Merge pull request #13 from Dasharo/fix-installing-uefi-shell-on-nvme

deploy-shell-efi.sh: Fix partition num breaking when /boot/efi on nvme0n1p1
This commit is contained in:
Filip Gołaś
2025-07-30 07:30:37 +02:00
committed by GitHub
+14 -2
View File
@@ -36,10 +36,22 @@ 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"
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'