move all UEFI parameters to base.sh

This commit is contained in:
Tobias Powalowski 2023-01-07 17:16:24 +01:00
parent 50457a7ca0
commit 671444ca0e
9 changed files with 54 additions and 69 deletions

View file

@ -210,6 +210,7 @@ fi
: >/tmp/.setup
set_title
detect_uefi_parameters
DIALOG --msgbox "Welcome to the Archboot Arch Linux Installation program.\n\nThe install process is fairly straightforward, and you should run through the options in the order they are presented.\n\nIf you are unfamiliar with partitioning/making filesystems, you may want to consult some documentation before continuing.\n\nYou can view all output from commands by viewing your ${VC} console (ALT-F${VC_NUM}). ALT-F1 will bring you back here." 14 65

View file

@ -44,7 +44,7 @@ autoprepare() {
if [[ "${NAME_SCHEME_PARAMETER_RUN}" == "" ]]; then
set_device_name_scheme || return 1
fi
if [[ "${GUIDPARAMETER}" == "1" ]]; then
if [[ "${_GUIDPARAMETER}" == "1" ]]; then
DIALOG --inputbox "Enter the mountpoint of your UEFI SYSTEM PARTITION (Default is /boot) : " 10 60 "/boot" 2>"${ANSWER}" || return 1
UEFISYS_MP="$(cat "${ANSWER}")"
fi
@ -63,14 +63,14 @@ autoprepare() {
command -v mkfs.nilfs2 2>/dev/null && FSOPTS="${FSOPTS} nilfs2 Nilfs2"
command -v mkfs.jfs 2>/dev/null && FSOPTS="${FSOPTS} jfs JFS"
# create 1 MB bios_grub partition for grub BIOS GPT support
if [[ "${GUIDPARAMETER}" == "1" ]]; then
if [[ "${_GUIDPARAMETER}" == "1" ]]; then
GUID_PART_SIZE="2"
GPT_BIOS_GRUB_PART_SIZE="${GUID_PART_SIZE}"
_PART_NUM="1"
_GPT_BIOS_GRUB_PART_NUM="${_PART_NUM}"
DISC_SIZE="$((DISC_SIZE-GUID_PART_SIZE))"
fi
if [[ "${GUIDPARAMETER}" == "1" ]]; then
if [[ "${_GUIDPARAMETER}" == "1" ]]; then
if [[ "${_UEFISYS_BOOTPART}" == "1" ]]; then
while [[ "${UEFISYS_PART_SET}" == "" ]]; do
DIALOG --inputbox "Enter the size (MB) of your /boot partition,\nMinimum value is 260.\n\nDisk space left: ${DISC_SIZE} MB" 10 65 "512" 2>"${ANSWER}" || return 1
@ -207,7 +207,7 @@ autoprepare() {
# disable swap and all mounted partitions, umount / last!
_umountall
# we assume a /dev/sdX,/dev/vdX or /dev/nvmeXnY format
if [[ "${GUIDPARAMETER}" == "1" ]]; then
if [[ "${_GUIDPARAMETER}" == "1" ]]; then
# GPT (GUID) is supported only by 'parted' or 'sgdisk'
printk off
DIALOG --infobox "Partitioning ${DEVICE} ..." 0 0
@ -274,7 +274,7 @@ autoprepare() {
_FSSPEC_SWAP_PART="${_SWAP_PART_NUM}:swap:swap::SWAP_ARCH"
_FSSPEC_BOOT_PART="${_BOOT_PART_NUM}:/boot:ext2::BOOT_ARCH"
_FSSPEC_UEFISYS_PART="${_UEFISYS_PART_NUM}:${UEFISYS_MP}:vfat:-F32:EFISYS"
if [[ "${GUIDPARAMETER}" == "1" ]]; then
if [[ "${_GUIDPARAMETER}" == "1" ]]; then
if [[ "${_UEFISYS_BOOTPART}" == "1" ]]; then
FSSPECS="${_FSSPEC_ROOT_PART} ${_FSSPEC_UEFISYS_PART} ${_FSSPEC_HOME_PART} ${_FSSPEC_SWAP_PART}"
else

View file

@ -66,3 +66,33 @@ geteditor() {
fi
}
detect_uefi_paramaters() {
_UEFI_BOOT="0"
_UEFI_SECURE_BOOT="0"
_GUIDPARAMETER="0"
[[ -e "/sys/firmware/efi" ]] && _UEFI_BOOT="1"
if [[ "${_UEFI_BOOT}" == "1" ]]; then
_GUIDPARAMETER="1"
_SECUREBOOT_VAR_VALUE="$(efivar -n 8be4df61-93ca-11d2-aa0d-00e098032b8c-SecureBoot 2>/dev/null | tail -n -1 | awk '{print $2}')"
_SETUPMODE_VAR_VALUE="$(efivar -n 8be4df61-93ca-11d2-aa0d-00e098032b8c-SetupMode 2>/dev/null | tail -n -1 | awk '{print $2}')"
if [[ "${_SECUREBOOT_VAR_VALUE}" == "01" ]] && [[ "${_SETUPMODE_VAR_VALUE}" == "00" ]]; then
_UEFI_SECURE_BOOT="1"
fi
if [[ "${RUNNING_ARCH}" == "x86_64" ]]; then
if grep -q '_IA32_UEFI=1' /proc/cmdline 1>/dev/null; then
_EFI_MIXED="1"
_UEFI_ARCH="IA32"
_SPEC_UEFI_ARCH="ia32"
else
_EFI_MIXED="0"
_UEFI_ARCH="X64"
_SPEC_UEFI_ARCH="x64"
fi
fi
if [[ "${RUNNING_ARCH}" == "aarch64" ]]; then
_EFI_MIXED="0"
_UEFI_ARCH="AA64"
_SPEC_UEFI_ARCH="aa64"
fi
fi
}

View file

@ -319,10 +319,9 @@ set_device_name_scheme() {
NAME_SCHEME_PARAMETER=""
NAME_SCHEME_LEVELS=""
MENU_DESC_TEXT=""
detect_uefi_boot
## util-linux root=PARTUUID=/root=PARTLABEL= support - https://git.kernel.org/?p=utils/util-linux/util-linux.git;a=commitdiff;h=fc387ee14c6b8672761ae5e67ff639b5cae8f27c;hp=21d1fa53f16560dacba33fffb14ffc05d275c926
## mkinitcpio's init root=PARTUUID= support - https://projects.archlinux.org/mkinitcpio.git/tree/init_functions#n185
if [[ "${_DETECTED_UEFI_BOOT}" == "1" ]]; then
if [[ "${_UEFI_BOOT}" == "1" ]]; then
NAME_SCHEME_LEVELS="${NAME_SCHEME_LEVELS} PARTUUID PARTUUID=<partuuid> PARTLABEL PARTLABEL=<partlabel>"
MENU_DESC_TEXT="\nPARTUUID and PARTLABEL are specific to GPT disks.\nIn GPT disks, PARTUUID is recommended.\nIn MBR/msdos disks,"
fi
@ -665,7 +664,7 @@ _createraid()
if [[ ${RAID_PARTITION} == "1" ]]; then
# switch for mbr usage
set_guid
if [[ "${GUIDPARAMETER}" == "0" ]]; then
if [[ "${_GUIDPARAMETER}" == "0" ]]; then
DIALOG --msgbox "Now you'll be put into the cfdisk program where you can partition your raiddevice to your needs." 6 70
cfdisk "${RAIDDEVICE}"
else

View file

@ -96,7 +96,7 @@ freeze_xfs() {
## Setup kernel cmdline parameters to be added to bootloader configs
bootloader_kernel_parameters() {
if [[ "${_DETECTED_UEFI_BOOT}" == "1" ]]; then
if [[ "${_UEFI_BOOT}" == "1" ]]; then
[[ "${NAME_SCHEME_PARAMETER}" == "PARTUUID" ]] && getrootpartuuid
[[ "${NAME_SCHEME_PARAMETER}" == "PARTLABEL" ]] && getrootpartlabel
fi
@ -154,31 +154,12 @@ abort_f2fs_bootpart() {
fi
}
do_uefi_setup_env_vars() {
if [[ "${RUNNING_ARCH}" == "x86_64" ]]; then
if grep -q '_IA32_UEFI=1' /proc/cmdline 1>/dev/null; then
_EFI_MIXED="1"
_UEFI_ARCH="IA32"
_SPEC_UEFI_ARCH="ia32"
else
_EFI_MIXED="0"
_UEFI_ARCH="X64"
_SPEC_UEFI_ARCH="x64"
fi
fi
if [[ "${RUNNING_ARCH}" == "aarch64" ]]; then
_EFI_MIXED="0"
_UEFI_ARCH="AA64"
_SPEC_UEFI_ARCH="aa64"
fi
}
do_uefi_common() {
PACKAGES=""
[[ ! -f "${DESTDIR}/usr/bin/mkfs.vfat" ]] && PACKAGES="${PACKAGES} dosfstools"
[[ ! -f "${DESTDIR}/usr/bin/efivar" ]] && PACKAGES="${PACKAGES} efivar"
[[ ! -f "${DESTDIR}/usr/bin/efibootmgr" ]] && PACKAGES="${PACKAGES} efibootmgr"
if [[ "${_DETECTED_UEFI_SECURE_BOOT}" == "1" ]]; then
if [[ "${_UEFI_SECURE_BOOT}" == "1" ]]; then
[[ ! -f "${DESTDIR}/usr/bin/mokutil" ]] && PACKAGES="${PACKAGES} mokutil"
[[ ! -f "${DESTDIR}/usr/bin/efi-readvar" ]] && PACKAGES="${PACKAGES} efitools"
[[ ! -f "${DESTDIR}/usr/bin/sbsign" ]] && PACKAGES="${PACKAGES} sbsigntools"
@ -230,7 +211,7 @@ do_uefi_bootmgr_setup() {
do_uefi_secure_boot_efitools() {
do_uefi_common
# install helper tools and create entries in UEFI boot manager, if not present
if [[ "${_DETECTED_UEFI_SECURE_BOOT}" == "1" ]]; then
if [[ "${_UEFI_SECURE_BOOT}" == "1" ]]; then
if [[ ! -f "${UEFISYS_MP}/EFI/BOOT/HashTool.efi" ]]; then
cp "${DESTDIR}/usr/share/efitools/efi/HashTool.efi" "${UEFISYS_MP}/EFI/BOOT/HashTool.efi"
_BOOTMGR_LABEL="HashTool (Secure Boot)"
@ -592,7 +573,7 @@ do_grub_config() {
fi
fi
## Move old config file, if any
if [[ "${_DETECTED_UEFI_SECURE_BOOT}" == "1" ]]; then
if [[ "${_UEFI_SECURE_BOOT}" == "1" ]]; then
GRUB_CFG="grub${_SPEC_UEFI_ARCH}.cfg"
else
GRUB_CFG="grub.cfg"
@ -882,7 +863,7 @@ do_grub_uefi() {
do_grub_common_before
DIALOG --infobox "Setting up GRUB(2) UEFI. This needs some time ..." 3 55
chroot_mount
if [[ "${_DETECTED_UEFI_SECURE_BOOT}" == "1" ]]; then
if [[ "${_UEFI_SECURE_BOOT}" == "1" ]]; then
# install fedora shim
[[ ! -d ${DESTDIR}/${UEFISYS_MP}/EFI/BOOT ]] && mkdir -p "${DESTDIR}"/"${UEFISYS_MP}"/EFI/BOOT/
cp -f /usr/share/archboot/bootloader/shim"${_SPEC_UEFI_ARCH}".efi "${DESTDIR}"/"${UEFISYS_MP}"/EFI/BOOT/BOOT"${_UEFI_ARCH}".EFI
@ -906,7 +887,7 @@ do_grub_uefi() {
GRUB_UEFI="1"
do_grub_config
GRUB_UEFI=""
if [[ "${_DETECTED_UEFI_SECURE_BOOT}" == "1" ]]; then
if [[ "${_UEFI_SECURE_BOOT}" == "1" ]]; then
# generate GRUB with config embeded
#remove existing, else weird things are happening
[[ -f "${DESTDIR}/${GRUB_PREFIX_DIR}/grub${_SPEC_UEFI_ARCH}.efi" ]] && rm "${DESTDIR}"/"${GRUB_PREFIX_DIR}"/grub"${_SPEC_UEFI_ARCH}".efi
@ -927,7 +908,7 @@ do_grub_uefi() {
fi
cp /"${GRUB_PREFIX_DIR}"/"${GRUB_CFG}" "${UEFISYS_MP}"/EFI/BOOT/grub"${_SPEC_UEFI_ARCH}".cfg
fi
if [[ -e "${DESTDIR}/${UEFISYS_MP}/EFI/grub/grub${_SPEC_UEFI_ARCH}.efi" && "${_DETECTED_UEFI_SECURE_BOOT}" == "0" && -e "${DESTDIR}/boot/grub/${_GRUB_ARCH}-efi/core.efi" ]]; then
if [[ -e "${DESTDIR}/${UEFISYS_MP}/EFI/grub/grub${_SPEC_UEFI_ARCH}.efi" && "${_UEFI_SECURE_BOOT}" == "0" && -e "${DESTDIR}/boot/grub/${_GRUB_ARCH}-efi/core.efi" ]]; then
_BOOTMGR_LABEL="GRUB"
_BOOTMGR_LOADER_DIR="/EFI/grub/grub${_SPEC_UEFI_ARCH}.efi"
do_uefi_bootmgr_setup
@ -937,7 +918,7 @@ do_grub_uefi() {
DIALOG --infobox "GRUB(2) for ${_UEFI_ARCH} UEFI has been installed successfully.\n\nContinuing in 5 seconds ..." 5 60
sleep 5
S_BOOTLOADER="1"
elif [[ -e "${DESTDIR}/${UEFISYS_MP}/EFI/BOOT/grub${_SPEC_UEFI_ARCH}.efi" && "${_DETECTED_UEFI_SECURE_BOOT}" == "1" ]]; then
elif [[ -e "${DESTDIR}/${UEFISYS_MP}/EFI/BOOT/grub${_SPEC_UEFI_ARCH}.efi" && "${_UEFI_SECURE_BOOT}" == "1" ]]; then
do_secureboot_keys || return 1
do_mok_sign
do_pacman_sign
@ -962,7 +943,7 @@ install_bootloader_uefi() {
_EFISTUB_MENU_LABEL="EFISTUB"
_EFISTUB_MENU_TEXT="EFISTUB for ${_UEFI_ARCH} UEFI"
fi
if [[ "${_DETECTED_UEFI_SECURE_BOOT}" == "1" ]]; then
if [[ "${_UEFI_SECURE_BOOT}" == "1" ]]; then
do_grub_uefi
else
DIALOG --menu "Which ${_UEFI_ARCH} UEFI bootloader would you like to use?" 9 55 3 \
@ -987,9 +968,7 @@ install_bootloader() {
select_source || return 1
fi
prepare_pacman
detect_uefi_boot
do_uefi_setup_env_vars
if [[ "${_DETECTED_UEFI_BOOT}" == "1" ]]; then
if [[ "${_UEFI_BOOT}" == "1" ]]; then
install_bootloader_uefi
else
if [[ "${RUNNING_ARCH}" == "aarch64" || "${RUNNING_ARCH}" == "riscv64" ]]; then

View file

@ -155,33 +155,11 @@ locale_gen() {
# set GUID (gpt) usage
set_guid() {
GUIDPARAMETER="0"
detect_uefi_boot
# all uefi systems should use GUID layout
if [[ "${_DETECTED_UEFI_BOOT}" == "1" ]]; then
GUIDPARAMETER="1"
else
if [[ "${_UEFI_BOOT}" == "0" ]]; then
## Lenovo BIOS-GPT issues - Arch Forum - https://bbs.archlinux.org/viewtopic.php?id=131149 , https://bbs.archlinux.org/viewtopic.php?id=133330 , https://bbs.archlinux.org/viewtopic.php?id=138958
## Lenovo BIOS-GPT issues - in Fedora - https://bugzilla.redhat.com/show_bug.cgi?id=735733, https://bugzilla.redhat.com/show_bug.cgi?id=749325 , http://git.fedorahosted.org/git/?p=anaconda.git;a=commit;h=ae74cebff312327ce2d9b5ac3be5dbe22e791f09
#shellcheck disable=SC2034
DIALOG --yesno "You are running in BIOS/MBR mode.\n\nDo you want to use GUID Partition Table (GPT)?\n\nIt is a standard for the layout of the partition table on a physical storage disk. Although it forms a part of the Unified Extensible Firmware Interface (UEFI) standard, it is also used on some BIOS systems because of the limitations of MBR aka msdos partition tables, which restrict maximum disk size to 2 TiB.\n\nWindows 10 and later versions include the capability to use GPT for non-boot aka data disks (only UEFI systems can boot Windows 10 and later from GPT disks).\n\nAttention:\n- Please check if your other operating systems have GPT support!\n- Use this option for a GRUB(2) setup, which should support LVM, RAID\n etc., which doesn't fit into the usual 30k MS-DOS post-MBR gap.\n- BIOS-GPT boot may not work in some Lenovo systems (irrespective of the\n bootloader used). " 0 0 && GUIDPARAMETER="1"
DIALOG --yesno "You are running in BIOS/MBR mode.\n\nDo you want to use GUID Partition Table (GPT)?\n\nIt is a standard for the layout of the partition table on a physical storage disk. Although it forms a part of the Unified Extensible Firmware Interface (UEFI) standard, it is also used on some BIOS systems because of the limitations of MBR aka msdos partition tables, which restrict maximum disk size to 2 TiB.\n\nWindows 10 and later versions include the capability to use GPT for non-boot aka data disks (only UEFI systems can boot Windows 10 and later from GPT disks).\n\nAttention:\n- Please check if your other operating systems have GPT support!\n- Use this option for a GRUB(2) setup, which should support LVM, RAID\n etc., which doesn't fit into the usual 30k MS-DOS post-MBR gap.\n- BIOS-GPT boot may not work in some Lenovo systems (irrespective of the\n bootloader used). " 0 0 && _GUIDPARAMETER="1"
fi
}
detect_uefi_secure_boot() {
_DETECTED_UEFI_SECURE_BOOT="0"
if [[ "${_DETECTED_UEFI_BOOT}" == "1" ]]; then
_SECUREBOOT_VAR_VALUE="$(efivar -n 8be4df61-93ca-11d2-aa0d-00e098032b8c-SecureBoot 2>/dev/null | tail -n -1 | awk '{print $2}')"
_SETUPMODE_VAR_VALUE="$(efivar -n 8be4df61-93ca-11d2-aa0d-00e098032b8c-SetupMode 2>/dev/null | tail -n -1 | awk '{print $2}')"
if [[ "${_SECUREBOOT_VAR_VALUE}" == "01" ]] && [[ "${_SETUPMODE_VAR_VALUE}" == "00" ]]; then
_DETECTED_UEFI_SECURE_BOOT="1"
fi
fi
}
detect_uefi_boot() {
_DETECTED_UEFI_BOOT="0"
[[ -e "/sys/firmware/efi" ]] && _DETECTED_UEFI_BOOT="1"
detect_uefi_secure_boot
}

View file

@ -11,7 +11,6 @@ destdir_mounts(){
# Run mountpoints, if nothing is mounted on ${DESTDIR}
if [[ "${PART_ROOT}" == "" ]]; then
DIALOG --msgbox "Setup couldn't detect mounted partition(s) in ${DESTDIR}, please set mountpoints first." 0 0
detect_uefi_boot
mountpoints || return 1
fi
}
@ -383,7 +382,7 @@ _mkfs() {
#shellcheck disable=SC2155
local _fslabel="$(getfslabel "${_device}")"
if [[ "${_DETECTED_UEFI_BOOT}" == "1" ]]; then
if [[ "${_UEFI_BOOT}" == "1" ]]; then
#shellcheck disable=SC2155
local _partuuid="$(getpartuuid "${_device}")"
#shellcheck disable=SC2155
@ -404,7 +403,7 @@ _mkfs() {
_device="LABEL=${_fslabel}"
fi
else
if [[ "${_DETECTED_UEFI_BOOT}" == "1" ]]; then
if [[ "${_UEFI_BOOT}" == "1" ]]; then
if [[ "${NAME_SCHEME_PARAMETER}" == "PARTUUID" ]]; then
if [[ -n "${_partuuid}" ]]; then
_device="PARTUUID=${_partuuid}"
@ -425,7 +424,7 @@ _mkfs() {
# _GUID_VALUE:
# get real device name from lsblk first to get GUID_VALUE from blkid
_GUID_VALUE="$(${_BLKID} -p -i -s PART_ENTRY_TYPE -o value "$(${_LSBLK} NAME,UUID,LABEL,PARTLABEL,PARTUUID | grep "$(echo "${_device}" | cut -d"=" -f2)" | cut -d" " -f 1)")"
if ! [[ "${_GUID_VALUE}" == "933ac7e1-2eb4-4f13-b844-0e14e2aef915" && "${_mountpoint}" == "/home" || "${_GUID_VALUE}" == "0657fd6d-a4ab-43c4-84e5-0933c84b4f4f" && "${_mountpoint}" == "swap" || "${_GUID_VALUE}" == "c12a7328-f81f-11d2-ba4b-00a0c93ec93b" && "${_mountpoint}" == "/boot" && "${_DETECTED_UEFI_BOOT}" == "1" || "${_mountpoint}" == "/" ]]; then
if ! [[ "${_GUID_VALUE}" == "933ac7e1-2eb4-4f13-b844-0e14e2aef915" && "${_mountpoint}" == "/home" || "${_GUID_VALUE}" == "0657fd6d-a4ab-43c4-84e5-0933c84b4f4f" && "${_mountpoint}" == "swap" || "${_GUID_VALUE}" == "c12a7328-f81f-11d2-ba4b-00a0c93ec93b" && "${_mountpoint}" == "/boot" && "${_UEFI_BOOT}" == "1" || "${_mountpoint}" == "/" ]]; then
if [[ "${_mountoptions}" == "" ]]; then
echo -n "${_device} ${_mountpoint} ${_fstype} defaults 0 " >>/tmp/.fstab
else

View file

@ -79,7 +79,6 @@ update_environment() {
DIALOG --infobox "Packages are already in pacman cache. Continuing in 3 seconds ..." 3 70
sleep 3
else
detect_uefi_boot
UPDATE_ENVIRONMENT=""
if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt "2571000" ]]; then
if ! [[ "${RUNNING_ARCH}" == "riscv64" ]]; then

View file

@ -138,7 +138,7 @@ partition() {
[[ "${DISC}" == "DONE" ]] && break
MSDOS_DETECTED=""
if ! [[ "${DISC}" == "" ]]; then
if [[ "${GUIDPARAMETER}" == "1" ]]; then
if [[ "${_GUIDPARAMETER}" == "1" ]]; then
CHECK_BIOS_BOOT_GRUB=""
CHECK_UEFISYS_PART=""
RUN_CFDISK="1"