Why can the custom-build iso not boot in EFI

bootmkisofsuefi

I am building a custom iso using xorriso in mkisofs mode. The build seems correct, inspecting the iso afterwards shows 2 boot images (1 BIOS, 2 UEFI), yet booting to the ISO from qemu using the OVMF firmware fails to find any bootable media.

If I try the exact same boot in qemu but using a clean downloaded ubuntu 16.04 server iso, it boots without a problem.

If I use BIOS (not UEFI), both boot just fine.

xorriso command:

xorriso -as mkisofs \
   -l -J -R -V version \
   -no-emul-boot -boot-load-size 4 -boot-info-table \
   -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat \
   -isohybrid-mbr isohhdpfx.bin \
   -eltorito-alt-boot -e EFI/BOOT/BOOTX64.EFI -no-emul-boot \
   -isohybrid-gpt-basdat \
   -o testos.iso ./cddir/

The details of examining the 2 iso (ubuntu and my custom built one) with xorriso -report_el_torito plain and cmd are in the following gist https://gist.github.com/deitch/e069268f92402d6a2b1c7e060ddba622

Best Answer

Thank you for flying xorriso.

The problem is in the image file which you let xorriso mark as EFI System Partition. It is supposed to be a FAT filesystem image which contains a binary file named /EFI/BOOT/BOOTX64.EFI (or .../BOOTIA32.EFI for 32 bit x86) plus possibly other files. Mount the file /boot/grub/efi.img from the Ubuntu ISO for learning about its content.

The FAT filesystems used by Ubuntu and others are probably produced by GRUB2 program grub-mkimage. ISOLINUX/SYSLINUX EFI software cannot be used because it bails out when seeing a CD-ROM device.

A quite convenient way to get a bootable ISO is program grub-mkrescue. If GRUB2 is configured for BIOS and EFI (e.g. by installing binary packages grub-pc, grub-efi-amd64, and grub-efi-ia32) then grub-mkrescue will produce an ISO which boots on BIOS and EFI of 32 bit and 64 bit x86 machines: El Torito boot images for BIOS and EFI, EFI image having BOOTX64.EFI and BOOTIA32.EFI, MBR for BIOS from hard disk, GPT for EFI from hard disk.

Related Question