#!/bin/bash # Arch Linux bootstrap script. Released under the terms of the GPL. # henning mueller usage() { cat >&2 < [source] This script is for installing Arch Linux after manual partitioning and network configuration. For the FTP installation, the original throttled Arch mirror is selected by default, so run with another mirror as [source], please. The full URL is expected in this case. Example: ftp://ftp5.gwdg.de/pub/linux/archlinux/current/os/x86_64 If you want to bootstrap another architecture than the script is currently running on, you have to specify a custom source. Options: -c Force chroot on Arch Linux. Local pacman cache will not be used. -f Generate fstab with UUIDs. Don't rely on that. -i Include packages from in the installation. should contain one package name per line. -x Xen mode. Activate serial console and deactivate virtual terminals. EOF exit 1 } wget="wget -q -t0" arch=$(uname -m) while [ $# -gt 1 ]; do case $1 in -c) chroot=true; shift;; -f) fstab=true; shift;; -i) [ ! -f $2 ] && echo "Package file '$2' does not exist." && exit 1 addpkgs=$(cat $2 | tr "\n" " ") shift; shift ;; -v) wget="wget -t0"; shift;; -x) xen=true; shift;; -h) usage;; *) break esac done mode=$1 target=$2 source=$3 [ "$mode" == "" ] || [ "$target" == "" ] && usage [ "$mode" == "ftp" ] || [ "$mode" == "cd" ] || usage [ "$UID" != "0" ] && echo "run as root, please." >&2 && exit 1 [ $(echo $target | egrep ^/) ] || target=$(pwd)/$target [ -d "$target" ] || mkdir -p $target [ "$source" == "" ] && source=ftp://ftp5.gwdg.de/pub/linux/archlinux/current/os/$arch || arch=$(basename $source) [ -f /etc/arch-release ] && [ ! $chroot ] && on_arch=true cache=$target/var/cache/pacman/pkg [ $on_arch ] && { mkdir -p $(dirname $cache) mkdir -p $target/var/lib/pacman [ ! -d $cache ] && ln -s /var/cache/pacman/pkg $cache } || { mkdir -p $cache } [ "$mode" == "ftp" ] && { install() { cd $cache echo " · $1" package=$(ls $1*.pkg.tar.gz 2>/dev/null | tail -1) [ ! -f "$package" ] && $wget $source/$1*.pkg.tar.gz || exit 1 package=$(ls $1*.pkg.tar.gz | tail -1) tar xzf $package -C $target || exit 1 } } [ "$mode" == "cd" ] && { install() { exit 1 } } [ $on_arch ] || { echo · downloading and installing bash. for package in glibc ncurses readline bash; do install $package done } echo · downloading and installing pacman. for package in libdownload libarchive acl attr zlib bzip2; do install $package done for package in openssl xz-utils pacman-?. pacman-mirrorlist; do install $package done echo · installing base. cd $target cp /etc/resolv.conf etc/resolv.conf mkdir sys proc dev tmp 2> /dev/null [ -z "$addpkgs" ] && { # TODO source for extra and community echo -e "[core]\nServer = $source" >> tmp/pacman.conf config="--config tmp/pacman.conf" } # sed -ie "s/#S/S/g" etc/pacman.d/mirrorlist cp etc/pacman.d/mirrorlist etc/pacman.d/mirrorlist.original tmp=$(echo $source | sed -e "s/current/\$repo/") echo "Server = $tmp" > etc/pacman.d/mirrorlist [ $on_arch ] && { pacman --noconfirm $config -r $target \ -Sfy base $addpkgs || exit 1 } || { mount -o bind /dev dev mount -t proc none proc mount -t sysfs none sys chroot $target /bin/bash < etc/inittab rc::sysinit:/etc/rc.sysinit rs:S1:wait:/etc/rc.single rm:2345:wait:/etc/rc.multi rh:06:wait:/etc/rc.shutdown su:S:wait:/sbin/sulogin -p c:2345:respawn:/sbin/agetty -8 38400 $vc linux EOF echo $vc > etc/securetty } [ $fstab ] && { grep $target /proc/mounts | while read line; do device=$(echo $line | cut -d ' ' -f 1) uuid=$(/lib/udev/vol_id --uuid $device) [ "$(echo $line | sed -e "s:$target::" | cut -d ' ' -f 2)" == "" ] && repl='/' || repl='' [ "$uuid" != "" ] && echo $line | sed -e "s:$target:$repl:" -e "s:$device:UUID=$uuid:" \ >> etc/fstab done } echo · cleaning up. [ -h $cache ] && rm $cache && mkdir $cache [ $on_arch ] || umount sys proc dev mv etc/resolv.conf.pacorig etc/resolv.conf rm -f etc/*.pac* tmp/pac* .FILELIST .INSTALL .PKGINFO ln -s . boot/boot echo -e "\nPackage installation complete.\n" [ ! $xen ] && cat < (example: /dev/sda /dev/sda1) For lilo: lilo A default initramfs setup was created during the package installation process. If you have special demands, generate a new one after editing /etc/mkinitcpio.conf and /etc/mkinitcpio.d/kernel26-fallback.conf: mkinitcpio -p kernel26 -k (example: 2.6.26-ARCH) Don't forget to set a root password. For completing the installation, edit /etc/rc.conf and /etc/fstab before unmounting the devices and rebooting. EOF [ $xen ] && cat <