From 0c68b5d68555725cf279452096a625676b2c3093 Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Wed, 28 Dec 2022 08:53:53 +0100 Subject: [PATCH] use _DETECT_UEFI for PARTUUID and PARTLABEL support --- usr/lib/archboot/installer/bootloader.sh | 7 ++----- usr/lib/archboot/installer/mountpoints.sh | 4 ++-- usr/lib/archboot/installer/partition.sh | 22 ---------------------- 3 files changed, 4 insertions(+), 29 deletions(-) diff --git a/usr/lib/archboot/installer/bootloader.sh b/usr/lib/archboot/installer/bootloader.sh index dfa7fa651..95dc22f9d 100644 --- a/usr/lib/archboot/installer/bootloader.sh +++ b/usr/lib/archboot/installer/bootloader.sh @@ -96,7 +96,7 @@ freeze_xfs() { ## Setup kernel cmdline parameters to be added to bootloader configs bootloader_kernel_parameters() { - if [[ "${GUID_DETECTED}" == "1" ]]; then + if [[ "${_DETECTED_UEFI_BOOT}" == "1" ]]; then [[ "${NAME_SCHEME_PARAMETER}" == "PARTUUID" ]] && getrootpartuuid [[ "${NAME_SCHEME_PARAMETER}" == "PARTLABEL" ]] && getrootpartlabel fi @@ -664,9 +664,9 @@ if [ "\${grub_platform}" == "efi" ]; then set _SPEC_UEFI_ARCH="aa64" fi fi +# Include modules - required for boot insmod part_gpt insmod part_msdos -# Include fat fs module - required for uefi systems. insmod fat insmod ${BOOT_PART_FS} insmod ${ROOT_PART_FS} @@ -720,9 +720,7 @@ if loadfont "\${_fontfile}" ; then terminal_output gfxterm fi EOF - echo "" >> "${DESTDIR}/${GRUB_PREFIX_DIR}/${GRUB_CFG}" [[ -e "/tmp/.device-names" ]] && sort "/tmp/.device-names" >> "${DESTDIR}/${GRUB_PREFIX_DIR}/${GRUB_CFG}" - echo "" >> "${DESTDIR}/${GRUB_PREFIX_DIR}/${GRUB_CFG}" if [[ "${NAME_SCHEME_PARAMETER}" == "PARTUUID" ]] || [[ "${NAME_SCHEME_PARAMETER}" == "FSUUID" ]] ; then GRUB_ROOT_DRIVE="search --fs-uuid --no-floppy --set=root ${BOOT_PART_HINTS_STRING} ${BOOT_PART_FS_UUID}" else @@ -792,7 +790,6 @@ EOF ## create example file for windows cat << EOF >> "${DESTDIR}/${GRUB_PREFIX_DIR}/${GRUB_CFG}" if [ "\${grub_platform}" == "pc" ]; then - ## Microsoft Windows 10/11 BIOS #menuentry Microsoft Windows 10/11 BIOS-MBR { # insmod part_msdos diff --git a/usr/lib/archboot/installer/mountpoints.sh b/usr/lib/archboot/installer/mountpoints.sh index 9cfec50e4..c61ccfd43 100644 --- a/usr/lib/archboot/installer/mountpoints.sh +++ b/usr/lib/archboot/installer/mountpoints.sh @@ -385,7 +385,7 @@ _mkfs() { #shellcheck disable=SC2155 local _fslabel="$(getfslabel "${_device}")" - if [[ "${GUID_DETECTED}" == "1" ]]; then + if [[ "${_DETECTED_UEFI_BOOT}" == "1" ]]; then #shellcheck disable=SC2155 local _partuuid="$(getpartuuid "${_device}")" #shellcheck disable=SC2155 @@ -406,7 +406,7 @@ _mkfs() { _device="LABEL=${_fslabel}" fi else - if [[ "${GUID_DETECTED}" == "1" ]]; then + if [[ "${_DETECTED_UEFI_BOOT}" == "1" ]]; then if [[ "${NAME_SCHEME_PARAMETER}" == "PARTUUID" ]]; then if [[ -n "${_partuuid}" ]]; then _device="PARTUUID=${_partuuid}" diff --git a/usr/lib/archboot/installer/partition.sh b/usr/lib/archboot/installer/partition.sh index 48427be29..1ea5cf115 100644 --- a/usr/lib/archboot/installer/partition.sh +++ b/usr/lib/archboot/installer/partition.sh @@ -1,22 +1,17 @@ #!/usr/bin/env bash # created by Tobias Powalowski detect_DISC() { - if [[ "${DISC}" == "" ]] || ! echo "${DISC}" | grep -q '/dev/'; then DISC="$(${_LSBLK} PKNAME "$(findmnt -vno SOURCE "${DESTDIR}/boot")")" fi - if [[ "${DISC}" == "" ]]; then DISC="$(${_LSBLK} PKNAME "$(findmnt -vno SOURCE "${DESTDIR}/")")" fi - } check_gpt() { - GUID_DETECTED="" [[ "$(${_BLKID} -p -i -o value -s PTTYPE "${DISC}")" == "gpt" ]] && GUID_DETECTED="1" - if [[ "${GUID_DETECTED}" == "" ]]; then DIALOG --yesno "Setup detected no GUID (gpt) partition table on ${DISC}.\n\nDo you want to convert the existing MBR table in ${DISC} to a GUID (gpt) partition table?" 0 0 || return 1 sgdisk --mbrtogpt "${DISC}" > "${LOG}" && GUID_DETECTED="1" @@ -34,13 +29,11 @@ check_gpt() { GUID_DETECTED="1" fi fi - if [[ "${GUID_DETECTED}" == "1" ]]; then ### This check is not enabled in any function yet! if [[ "${CHECK_UEFISYS_PART}" == "1" ]]; then check_efisys_part fi - if [[ "${CHECK_BIOS_BOOT_GRUB}" == "1" ]]; then if ! sgdisk -p "${DISC}" | grep -q 'EF02'; then DIALOG --msgbox "Setup detected no BIOS BOOT PARTITION in ${DISC}. Please create a >=1 MB BIOS Boot partition for grub BIOS GPT support." 0 0 @@ -48,7 +41,6 @@ check_gpt() { fi fi fi - if [[ "${RUN_CFDISK}" == "1" ]]; then DIALOG --msgbox "Now you'll be put into cfdisk where you can partition your storage drive. You should make a swap partition and as many data partitions as you will need." 7 60 clear && cfdisk "${DISC}" @@ -59,9 +51,7 @@ check_gpt() { ## check and mount EFISYS partition at ${UEFISYS_MOUNTPOINT} check_efisys_part() { - detect_DISC - if [[ "$(${_BLKID} -p -i -o value -s PTTYPE "${DISC}")" != "gpt" ]]; then GUID_DETECTED="" DIALOG --defaultno --yesno "Setup detected no GUID (gpt) partition table on ${DISC}.\nUEFI boot requires ${DISC} to be partitioned as GPT.\n\nDo you want to convert the existing MBR table in ${DISC} to a GUID (gpt) partition table?" 0 0 || return 1 @@ -73,58 +63,46 @@ check_efisys_part() { return 1 fi fi - if ! sgdisk -p "${DISC}" | grep -q 'EF00'; then # Windows 10 recommends a minimum of 260MB Efi Systen Partition DIALOG --msgbox "Setup detected no EFI System partition in ${DISC}. You will now be put into cfdisk. Please create a >= 260 MB partition with cfdisk type EFI System .\nWhen prompted (later) to format as FAT32, say YES.\nIf you already have a >=260 MB FAT32 EFI System partition, check whether that partition has EFI System cfdisk type code." 0 0 clear && cfdisk "${DISC}" RUN_CFDISK="" fi - if sgdisk -p "${DISC}" | grep -q 'EF00'; then # check on unique PARTTYPE c12a7328-f81f-11d2-ba4b-00a0c93ec93b for EFI System Partition type UUID UEFISYS_PART="$(${_LSBLK} NAME,PARTTYPE "${DISC}" | grep 'c12a7328-f81f-11d2-ba4b-00a0c93ec93b' | cut -d " " -f1)" - if [[ "$(${_LSBLK} FSTYPE "${UEFISYS_PART}")" != "vfat" ]]; then ## Check whether EFISYS is FAT, otherwise inform the user and offer to format the partition as FAT32. DIALOG --defaultno --yesno "Detected EFI System partition ${UEFISYS_PART} does not appear to be FAT formatted. UEFI Specification requires EFI System partition to be FAT32 formatted. Do you want to format ${UEFISYS_PART} as FAT32?\nNote: Setup will proceed even if you select NO. Some systems like Apple Macs may work with Non-FAT EFI System partition. However the installed system is not in conformance with UEFI Spec., and MAY NOT boot properly." 0 0 && _FORMAT_UEFISYS_FAT32="1" fi - if [[ "$(${_LSBLK} FSTYPE "${UEFISYS_PART}")" == "vfat" ]] && [[ "$(${_BLKID} -p -i -o value -s VERSION "${UEFISYS_PART}")" != "FAT32" ]]; then ## Check whether EFISYS is FAT32 (specifically), otherwise warn the user about compatibility issues with UEFI Spec. DIALOG --defaultno --yesno "Detected EFI System partition ${UEFISYS_PART} does not appear to be FAT32 formatted. Do you want to format ${UEFISYS_PART} as FAT32?\nNote: Setup will proceed even if you select NO. Most systems will boot fine even with FAT16 or FAT12 EFI System partition, however some firmwares may refuse to boot with a non-FAT32 EFI System partition. It is recommended to use FAT32 for maximum compatibility with UEFI Spec." 0 0 && _FORMAT_UEFISYS_FAT32="1" fi - #autodetect efisys mountpoint, on fail ask for mountpoint UEFISYS_MOUNTPOINT="/$(basename "$(mount | grep "${UEFISYS_PART}" | cut -d " " -f 3)")" if [[ "${UEFISYS_MOUNTPOINT}" == "/" ]]; then DIALOG --inputbox "Enter the mountpoint of your EFI System partition (Default is /boot): " 0 0 "/boot" 2>"${ANSWER}" || return 1 UEFISYS_MOUNTPOINT="$(cat "${ANSWER}")" fi - umount "${DESTDIR}/${UEFISYS_MOUNTPOINT}" &> /dev/null umount "${UEFISYS_PART}" &> /dev/null - if [[ "${_FORMAT_UEFISYS_FAT32}" == "1" ]]; then mkfs.vfat -F32 -n "EFISYS" "${UEFISYS_PART}" fi - mkdir -p "${DESTDIR}/${UEFISYS_MOUNTPOINT}" - if [[ "$(${_LSBLK} FSTYPE "${UEFISYS_PART}")" == "vfat" ]]; then mount -o rw,flush -t vfat "${UEFISYS_PART}" "${DESTDIR}/${UEFISYS_MOUNTPOINT}" else DIALOG --msgbox "${UEFISYS_PART} is not formatted using FAT filesystem. Setup will go ahead but there might be issues using non-FAT FS for EFI System partition." 0 0 - mount -o rw "${UEFISYS_PART}" "${DESTDIR}/${UEFISYS_MOUNTPOINT}" fi - mkdir -p "${DESTDIR}/${UEFISYS_MOUNTPOINT}/EFI" || true else DIALOG --msgbox "Setup did not find any EFI System partition in ${DISC}. Please create >= 260 MB FAT32 partition with cfdisk type EFI System code and try again." 0 0 return 1 fi - } partition() {