From dfce36e61a0fead24e3a0ea78065d9f221befc03 Mon Sep 17 00:00:00 2001 From: Peter Ajamian Date: Sun, 27 Jun 2021 21:53:34 +1200 Subject: [PATCH] efibootmgr needs separate disk and partition (#52) * efibootmgr needs separate disk and partition efibootmgr needs a separate device (/dev/xxx) and partition number. Co-authored-by: McNutnut --- migrate2rocky/migrate2rocky.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/migrate2rocky/migrate2rocky.sh b/migrate2rocky/migrate2rocky.sh index 4feab1a..d06ac3e 100644 --- a/migrate2rocky/migrate2rocky.sh +++ b/migrate2rocky/migrate2rocky.sh @@ -215,7 +215,7 @@ bin_check() { curl sha512sum mktemp ) if [[ $update_efi ]]; then - bins+=(findmnt grub2-mkconfig efibootmgr grep mokutil) + bins+=(findmnt grub2-mkconfig efibootmgr grep mokutil lsblk) fi for bin in "${bins[@]}"; do if ! type "$bin" >/dev/null 2>&1; then @@ -351,10 +351,13 @@ collect_system_info () { # Check the efi mount first, so we can bail before wasting time on all these # other checks if it's not there. if [[ $update_efi ]]; then - declare -g efi_mount + local efi_mount + declare -g efi_disk efi_partition efi_mount=$(findmnt --mountpoint /boot/efi --output SOURCE \ --noheadings) || exit_message "Can't find EFI mount. No EFI boot detected." + efi_disk=/dev/$(lsblk -no pkname "$efi_mount") + efi_partition=$(<"/sys/block/${efi_disk##*/}/${efi_mount##*/}/partition") fi # check if EFI secure boot is enabled @@ -773,7 +776,8 @@ efi_check () { fix_efi () ( grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg || exit_message "Error updating the grub config." - efibootmgr -c -d "$efi_mount" -L "Rocky Linux" -l /EFI/rocky/grubx64.efi || + efibootmgr -c -d "$efi_disk" -p "$efi_partition" -L "Rocky Linux" \ + -l /EFI/rocky/grubx64.efi || exit_message "Error updating uEFI firmware." )