I've installed Debian Bullseye on a usb thumbdrive. When I plug the thumbdrive notebook bootet from it, because there was an entry in UEFI "debian".
After removing it with sudo efibootmgr -b <boot entry number> -B
thumbdrive didn't boot anymore after selecting it from UEFI bootmanager. It wasn't bootable anymore because UEFI used then default Windows Bootmanager boot entry.
After that I've used a Ubuntu Live system and issued
sudo mount /dev/sdXY /mnt
sudo mount /dev/sdXX /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo chroot /mnt
grub-install --no-nvram --removable /dev/sdX
update-grub
like described here https://askubuntu.com/a/831241 and adding options --no-nvram --removable
, see https://www.systutorials.com/docs/linux/man/8-grub-install/ .
When selecting thumb drive now from EFI bootmanager it boots, but a message is displayed, "Boot option restauration", which can be canceled within about 6 seconds. After that system reboots and then grub is loaded and system boots. However now there is again debian
in the UEFI system.
Using --no-nvram
or not, makes no difference. To boot from this thumb drive there is an entry in the UEFI.
How can this be prevented? When booting from Acronis Media or the Ubuntu Live media from usb thumbdrive it boots without modifying UEFI boot entry table of system. So this should be possible.
Update: You can press any key and then select to continue boot without resetting the system and to always continue boot. Then "Boot option restauration" windows isn't shown anymore, instead grub is shown immediate, but still OS is written to UEFI boot order.
If your USB is formated as fat (or vfat), you just need an /EFI directory on it and install grub there. It doesn't need a separate EFI partition unless it's not fat format.
The bios doesn't need to know about that EFI entry so you don't need to install it with efibootmgr. However, you might need to tell your bios to boot the USB, either manually (by selecting it on each boot from the manual boot menu) or by putting the USB in the boot order.