Creating a UEFI Rescue DVD

Developing a UEFI rescue DVD containing a set of useful UEFI-related utilities is a personal project that I work on from time to time. I own a number of laptops with UEFI firmware and have encountered a myriad of strange UEFI-related booting issues on these laptops over the last few years. In fairness, some of these issues were due to early versions of UEFI firmware but a lot are not.

Booting begins by reading the Boot Record of the IS0 filesystem. The Boot Record resides at sector 17 and points to a Boot Catalog which is stored in one or more blocks in ISO filesystem. The Boot Catalog lists the available Boot Images (Catalog Entries), one per supported platforms. These Boot Images are marked as one of: emulated floppy, emulated hard disk, or no-emulation. In the build script, I specify no-emulation with the -no-emul-boot option.

The “CD001” string of the Boot Record indicates that this image is an ISO 9660. The “EL TORITO SPECIFICATION” string identifies the image as one that is potentially bootable. The DWORD at offset 47 (0x0026) is an absolute pointer to the first sector of the Boot Catalog.

UEFI interprets a Boot Image with a Platform ID of 0xEF (see offset 0 above) as a FAT32 filesystem and uses a standardized filepath to find an executable to load. For URD, this is /EFI/BOOT/BOOTX64. I probably should add a Manufacturer ID at offset 0x03. The maximum length of such an ID is 18. Note the “55AA” signature (which same as last two bytes in a MBR) in the second line of the output. The following byte is the Boot Indicator and indicates that the entry is bootable (88 – bootable, O – non-bootable). Offset Boot Indicator + 1 is the Boot Media Type byte (0 – no emulation, 4 – hard disk, etc.). Offset Boot Indicator + 8 contains the Load RBA DWORD which is the start address of the virtual disk.

Here is a diagram of the relationship between the various sections:

Note that you cannot boot this DVD on a non-UEFI system. Why not, you might ask? The reason is simple; the DVD contains no Boot Image with a Platform ID of 0x00. For example, this is what dumpet outputs for a dual boot Microsoft Vista SP1 X64 DVD:

A Platform ID of 0x00 basically means a PC. The media load segment is 0000:7c00 which generally means a BIOS-based image. The load sectors are 4 which is always the case for a BIOS-based image. UEFI firmware must ignore catalog entries with a 0x00 Platform ID and read catalog entries with a 0xEF Platform ID.

Here is what Microsoft has to say about dual BIOS/UEFI boot media:

The following guidelines apply for installation media on x64 platforms:

– The default El Torito boot entry is a BIOS entry that includes the 80×86
Platform ID, which is defined as “0x00” in hexadecimal.

– The second El Torito boot entry is an EFI entry that includes the Platform
ID as “0xEF” in hexadecimal. The entry references a FAT partition that
contains the bootable EFI application at \EFI\BOOT\BOOTX64.EFI.

Firmware vendors must ensure that the following conditions exist:

– The BIOS ignores boot entries that do not have the 80×86 Platform ID, which
is defined as “0x00” in hexadecimal. Failure to ignore other boot entries
results in the display of a confusing boot menu to the end user.

– The BIOS boots based on the BIOS entry without prompt.

– The UEFI boot manager ignores boot entries that do not have the “0xEF”
Platform ID.

– The UEFI boot manager boots based on the EFI entry without prompt.

The information provided in this post should be enough to get to started on creating your own custom UEFI-bootable DVDs. Happy experimenting and a Happy New Year!

December 29th, 2014

2 comments to Creating a UEFI Rescue DVD

I am interested in the showedid.efi tool. I use an EDKII build environment, so it may not be trivial to build the sources on github, since they are build with gnu-efi. Is there the compiled version “showedid.efi” also available for download anywhere? This would be great!