Score:0

How to make grub for fully portable linux on usb thumbdrive without writing entry to systems EFI?

in flag

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.

Score:0
nc flag

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.

in flag
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"
user10489 avatar
nc flag
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...
in flag
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.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.