[Nottingham] How to create a UEFI bootable USB stick?

Duncan notlug at pendinas.org.uk
Mon Apr 28 13:10:09 UTC 2014

On 28/04/14 12:43, Jason Irwin wrote:
> I'm using a BIOS laptop and I need to create a UEFI bootable USB stick. So
> far every single tool I have tried only creates a BIOS-bootable stick.
> Every guide I have found only deals with a UEFI HDD install (I haven't got
> that far yet).
> From what I can tell, GRUB won't create a UEFI bootable stick unless run
> from UEFI hardware (chicken/egg).
> Does anyone know of a way to create a USB stick that can boot on a UEFI
> lappy?

Yes,  done it and still have the USB stick lying around to prove it :)

But now you ask, I'll need to remember how I did it...

I wanted to purge my Dell XPS-13 developer edition of ubuntu and replace
it with Debian. I started creating a "system on a USB stick" so I could
test the laptop before going ahead with the purge.

The debian (testing) installer can boot UEFI from a USB stick and install
a UEFI system[1]. You need 2 USB sticks - one with a debian install image (D-USB)
on it (I think I used the testing netboot image) and the other the target for the
installation (T-USB)

With my laptop (Dell XPS-13 developer edition) I:
	1. Plugged in D-USB and T-USB
	2. Booted and select the laptop "boot options" key (F10).
	This gave me a list of
		legacy boot from ...
		UEFI boot from ....

	3. Select the UEFI D-USB entry.

	4. Told the debian installer to install to T-USB

	5. Partitioned T-UDB for UEFI boot and install

	6. After the install, because T-USB was UEFI and the laptop was in the default
	non-UEFI boot mode I had to boot T-USB using the same F10, choose the right one
	method as needed to bot D-USB in the first place.

	7. Once satisfied that Debian could take command of the machine I installed it
	on the HDD in the same way.  Once working on the HDD via F10 boot I used the F10
	"change the default boot" option to set the default boot method to UEFI. Now the
	HDD boots hitting F10 during boot.
Extra Notes:
1. I  didn't have windows to worry about and I use grub as the boot loader.

2. You need a single EFI partition which on Linux+grub must be mounted as /boot/efi.
The partition needs to be of type EF00 (gdisk option 't') and formatted as
VFAT (mkfs.vfat -F 32 ...):

$ gdisk -l /dev/sda
GPT fdisk (gdisk) version 0.8.8

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 500118192 sectors, 238.5 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 5BDA1EDB-4FC0-4AB1-A71F-852E6E2747BD
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 500118158
Partitions will be aligned on 2048-sector boundaries
Total free space is 4717 sectors (2.3 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          718847   350.0 MiB   8300  Linux filesystem
   2          718848         1767423   512.0 MiB   EF00  EFI SYSTEM PARTITION
   3         1767424         5672959   1.9 GiB     8300
   5         5672960       500115455   235.8 GiB   8300

3. Note the last usable sector is 500118158 but the last used sector 500115455.  This leaves
enough space at the end of the disk for the backup GPT partition table.

4. I have separate /boot (sda3) and /boot/efi (sda2) partitions so I can run a luks encrypted root.
(sda5 == encrypted LVM containing root, swap etc which means I only have one passphrase for the whole
LVM partition rather than one for each of root, swap etc).

5. sda4 is absent because it was a late night and I had lost the ability to count beyond 3.

[1] Worked for me but I understand it doesn't work for everyone.



More information about the Nottingham mailing list