How to make bootable Debian usb drive that works on both BIOS and UEFI systems?

Solution 1:

If you're talking about creating a Debian installation image, I can't provide step-by-step instructions for it; however, the general way to create a USB drive that's bootable in both EFI and Linux is:

  1. Prepare the disk with partitions. GPT is probably most reliable for this, but MBR will work on at least some systems, too. Be sure to include an EFI System Partition (ESP) and (if you use GRUB 2) a BIOS Boot Partition.
  2. Install 64-bit Linux to the USB drive. (A 32-bit Linux will boot in EFI mode only on those rare 32-bit EFI-based PCs or with the help of a 64-bit EFI boot loader. These days, you're probably best off with a 64-bit Linux.)
  3. Install a BIOS-mode boot loader (probably GRUB 2, but GRUB Legacy patched with GPT support, SYSLINUX, or LILO will work, too).
  4. Install an EFI-mode boot loader/manager (GRUB 2, Fedora's patched GRUB Legacy, recent SYSLINUX, rEFInd, or gummiboot) in the ESP as EFI/BOOT/bootx64.efi.

The Debian installer, of course, has things set up in its own way, so step #2 will involve figuring out how the installer works and "translating" it to work from the USB flash drive.

Solution 2:

I would think that Debian and Ubuntu are technically close enough so that this method for Ubuntu may work also for Debian: https://help.ubuntu.com/community/Installation/UEFI-and-BIOS

EDIT: You need to first decide which flavor you want: 32-bit or 64-bit. Most people will want to go with 64-bit i.e. amd64. Then create a partition table with parted as follows: ~1MB for bios_grub, ~256MB (or 512MB, it is really up to you to decide) for the EFI System Partition (ESP). Then create your Linux partitions for / and your swap, additional partitions and possible use of LVM is entirely up to you.

Number  Start   End     Size    File system     Name  Flags
 1      1049kB  2097kB  1049kB                        bios_grub
 2      2097kB  264MB   262MB   fat32                 boot
 3      264MB   7434MB  7170MB  ext4
 4      7434MB  7799MB  365MB   linux-swap(v1)

Then install Debian, preferably in UEFI mode. After configuring the bootloader (which will be installed to the ESP) reboot again with the Debian installation media, but this time in BIOS mode. Try to install GRUB to the bios_grub partition. On Ubuntu 12.04 LTS you could use boot-repair which is only available from an external repository (once in UEFI mode, once in BIOS mode), but I don't know if this is also available on Debian. Run it both times with recommended repair settings.

On Debian you will probably have to install GRUB by hand, manually, and make sure it is installed once as UEFI bootloader on the ESP and once as BIOS boot sector on the bios_grub partition.

Be aware that automatic kernel updates will only be updated on the system that is currently running, i.e. either BIOS or UEFI, and depending on your current configuration. THIS IS NOT AUTOMATIC.

There are a couple of other possibilities described in the linked source, and sources linked from there. It is also different for an installed Debian vs. the installer for Debian to be multi-system (UEFI+BIOS). Additionally, in UEFI mode you have to take some thought if you want it to be able to use Secure Boot or not.