0

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.

Hannes
  • 157
  • 8

1 Answers1

0

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.

user10489
  • 474
  • 1
  • 2
  • 12
  • root partition is ext4, so separate partition is needed. I don't install the entry with efibootmgr. I use efibootmgr to remove the entry. grub automatically installs the entry when I seletected the thumb drive from UEFI bootmanager. That is the step "Boot option restauration" – Hannes Apr 02 '22 at 21:55
  • Grub doesn't automatically add an entry unless it doesn't realize this is a temporary usb, but if you mean the bios UEFI manager, ilt detects what it sees... – user10489 Apr 02 '22 at 22:07
  • When grub was installed without --removable system didn't boot when selecting usb thumbdrive from uefi boot manager. After adding this option a blue screen appears "Boot option restauration" which you can cancel within a few seconds, so I guess grub restores the uefi entry. Wen booting that system from acronis media or ubuntu live also no entry remains in uefi. So it is more likely that this is grub. – Hannes Apr 03 '22 at 07:11