#!/usr/bin/bash -eu # # Author: Casey DeLorme # # This is used by my packer build, but is wired to work for a complete install. # # Description: Thse are the pre-installation steps for Arch, where you may have # launched the iso and have a terminal, but you're working off a live system # and still need to partition the disk. # # Warning: This installation is wired for efi mode installations. While it # may print a warning it won't stop the installation and may leave you with # a derelict system. # # Warning: This currently uses /dev/sda explicitly and may delete data or fail # if there are multiple disks connected or you are using alternative storage # such as M.2/NVME. [ ! -f /sys/firmware/efi/efivars ] && echo "efivars not mounted and this install may leave you with a derelict system..." # optionally print all commands [ -n "$DEBUG" ] && set -x # test network connection ping -c 3 archlinux.org # synchronize time (print for debug) timedatectl set-ntp true timedatectl status # @todo: future editions will intelligently check available disks, # may ask which disk to use, may detect if running on a laptop, # may automatically choose or ask if swap should be sized for # hibernation, and appropriately modify partition logic. # partition the hard drive parted /dev/sda -s 'mklabel gpt' parted /dev/sda -s 'mkpart primary fat32 1MiB 1024MiB' parted /dev/sda -s 'set 1 esp on' parted /dev/sda -s 'mkpart primary linux-swap 1024MiB 3072MiB' parted /dev/sda -s 'mkpart primary btrfs 3072MiB 100%' # format the partitions mkfs.fat -F32 -nEFI /dev/sda1 mkswap -Larch /dev/sda2 mkfs.btrfs -fLarch /dev/sda3 # enable and mount partitions with appropriate settings swapon /dev/sda2 mount -o "noatime,compress=lzo,space_cache,autodefrag,ssd" /dev/sda3 /mnt mkdir /mnt/boot mount /dev/sda1 /mnt/boot # install base and base-devel package sets, and generate the fstab pacstrap /mnt base base-devel genfstab -U -p /mnt >> /mnt/etc/fstab # this assumes that arch.sh and install/ exists and will copy them to continue # @note: would prefer to copy to `/tmp` but `/mnt/tmp` from iso is a separate tmpfs mkdir -p /mnt/srv/arch-desktop cp -r install /mnt/srv/arch-desktop/ cp arch.sh /mnt/srv/arch-desktop/ # proceed to automate arch-chroot installation then umount and reboot with an async delay arch-chroot /mnt /srv/arch-desktop/arch.sh umount -R /mnt (sleep 5 && systemctl reboot) &