Recreate EFI partition

Recently I installed Debian 12 in a machine with EndeavourOS and the efi partition was overwritten (due to my carelessness). The structure of the partition was

/boot/efi/
└── EFI/
   ├── boot/bootx64.efi
   └── EndeavourOS/grubx64.efi

By running the command
sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=EndeavourOS --force --recheck
I was able to recreate the EndeavourOS/grubx64.efi
But how to recreate the boot/bootx64.efi ?

you could add --removable to the grub-install command if you want

sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --removable --recheck

Tip: If you use the option --removable then GRUB will be installed to esp/EFI/BOOT/BOOTX64.EFI (or esp/EFI/BOOT/BOOTIA32.EFI for the i386-efi target) and you will have the additional ability of being able to boot from the drive in case EFI variables are reset or you move the drive to another computer. Usually you can do this by selecting the drive itself similar to how you would using BIOS. If dual booting with Windows, be aware Windows usually places an EFI executable there, but its only purpose is to recreate the UEFI boot entry for Windows. If you are installing GRUB on a Mac, you will have to use this option. If you execute a BIOS update, this update might delete the existing UEFI boot entries. Therefore, it is a potential fallback strategy to have the “removable” boot entry enabled.

source: https://wiki.archlinux.org/title/Grub

2 Likes

Thanks : )
Two small queries -

  1. How does calamares do this during install? Couldn’t find the option “–removable” in UEFI grub install in /usr/lib/calamares/modules/bootloader/main.py
  2. boot/bottx64.efi and EndeavourOS/grubx64.efi are exactly same in size? so are they the same with different names? if yes, then will copying one to the other work?

I am not familiar with all the Calamares’ ins and outs but I did take a quick look and found this:

Perhaps @dalto could shed some more light on this?

I guess you could do this as long as you rename the file and use the correct alternative boot path. However for it be “bootable”, I think you would need to write the boot entry to NVRAM manually using efibootmgr.

1 Like

Thanks a lot

1 Like

But this way you wouldn’t get EndeavourOS/grubx64.efi.

I mean, you have to run both commands if you want both files.

1 Like

OP had already done:

1 Like

IIRC, it doesn’t do that by using grub: the installer “manually” copies that file

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.