Ubuntu – Install Ubuntu to usb drive and boot it to Uefi and Bios system.

biosbootloadergrub2uefiusb-drive

So I'm totally new to linux. I don't want to install to my internal HDD. So I've been trying to install it independently on a usb so i can boot it on any pc (UEFI or BIOS).

So i created a live usb and formatted another usb where i want to put linux on. I go on the live linux, install linux to the empty usb and choose bootloader to install on my Usb. But when it's finished installing, i see grub traces on my internal hdd by efi partitions and stuff.

And i can't boot my usb to boot linux on a different pc.

I've been searching on google for two days straight!! I've seen quite some people asking this but i didn't understand the answer since I'm a beginner. I don't understand so much of linux at all so please answer detailed.

Best Answer

The Ubuntu install process (not grub-installer itself, which will write to a target) writes to the sda's EFI partition regardless of what you tell it. There have been several bugs filed on this, with other potentially worse issues like having the machine's native boot entry changed. See bugs 1173457, 1229488, ... and many more if you search. Add yourself to any bugs you feel affect you.

The solution is simple, just mount the USB's EFI partition and copy everything from the hard disk's EFI partition. Then, copy the Ubuntu bootloaders shimx64.efi and grubx64.efi from .../EFI/ubuntu to .../EFI/Boot/ and rename the .../EFI/.Boot/ shimx64.efi to bootx64.efi. That's the bootloader used for removable media. It still requires the grub.cfg file be in EFI/ubuntu, so leave it there. Remember, these are all just files on a FAT filesystem. You can copy and rename them from the Windows filemanager just as easily as from a Linux system.

Do back up your hard disk's EFI partition, using USB installs may change things. Know what the boot order is, since even that may be changed after a USB install.

Related Question