From 7e30b06e931ff60513bea8a542438696cffc1217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Go=C5=82a=C5=9B?= Date: Fri, 25 Jul 2025 12:17:56 +0200 Subject: [PATCH 1/2] deploy-shell-efi.sh: Fix partition num breaking on nvme0n1p1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was just getting all digits from the disk name, so nvm0n1p1 resulted in part num `011` which was interpreted as partiion number 11 resulting in a broken boot entry in the UEFI boot manager. Now only the last sequence of digits is taken into account and returns `1` for both `sda1` and `nvme0n1p1` creating bootable UEFI Shell boot entries. Signed-off-by: Filip Gołaś --- uefi-shell/deploy-shell-efi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uefi-shell/deploy-shell-efi.sh b/uefi-shell/deploy-shell-efi.sh index 7dd22fc..c2beea0 100755 --- a/uefi-shell/deploy-shell-efi.sh +++ b/uefi-shell/deploy-shell-efi.sh @@ -36,7 +36,7 @@ cp "$SHELL_EFI_SRC" "$DEST_EFI" PART_DEV=$(findmnt -no SOURCE "$ESP") DISK=$(lsblk -no PKNAME "$PART_DEV" | head -n1) -PART_NUM=$(echo "$PART_DEV" | sed 's/[^0-9]*//g') +PART_NUM=$(echo "$PART_DEV" | sed -E 's/.*[^0-9]([0-9]+)$/\1/') DISK_DEV="/dev/$DISK" echo "Registering UEFI boot entry..." From 28ed1aba95b35cdd943ab23fd75167a742490e87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Go=C5=82a=C5=9B?= Date: Fri, 25 Jul 2025 15:51:08 +0200 Subject: [PATCH 2/2] deploy-shell-efi.sh: Prevent duplicated entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Filip Gołaś --- uefi-shell/deploy-shell-efi.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/uefi-shell/deploy-shell-efi.sh b/uefi-shell/deploy-shell-efi.sh index c2beea0..b1c2aab 100755 --- a/uefi-shell/deploy-shell-efi.sh +++ b/uefi-shell/deploy-shell-efi.sh @@ -38,8 +38,20 @@ PART_DEV=$(findmnt -no SOURCE "$ESP") DISK=$(lsblk -no PKNAME "$PART_DEV" | head -n1) PART_NUM=$(echo "$PART_DEV" | sed -E 's/.*[^0-9]([0-9]+)$/\1/') DISK_DEV="/dev/$DISK" +LABEL="UEFI Shell" -echo "Registering UEFI boot entry..." +# Remove existing UEFI Shell entries +efibootmgr | grep "$LABEL" | while IFS= read -r line; do + # Extract the boot number Boot0003 -> 0003 + bootnum=$(echo "$line" | grep -oP 'Boot\K[0-9A-Fa-f]{4}') + # If nonzero + if [[ -n "$bootnum" ]]; then + echo Removing UEFI Shell at $bootnum + sudo efibootmgr -b "$bootnum" -B &> /dev/null + fi +done + +echo "Registering UEFI boot entry at $DISK_DEV part $PART_NUM" efibootmgr --create --disk "$DISK_DEV" --part "$PART_NUM" \ --label "UEFI Shell" --loader '\EFI\Shell\Shell.efi'