User:Pjones/BootableCDsForBIOSAndUEFI

From FedoraProject

< User:Pjones
Revision as of 20:10, 20 August 2010 by Pjones (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Bootable CDs

In some cases, we want CDs to be bootable by both tradition BIOS and UEFI on the same systems. This means we need to do some special things to the disk.

The primary difference here is how the disc is created with mkisofs

Old BIOS way

With normal BIOS, the way to do this is something like:

mkisofs -U -A "MyLinux_1 x86_64" -V "MyLinux_1 x86_64 Disc 1" \
    -volset "MyLinux_1 x86_64" -J -joliet-long -r -v -T -x ./lost+found \
    -o /home/pjones/MyLinux/1/x86_64/iso/MyLinux-1-x86_64-disc1-dualboot.iso \
    -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
    -boot-info-table .

There are sections here, and to understand what changes are necessary for UEFI boot support, they must be identified. The first section is about the entire volume:

mkisofs -U -A "MyLinux_1 x86_64" -V "MyLinux_1 x86_64 Disc 1" \
    -volset "MyLinux_1 x86_64" -J -joliet-long -r -v -T -x ./lost+found \
    -o /home/pjones/MyLinux/1/x86_64/iso/MyLinux-1-x86_64-disc1.iso

This specifies global format options, such as the use of the joliet long filename format, and also the output image. The second section specifies information about how to create the El Torito boot image:

-b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot \
    -boot-load-size 4 -boot-info-table

The last section specifies the tree to find the files for the image:

.

New UEFI/BIOS hybrid method

To make a disk also EFI bootable, it needs an EFI bootable image, such as efiboot.img in our trees, and that needs to be inserted as a second El Torito boot image. To do this, we insert a 4th section between the El Torito section and the section about our tree, which looks like this:

-eltorito-alt-boot -e images/efiboot.img -no-emul-boot

Thus making the full command line look like:

mkisofs -U -A "MyLinux_1 x86_64" -V "MyLinux_1 x86_64 Disc 1" \
    -volset "MyLinux_1 x86_64" -J -joliet-long -r -v -T -x ./lost+found \
    -o /home/pjones/MyLinux/1/x86_64/iso/MyLinux_1-x86_64-disc1-dualboot.iso \
    -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
    -boot-info-table -eltorito-alt-boot -e images/efiboot.img -no-emul-boot .

Testing the image

The first thing to do to test images is a simple smoke-test using the "dumpet" tool. Here's what it looks like with a traditional ISO image:

pjones4:/home/pjones/MyLinux/1/x86_64/iso$ dumpet -i MyLinux_1-x86_64-disc1-ftp.iso
Validation Entry:
	Header Indicator: 0x01 (Validation Entry)
	PlatformId: 0x00 (80x86)
	ID: ""
	Checksum: 0x55aa
	Key bytes: 0x55aa
Boot Catalog Default Entry:
	Entry is bootable
	Boot Media emulation type: no emulation
	Media load segment: 0x0 (0000:7c00)
	System type: 0 (0x00)
	Load Sectors: 4 (0x0004)
	Load LBA: 154 (0x0000009a)

There are some important considerations, including:

  • The PlatformId is 0x0 (which means "PC")
  • The Boot Catalog Default Entry is bootable, with no emulation
  • Media load segment is 0000:7c00 - this will always be true for a BIOS image in Fedora
    • dumpet 1.1 incorrectly said 0x7c0 here.
  • Load sectors is "4" - this will always be true for a BIOS image

On a UEFI/BIOS hybrid image, the output will look like this:

pjones4:/home/pjones/MyLinux/1/x86_64/iso$ dumpet -i MyLinux_1-x86_64-disc1-dualboot.iso 
Validation Entry:
	Header Indicator: 0x01 (Validation Entry)
	PlatformId: 0x00 (80x86)
	ID: ""
	Checksum: 0x55aa
	Key bytes: 0x55aa
Boot Catalog Default Entry:
	Entry is bootable
	Boot Media emulation type: no emulation
	Media load segment: 0x0 (0000:7c00)
	System type: 0 (0x00)
	Load Sectors: 4 (0x0004)
	Load LBA: 348 (0x0000015c)
Section Header Entry:
	Header Indicator: 0x91 (Final Section Header Entry)
	PlatformId: 0xef (EFI)
	Section Entries: 1
	ID: ""
Boot Catalog Section Entry:
	Entry is bootable
	Boot Media emulation type: no emulation
	Media load address: 0 (0x0000)
	System type: 0 (0x00)
	Load Sectors: 776 (0x0308)
	Load LBA: 154 (0x0000009a)

The BIOS entry looks the same, except for the Load LBA (the address of the image on the disc), but there's also another Section Header Entry and Boot Catalog Section Entry, which specify the UEFI boot image. The important aspects of this are:

  • PlatformId is 0xef (EFI)
  • The Boot Catalog Section Entry is bootable, with no emulation
  • Media load address is 0
  • "Load Sectors" is NOT 4. Load Sectors * 2048 should be the size of efiboot.img rounded up to a multiple of 2048

If all these things are correct, an EFI system should see the efiboot.img, and if it is formed correctly, then you've got bootable media on a UEFI machine and BIOS machines.