I have a laptop running stock UEFI and Windows 8.1. I want to create a bootable live linux USB stick that can be used to boot either my older BIOS system or my newer UEFI system. I am ok with having two separate copies of the live distro on different partitions of the USB stick if need be. What are the steps to accomplish this?
I have read other posts that seem to indicate this is possible but none of them clearly illustrate how to do it:
How to create hybrid MBR/GPT partition on USB drive?
Is a hybrid Linux USB-Stick for UEFI & legacy BIOS possible?
Best Answer
As you request a clear illustration of how to do it, here it is. I assume you have your live Linux booted.
Partition the USB thumb drive
I recommend the command line tool
gdisk
. It produces very clean results. Alternatively, you can usegparted
.Create a new partiton table. Use GPT with a protective MBR.
Define these partitions:
Example: On my 64GB thumb drive, the result looks like this:
Install Linux to the USB thumb drive using any method.
During the process, format the Linux partition with a filesystem of your choice, preferably
ext4
. Use this partition as root/
.Format the EFI System partition with FAT16.
The BIOS boot partition remains unformatted.
Install GRUB twice
In a final step, install GRUB for both boot methods, UEFI style booting and legacy BIOS booting.
Where
/dev/sdx
is your USB thumb drive, obviously.That
--removable
is important. Took me three hours to realize I need it on a removable USB thumb drive...If you install GRUB to the thumb drive from the "outside" (not having booted the Linux from the USB thumb drive), you need to mount the Linux partition first. Maybe you mount it into
/mnt
. Then you mount the EFI System partition into the Linux partitions/mnt/boot/efi
directory. Use--root=/mnt
as parameter forgrub-install
. Only thengrub-install
finds all necessary directories.Done.
For further reading:
We did not really define partitions in the MBR. So you may ask, why it does work on legacy BIOS machines. Keep in mind, we installed GRUB into the MBR. During the legacy BIOS boot process, the bootloader stored in the MBR is executed. This loads stage 1 of GRUB, which then proceeds to load stage 2 from the legacy BIOS boot partition. But at this time, GRUB does not actually know anything about partitions MBR or otherwise. For this reason, the information about the position of the BIOS boot partition has been embedded into GRUB stage 1. Consequently, if the BIOS boot partition is moved, you need to reinstall GRUB. After GRUB stage 2 is loaded, GRUB understands GPT and can continue with booting the Linux kernel.