Simplify boot partition mountpoint

This commit is contained in:
natemaia 2019-01-20 01:34:22 -08:00
parent 2a08b86a24
commit 8c85cc08af
2 changed files with 36 additions and 40 deletions

View File

@ -139,7 +139,7 @@ _InstSysBody="\nInstall syslinux to the master boot record (MBR) or to root (/)?
# File System # File System
_FSTitle="Choose Filesystem" _FSTitle="Choose Filesystem"
_SelRootBody="\nSelect the system root (/) partition.\n\nThis is where $DIST will be installed." _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" _SelSwpNone="None"
_SelSwpFile="Swapfile" _SelSwpFile="Swapfile"

View File

@ -113,20 +113,6 @@ declare -A BCMDS=(
[systemd-boot]="bootctl --path=/boot install" [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 # match the wm name with the actual session name used for xinit
declare -A WM_SESSIONS=( declare -A WM_SESSIONS=(
[dwm]='dwm' [dwm]='dwm'
@ -259,7 +245,7 @@ main()
show_cfg() show_cfg()
{ {
local cmd="${BCMDS[$BOOTLDR]}" local cmd="${BCMDS[$BOOTLDR]}"
local mnt="${BMNTS[$SYS-$BOOTLDR]}" local mnt="/boot"
local pkgs="${USER_PKGS# }" local pkgs="${USER_PKGS# }"
pkgs="${pkgs% }" pkgs="${pkgs% }"
pkgs="${pkgs% } ${PACKAGES# }" pkgs="${pkgs% } ${PACKAGES# }"
@ -1332,6 +1318,9 @@ select_boot_partition()
if [[ $AUTO_BOOT_PART && $AUTO_BOOT_PART == "$BOOT_PART" ]]; then if [[ $AUTO_BOOT_PART && $AUTO_BOOT_PART == "$BOOT_PART" ]]; then
BOOT_PART="$AUTO_BOOT_PART" BOOT_PART="$AUTO_BOOT_PART"
return 0 # were done here 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 else
BOOT_PART="$(menubox "$_PrepMount" "$_SelBiosBody" "$_Skip" "-" $PARTS)" BOOT_PART="$(menubox "$_PrepMount" "$_SelBiosBody" "$_Skip" "-" $PARTS)"
[[ $BOOT_PART == "" || $BOOT_PART == "$_Skip" ]] && { BOOT_PART=""; return 0; } [[ $BOOT_PART == "" || $BOOT_PART == "$_Skip" ]] && { BOOT_PART=""; return 0; }
@ -1368,7 +1357,6 @@ select_root_partition()
select_extra_partitions() select_extra_partitions()
{ {
local part local part
while (( COUNT > 0 )); do while (( COUNT > 0 )); do
tput civis tput civis
part="$(menubox "$_PrepMount " "$_ExtPartBody" "$_Done" "Return to the main menu" $PARTS)" part="$(menubox "$_PrepMount " "$_ExtPartBody" "$_Done" "Return to the main menu" $PARTS)"
@ -1382,7 +1370,6 @@ select_extra_partitions()
break; return 1 break; return 1
fi fi
done done
return 0 return 0
} }
@ -1733,11 +1720,22 @@ suckless_install()
setup_boot() setup_boot()
{ {
tput civis 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 [[ $BOOTLDR ]] || return 1
if [[ $BOOT_PART != "" ]]; then 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 setup_boot_device
fi fi
@ -1746,11 +1744,11 @@ setup_boot()
setup_grub() setup_grub()
{ {
local efidir="/sys/firmware/efi"
# grub has by far the worst setup of the three however # grub has by far the worst setup of the three however
# the configuration is shorter due to grub-mkconfig # the configuration is shorter due to grub-mkconfig
EDIT_FILES[bootloader]="/etc/default/grub" EDIT_FILES[bootloader]="/etc/default/grub"
if [[ $SYS == 'BIOS' ]]; then if [[ $SYS == 'BIOS' ]]; then
[[ $BOOT_DEVICE ]] || { select_device 'boot' || return 1; } [[ $BOOT_DEVICE ]] || { select_device 'boot' || return 1; }
BCMDS[grub]="grub-install --recheck --force --target=i386-pc $BOOT_DEVICE" 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 if [[ $ROOT_PART == */dev/mapper/* && ! $LVM && ! $LUKS_PASS ]]; then
luks_pass "$_LuksOpen" 1 || return 1 luks_pass "$_LuksOpen" 1 || return 1
fi fi
BCMDS[grub]="mount -t efivarfs efivarfs $efidir/efivars || true && BCMDS[grub]="mount -t efivarfs efivarfs /sys/firmware/efi/efivars || true &&
grub-install --recheck --force --bootloader-id=$DIST" 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 fi
BCMDS[grub]="mkdir -p /run/udev /run/lvm && BCMDS[grub]="mkdir -p /run/udev /run/lvm &&
@ -1812,19 +1810,19 @@ prerun_grub()
prerun_systemd-boot() prerun_systemd-boot()
{ {
# create the boot entry configs # create the boot entry configs
mkdir -p ${MNT}${BMNTS[$SYS-systemd-boot]}/loader/entries mkdir -p ${MNT}/boot/loader/entries
cat > ${MNT}${BMNTS[$SYS-systemd-boot]}/loader/loader.conf << EOF cat > ${MNT}/boot/loader/loader.conf << EOF
default $DIST default $DIST
timeout 5 timeout 5
editor no editor no
EOF EOF
cat > ${MNT}${BMNTS[$SYS-systemd-boot]}/loader/entries/${DIST}.conf << EOF cat > ${MNT}/boot/loader/entries/${DIST}.conf << EOF
title $DIST Linux title $DIST Linux
linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd %s" "/${UCODE}.img") linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd %s" "/${UCODE}.img")
initrd /initramfs-$KERNEL.img initrd /initramfs-$KERNEL.img
options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw
EOF 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 title $DIST Linux Fallback
linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd %s" "/${UCODE}.img") linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd %s" "/${UCODE}.img")
initrd /initramfs-$KERNEL-fallback.img initrd /initramfs-$KERNEL-fallback.img
@ -1850,10 +1848,10 @@ EOF
prerun_syslinux() prerun_syslinux()
{ {
mkdir -pv $MNT${BMNTS[$SYS-syslinux]}/syslinux mkdir -pv $MNT/boot/syslinux
cp -rfv $RUN/syslinux/splash.png $MNT${BMNTS[$SYS-syslinux]}/syslinux/ cp -rfv $RUN/syslinux/splash.png $MNT/boot/syslinux/
cp -rfv /usr/lib/syslinux/bios/* $MNT${BMNTS[$SYS-syslinux]}/syslinux/ cp -rfv /usr/lib/syslinux/bios/* $MNT/boot/syslinux/
cat > $MNT${BMNTS[$SYS-syslinux]}/syslinux/syslinux.cfg << EOF cat > $MNT/boot/syslinux/syslinux.cfg << EOF
UI vesamenu.c32 UI vesamenu.c32
MENU TITLE $DIST Boot Menu MENU TITLE $DIST Boot Menu
MENU BACKGROUND splash.png MENU BACKGROUND splash.png
@ -1922,9 +1920,9 @@ install_bootloader()
fi fi
if [[ $SYS == 'UEFI' ]]; then 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 -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 -name '[Bb][oO][oO][tT]' -type d -exec rm -rf '{}' \; >/dev/null 2>&1
fi fi
@ -1938,7 +1936,7 @@ install_bootloader()
fi fi
prerun_$BOOTLDR 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 chrun "${BCMDS[$BOOTLDR]}" 2>$ERR
errshow 1 "${BCMDS[$BOOTLDR]}" errshow 1 "${BCMDS[$BOOTLDR]}"
@ -1949,10 +1947,8 @@ install_bootloader()
fi fi
if [[ $BOOTLDR == 'grub' && $SYS == 'UEFI' ]]; then if [[ $BOOTLDR == 'grub' && $SYS == 'UEFI' ]]; then
printf "Copying grub efi stub to system fallback ${BMNTS[$SYS-$BOOTLDR]}/EFI/BOOT/BOOTX64.EFI\n" mkdir -pv $MNT/boot/EFI/BOOT
local esp="${MNT}${BMNTS[$SYS-$BOOTLDR]}" cp -fv $MNT/boot/EFI/$DIST/grubx64.efi $MNT/boot/EFI/BOOT/BOOTX64.EFI
mkdir -pv $esp/EFI/BOOT
cp -fv $esp/EFI/$DIST/grubx64.efi $esp/EFI/BOOT/BOOTX64.EFI
fi fi
return 0 return 0