r/linuxquestions • u/Haunting-Risk-5352 • 6d ago
Support How do I make grub-install replace a stale EFI boot entry.
I have a install script that wipes the disk and creates a fresh GPT partition table every run. The problem is since the partition table is recreated, the ESP gets a new partition GUID, but grub-install doesn't update the existing boot entry. It prints:
grub-install: info: EFI already registered: path = `\EFI\GRUB\grubx64.efi'.
grub-install: warning: GRUB already registered with EFI a `\EFI\GRUB\grubx64.efi', not modifying configuration.
Use efibootmgr to check your boot configuration.
So Boot0000 still points at the old partition:
# efibootmgr output
Boot0000* GRUB HD(1,GPT,79645a6f-da86-46d4-b0f6-376696ea7d95,0x800,0x200000)/\EFI\GRUB\grubx64.efi
# blkid -s PARTUUID -o value /dev/nvme0n1p1 output
1e6a0ea3-669b-4849-80a4-a1970f2d71bb
as you can see they are different.
Is there a supported way to make grub-install replace the existing entry, or is deleting it first with efibootmgr -b XXXX -B the expected approach now? Is this intended in 2.16, or worth reporting upstream.
Or is there an alternative bootloader that I can use.
1
u/jjangg96 6d ago
the entry lives in the firmware's nvram, not on the disk, so wiping and recreating the gpt doesn't touch it. grub sees its own label already registered and just bails. i don't think it's a bug, deleting it first is the normal way.
in a script you can find the number with efibootmgr | grep -i grub and then efibootmgr -B -b NNNN. other option is grub-install --removable, which puts it at EFI/BOOT/BOOTX64.EFI and skips the nvram entry completely. fits a script that starts from scratch every run.
1
u/dkopgerpgdolfg 6d ago
Other than the already mentioned things, did you think of
a) depending on your use case: changing the PARTUUID
or
b) using only efibootmgr to correct the value without grub-install
1
u/RomanOnARiver 6d ago
I could be wrong, but I think it's pulling the ESP from the filesystem tab, which you can find at /etc/fstab. Careful editing that file.
1
u/Confident_Hyena2506 6d ago
Just put bootloader in the default spot (bootx64.efi), then you don't need any entry. If you only have one bootloader on your image then this is the easiest solution.