From 8c85cc08afc0250482b275a00f9edd0e49d1436c Mon Sep 17 00:00:00 2001 From: natemaia Date: Sun, 20 Jan 2019 01:34:22 -0800 Subject: [PATCH] Simplify boot partition mountpoint --- lang/english.trans | 2 +- src/archlabs-installer | 74 ++++++++++++++++++++---------------------- 2 files changed, 36 insertions(+), 40 deletions(-) diff --git a/lang/english.trans b/lang/english.trans index 7d2fbe1..e8f31bb 100644 --- a/lang/english.trans +++ b/lang/english.trans @@ -139,7 +139,7 @@ _InstSysBody="\nInstall syslinux to the master boot record (MBR) or to root (/)? # File System _FSTitle="Choose Filesystem" _SelRootBody="\nSelect the system root (/) partition.\n\nThis is where $DIST will be installed." -_SelBiosBody="\nSelect the boot partition, this is only required for LUKS." +_SelBiosBody="\nDo you want to use a separate boot partition?\n\nThis partition is where the bootloader and init will be installed.\n" _SelSwpNone="None" _SelSwpFile="Swapfile" diff --git a/src/archlabs-installer b/src/archlabs-installer index 23f1134..ec7d963 100755 --- a/src/archlabs-installer +++ b/src/archlabs-installer @@ -113,20 +113,6 @@ declare -A BCMDS=( [systemd-boot]="bootctl --path=/boot install" ) -# boot partition mount points for each bootloader -declare -A BMNTS=( -[BIOS-grub]="/boot" -[UEFI-grub]="/boot/efi" -[BIOS-syslinux]="/boot" -[UEFI-systemd-boot]="/boot" -) - -# bootloader options with respective boot partition mountpoint -declare -A BOOTLDRS=( -[BIOS]="grub ${BMNTS[BIOS-grub]} syslinux ${BMNTS[BIOS-syslinux]}" -[UEFI]="systemd-boot ${BMNTS[UEFI-systemd-boot]} grub ${BMNTS[UEFI-grub]}" -) - # match the wm name with the actual session name used for xinit declare -A WM_SESSIONS=( [dwm]='dwm' @@ -259,7 +245,7 @@ main() show_cfg() { local cmd="${BCMDS[$BOOTLDR]}" - local mnt="${BMNTS[$SYS-$BOOTLDR]}" + local mnt="/boot" local pkgs="${USER_PKGS# }" pkgs="${pkgs% }" pkgs="${pkgs% } ${PACKAGES# }" @@ -1332,6 +1318,9 @@ select_boot_partition() if [[ $AUTO_BOOT_PART && $AUTO_BOOT_PART == "$BOOT_PART" ]]; then BOOT_PART="$AUTO_BOOT_PART" return 0 # were done here + elif [[ $LUKS && ! $LVM ]]; then + BOOT_PART="$(menubox "$_PrepMount" "\nSelect the boot partition (/boot), this is required for LUKS." $PARTS)" + [[ $BOOT_PART ]] || return 1 else BOOT_PART="$(menubox "$_PrepMount" "$_SelBiosBody" "$_Skip" "-" $PARTS)" [[ $BOOT_PART == "" || $BOOT_PART == "$_Skip" ]] && { BOOT_PART=""; return 0; } @@ -1368,7 +1357,6 @@ select_root_partition() select_extra_partitions() { local part - while (( COUNT > 0 )); do tput civis part="$(menubox "$_PrepMount " "$_ExtPartBody" "$_Done" "Return to the main menu" $PARTS)" @@ -1382,7 +1370,6 @@ select_extra_partitions() break; return 1 fi done - return 0 } @@ -1733,11 +1720,22 @@ suckless_install() setup_boot() { tput civis - BOOTLDR="$(menubox "$_PrepMount" "$_MntBootBody" ${BOOTLDRS[$SYS]})" + if [[ $SYS == 'BIOS' ]]; then + BOOTLDR="$(menubox "$_PrepMount" "$_MntBootBody" \ + "grub" "The Grand Unified Bootloader, standard among many Linux distributions" \ + "syslinux" "A collection of boot loaders capable of booting from drives, CDs, and over the network")" + + else + BOOTLDR="$(menubox "$_PrepMount" "$_MntBootBody" \ + "systemd-boot" "A simple UEFI boot manager which executes configured EFI images" \ + "grub" "The Grand Unified Bootloader, standard among many Linux distributions")" + + fi + [[ $BOOTLDR ]] || return 1 if [[ $BOOT_PART != "" ]]; then - mount_partition "$BOOT_PART" "${BMNTS[$SYS-$BOOTLDR]}" && SEP_BOOT=true || return 1 + mount_partition "$BOOT_PART" "/boot" && SEP_BOOT=true || return 1 setup_boot_device fi @@ -1746,11 +1744,11 @@ setup_boot() setup_grub() { - local efidir="/sys/firmware/efi" - # grub has by far the worst setup of the three however # the configuration is shorter due to grub-mkconfig + EDIT_FILES[bootloader]="/etc/default/grub" + if [[ $SYS == 'BIOS' ]]; then [[ $BOOT_DEVICE ]] || { select_device 'boot' || return 1; } BCMDS[grub]="grub-install --recheck --force --target=i386-pc $BOOT_DEVICE" @@ -1758,10 +1756,10 @@ setup_grub() if [[ $ROOT_PART == */dev/mapper/* && ! $LVM && ! $LUKS_PASS ]]; then luks_pass "$_LuksOpen" 1 || return 1 fi - BCMDS[grub]="mount -t efivarfs efivarfs $efidir/efivars || true && - grub-install --recheck --force --bootloader-id=$DIST" + BCMDS[grub]="mount -t efivarfs efivarfs /sys/firmware/efi/efivars || true && + grub-install --recheck --force --target=x86_64-efi --efi-directory=/boot --bootloader-id=$DIST" - grep -q $efidir/efivars <<< "$(mount)" || mount -t efivarfs efivarfs $efidir/efivars + grep -q /sys/firmware/efi/efivars <<< "$(mount)" || mount -t efivarfs efivarfs /sys/firmware/efi/efivars fi BCMDS[grub]="mkdir -p /run/udev /run/lvm && @@ -1812,19 +1810,19 @@ prerun_grub() prerun_systemd-boot() { # create the boot entry configs - mkdir -p ${MNT}${BMNTS[$SYS-systemd-boot]}/loader/entries - cat > ${MNT}${BMNTS[$SYS-systemd-boot]}/loader/loader.conf << EOF + mkdir -p ${MNT}/boot/loader/entries + cat > ${MNT}/boot/loader/loader.conf << EOF default $DIST timeout 5 editor no EOF - cat > ${MNT}${BMNTS[$SYS-systemd-boot]}/loader/entries/${DIST}.conf << EOF + cat > ${MNT}/boot/loader/entries/${DIST}.conf << EOF title $DIST Linux linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd %s" "/${UCODE}.img") initrd /initramfs-$KERNEL.img options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw EOF - cat > ${MNT}${BMNTS[$SYS-systemd-boot]}/loader/entries/${DIST}-fallback.conf << EOF + cat > ${MNT}/boot/loader/entries/${DIST}-fallback.conf << EOF title $DIST Linux Fallback linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd %s" "/${UCODE}.img") initrd /initramfs-$KERNEL-fallback.img @@ -1850,10 +1848,10 @@ EOF prerun_syslinux() { - mkdir -pv $MNT${BMNTS[$SYS-syslinux]}/syslinux - cp -rfv $RUN/syslinux/splash.png $MNT${BMNTS[$SYS-syslinux]}/syslinux/ - cp -rfv /usr/lib/syslinux/bios/* $MNT${BMNTS[$SYS-syslinux]}/syslinux/ - cat > $MNT${BMNTS[$SYS-syslinux]}/syslinux/syslinux.cfg << EOF + mkdir -pv $MNT/boot/syslinux + cp -rfv $RUN/syslinux/splash.png $MNT/boot/syslinux/ + cp -rfv /usr/lib/syslinux/bios/* $MNT/boot/syslinux/ + cat > $MNT/boot/syslinux/syslinux.cfg << EOF UI vesamenu.c32 MENU TITLE $DIST Boot Menu MENU BACKGROUND splash.png @@ -1922,9 +1920,9 @@ install_bootloader() fi if [[ $SYS == 'UEFI' ]]; then - find ${MNT}${BMNTS[UEFI-$BOOTLDR]}/EFI/ -maxdepth 1 -mindepth 1 \ + find $MNT/boot/EFI/ -maxdepth 1 -mindepth 1 \ -name '[aA][rR][cC][hH][lL]abs' -type d -exec rm -rf '{}' \; >/dev/null 2>&1 - find ${MNT}${BMNTS[UEFI-$BOOTLDR]}/EFI/ -maxdepth 1 -mindepth 1 \ + find $MNT/boot/EFI/ -maxdepth 1 -mindepth 1 \ -name '[Bb][oO][oO][tT]' -type d -exec rm -rf '{}' \; >/dev/null 2>&1 fi @@ -1938,7 +1936,7 @@ install_bootloader() fi prerun_$BOOTLDR - printf "Installing and setting up $BOOTLDR in ${BMNTS[$SYS-$BOOTLDR]}\n" + printf "Installing and setting up $BOOTLDR\n" chrun "${BCMDS[$BOOTLDR]}" 2>$ERR errshow 1 "${BCMDS[$BOOTLDR]}" @@ -1949,10 +1947,8 @@ install_bootloader() fi if [[ $BOOTLDR == 'grub' && $SYS == 'UEFI' ]]; then - printf "Copying grub efi stub to system fallback ${BMNTS[$SYS-$BOOTLDR]}/EFI/BOOT/BOOTX64.EFI\n" - local esp="${MNT}${BMNTS[$SYS-$BOOTLDR]}" - mkdir -pv $esp/EFI/BOOT - cp -fv $esp/EFI/$DIST/grubx64.efi $esp/EFI/BOOT/BOOTX64.EFI + mkdir -pv $MNT/boot/EFI/BOOT + cp -fv $MNT/boot/EFI/$DIST/grubx64.efi $MNT/boot/EFI/BOOT/BOOTX64.EFI fi return 0