From 2a2ef9abd7ece89784d530dcb8506e267b10bf0a Mon Sep 17 00:00:00 2001 From: oddlama Date: Tue, 20 Dec 2022 13:07:17 +0100 Subject: [PATCH] fix: more robust way to extract efi partition and parent device (fixes #63) --- scripts/main.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/main.sh b/scripts/main.sh index 599eaab..f48c0d1 100644 --- a/scripts/main.sh +++ b/scripts/main.sh @@ -209,10 +209,16 @@ function install_kernel_efi() { || die "Could not resolve device with id=$DISK_ID_EFI" efipartdev="$(realpath "$efipartdev")" \ || die "Error in realpath '$efipartdev'" - local efipartnum="${efipartdev: -1}" + local efipartnum + efipartnum="$(cat "$efipartdev/partition")" \ + || die "Failed to find partition number for EFI partition $efipartdev" local gptdev - gptdev="$(resolve_device_by_id "${DISK_ID_PART_TO_GPT_ID[$DISK_ID_EFI]}")" \ - || die "Could not resolve device with id=${DISK_ID_PART_TO_GPT_ID[$DISK_ID_EFI]}" + gptdev="/dev/$(basename "$(readlink -f "$efipartdev/..")")" \ + || die "Failed to find parent device for EFI partition $efipartdev" + if [[ ! -e "$gptdev" ]] || [[ -z "$gptdev" ]]; then + gptdev="$(resolve_device_by_id "${DISK_ID_PART_TO_GPT_ID[$DISK_ID_EFI]}")" \ + || die "Could not resolve device with id=${DISK_ID_PART_TO_GPT_ID[$DISK_ID_EFI]}" + fi try efibootmgr --verbose --create --disk "$gptdev" --part "$efipartnum" --label "gentoo" --loader '\vmlinuz.efi' --unicode 'initrd=\initramfs.img'" $(get_cmdline)" # Create script to repeat adding efibootmgr entry