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?

  • I think that happens automatically. UEFI looks for the EFI files, while BIOS boot will look for the legacy files. – TheWanderer Aug 22 '15 at 23:08
  • So I could simply have a single partition that contains /EFI and /boot, and it would work automatically with grub on a "legacy" BIOS, whereas [U]EFI would boot from the correct EFI path, because EFI specs require that it read MBR partitions anyway? – taz Aug 23 '15 at 0:02
  • Yep. It might boot legacy, but it should still manage EFI fine. – TheWanderer Aug 23 '15 at 0:24
  • @taz it very much depends on the firmware; but I have a USB pendrive with a similar setup, and it works on several computers; just mine is not a liveCD, not even Linux not GRUB. – AntoineL Aug 28 '15 at 10:41

As you request a clear illustration of how to do it, here it is. I assume you have your live Linux booted.

  1. Partition the USB thumb drive

    I recommend the command line tool gdisk. It produces very clean results. Alternatively, you can use gparted.

    1. Create a new partiton table. Use GPT with a protective MBR.

    2. Define these partitions:

      • (optional) A data partition
      • A Linux partition
      • A legacy BIOS boot partition (1MB is enough)
      • A EFI System partition (at least 32MB)
    3. Example: On my 64GB thumb drive, the result looks like this:

      Number  Start (sector)    End (sector)  Size       Code  Name
         1            2048       107632639   51.3 GiB    0700  DATA
         2       107632640       124411903   8.0 GiB     8300  Linux filesystem
         3       124411904       124413951   1024.0 KiB  EF02  BIOS boot partition
         4       124413952       124822453   199.5 MiB   EF00  EFI System
  2. 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.

  3. Install GRUB twice

    In a final step, install GRUB for both boot methods, UEFI style booting and legacy BIOS booting.

    grub-install --target=x86_64-efi --removable /dev/sdx
    grub-install --target=i386-pc /dev/sdx

    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 for grub-install. Only then grub-install finds all necessary directories.


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.

  • Thanks for the guide! It's actually really helpful (haven't tested it yet though). I do, however have a problem installing the efi version of grub, since I'm on a bios-only machine. I get this message: grub-install: error: /usr/lib/grub/x86_64-efi/modinfo.sh doesn't exist. Please specify --target or --directory.. Is there any way to force it to install it without having to boot via efi? – starbeamrainbowlabs May 22 '16 at 15:15
  • Yes, it is possible. The error message indicates, the 64bit EFI variant of the grub installer is not present in your currently booted system. On ubuntu, you need to install grub-efi-amd64-bin. Furthermore, you can search the online package index about what installers are available at all. Experience may vary for other flavours of linux. – Hermann Jun 8 '16 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.