I've noted that the Ubuntu ISO file is bootable on systems with BIOS and with UEFI. I've remastered Ubuntu from scratch and I'd like my ISO file to be bootable in both cases.

My remastering of Ubuntu is done by first installing debootstrap into a chroot jail, and then gradually adding files until I have all desired programs. However, the resulting ISO file is only bootable on a system with BIOS.

I believe I need some different magic with mkisofs, but what about the files in EFI/BOOT? What is the origin of those files? Is there anything else I need?



  • 1
    The ISO has a pre-configured grub renamed to /EFI/Boot/bootx64.efi. UEFI only boots from /EFI/Boot/bootx64.efi. So BIOS boot is from syslinux and UEFI boot is from grub. The version of grub in the ISO is uses just the files needed to boot the installer, not the full install of grub in a standard install.See long answer, not script: askubuntu.com/questions/549647/…
    – oldfred
    Nov 11, 2017 at 21:08
  • Create one partition with type EFI System and do as @oldfred suggested Nov 11, 2017 at 22:11
  • That reply talks about preparing a boot medium with partitions and such, whereas I'm trying to create the ISO file that others can easily boot via BIOS or UEFI. If I take the Ubuntu ISO file and mount it read-only/loopback, I see EFI/BOOT with two files in it: BOOTx64.EFI and grubx64.efi. Specifically, how are those files created?
    – AndyS
    Nov 12, 2017 at 0:27
  • I see in oldfred's reference that there are clear instructions for creating bootx64.efi, but is that the same as BOOTx64.EFI? I see also an example of grub.cfg, but on the Ubuntu ISO, I see two grub.cfg files at these locations: /boot/grub/x86_64-efi/grub.cfg and /boot/grub/grub.cfg. My guess is that two files are needed, one for BIOS and the other for EFI boot.
    – AndyS
    Nov 12, 2017 at 0:31
  • The grub.cfg file from oldfred's link references vmlinuz.efi. How is that file created?
    – AndyS
    Nov 12, 2017 at 0:33

1 Answer 1


You can generate an ESP (EFI System Partition) image suitable for booting on UEFI with:

#! /bin/sh

BOOT_IMG_DATA=$(mktemp -d)

mkdir -p $(dirname $BOOT_IMG)

truncate -s 4M $BOOT_IMG
mkfs.vfat $BOOT_IMG
mkdir -p $BOOT_IMG_DATA/efi/boot

grub-mkimage \
    -C xz \
    -O x86_64-efi \
    -p /boot/grub \
    -o $BOOT_IMG_DATA/efi/boot/bootx64.efi \
    boot linux search normal configfile \
    part_gpt btrfs fat iso9660 loopback \
    test keystatus gfxmenu regexp probe \
    efi_gop efi_uga all_video gfxterm font \
    echo read ls cat png jpeg halt reboot

mcopy -i $BOOT_IMG -s $BOOT_IMG_DATA/efi ::

That will generate a FAT-formatted file (change the location of the file by changing the $BOOT_IMG variable), which is, in turn, an ESP image.

You can use the generated image by adding the flag -append_partition 2 0xef efi.img to the xorriso command.

The resulting xorriso command may be something like this:

xorriso -as mkisofs \
    -r -V <ISO_LABEL> \
    -J -J -joliet-long -cache-inodes \
    -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
    -b isolinux/isolinux.bin \
    -c isolinux/boot.cat \
    -boot-load-size 4 -boot-info-table -no-emul-boot \
    -eltorito-alt-boot \
    -e --interval:appended_partition_2:all:: \
    -append_partition 2 0xef efi.img \
    -no-emul-boot -isohybrid-gpt-basdat \

Bear in mind that you also need to use ISOLINUX if you want your image to boot on BIOS systems. GRUB2 is for UEFI.

Also, you should use a recent version of xorriso (the flag --interval:appended_partition_2:all:: was added a couple years ago, so old versions doesn't support it).

For further guidance, also take a look to this question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.