customizer icon indicating copy to clipboard operation
customizer copied to clipboard

Booting EFI from ISO written to USB

Open willprice opened this issue 4 years ago • 4 comments

Once I've written my generated ISO to a USB stick using dd if=Ubuntu-amd64-18.04.iso of=/dev/sdX bs=1M I am able to successfully boot in BIOS mode, however in EFI mode the USB stick does not show up. Looking at the usb key under parted I can't see a partition table. I am under the impression EFI needs a FAT32 partition with the ESP type set and to be marked as bootable.

Does customizer support EFI boot? If so, are there any guide on how to do this? If there aren't, if you can guide me through the process I'll happily write up instructions on the wiki

Thanks for you very useful program!

willprice avatar Aug 06 '19 10:08 willprice

I am under the impression EFI needs a FAT32 partition with the ESP type set and to be marked as bootable.

Incorrect -- a removable storage device will be checked for the /EFI/BOOT/ path, and if any signed EFI binaries are found, the firmware will present it as a bootable choice.

ESP is only for a non-removable device, and there should only be one in a system. Some firmwares rely on it's existence to store non-volatile configuration. Others are fairly indifferent to it's existence or nonexistence.

As far as I know, the images should be generated in isohybrid mode, which should have a valid MBR, but I just poked around with a hex editor and saw the isolinux signatures, so unfortunately, this may not always be the case.

My personal preference is to find a windows box, grab the official lubuntu 18.04.2 ISO, and use rufus to dump the ISO onto the stick in FAT32 mode.

https://rufus.ie

For whatever reason, rufus gets it more or less right when many other tools don't. Dunno why.

Rufus UI)

Once that's done, you can copy the /EFI/BOOT/ contents: BOOTx64.EFI and grubx64.efi (these are the secure boot signed files) elsewhere, or boot the image up and ask it to install the MBR copy of grub (which will share the grub.cfg between both EFI and "bios"/CSM boot methods)

Can also extract them other ways, or yank them right out of /home/customizer/ISO/ now that I think about it.

Anyway, as of more recently (2016), I've been keeping multiple ISOs on my boot stick using grub2's iso loopback tricks. https://github.com/kamilion/kamikazi-core/blob/master/buildscripts/xengrub.cfg At that point, I just delete everything else but /EFI, /boot/grub and the ISOs.

Lotta ways you can attack it, I suppose.

kamilion avatar Aug 07 '19 09:08 kamilion

I edited the /usr/share/customizer/actions/rebuild.py script where the ISO file is created to include the commands needed to make a uefi hybrid iso. In particular this is the line required. '-eltorito-alt-boot', '-e', 'boot/grub/efi.img','-no-emul-boot', '-isohybrid-gpt-basdat',
The rebuild will fail if there is no "boot/grub/efi.img" as is the case with something like "ubuntu-mini-remix", so coding in some validation first really is needed.

In conjunction with the "unmkinitramfs" workaround (#208), customizer is now building my lubuntu 16.04 images without issue.

# Create the ISO filesystem
message.sub_info('Creating ISO')
os.chdir(config.ISO_DIR)
misc.system_command(('xorriso', '-as', 'mkisofs', '-r', '-V', \
    distrib + '-' + arch + '-' + release, '-isohybrid-mbr',\
    '/usr/lib/ISOLINUX/isohdpfx.bin', '-b', 'isolinux/isolinux.bin', \
    '-c', 'isolinux/boot.cat', '-J', '-l', '-no-emul-boot', \
    '-boot-load-size', '4', '-boot-info-table', \
    '-eltorito-alt-boot', '-e', 'boot/grub/efi.img','-no-emul-boot', '-isohybrid-gpt-basdat', \
    '-o', iso_file, \
    '-cache-inodes', '-input-charset', 'utf-8', '.'))

asharrem avatar Sep 06 '19 23:09 asharrem

@asharrem Bammo, that looks like the culprit. Thank you for your sleuthing, I'm pretty sure we had a similar problem before with /usr/lib/ISOLINUX/isohdpfx.bin and not telling customizer users isolinux had become a required package.

Looks like I need to add grub-pc-bin, grub-efi-amd64-bin, and possibly grub-xen-bin to the required packages.

To fix this in your ISOs, make sure the package grub-efi-amd64-bin is installed inside the chroot before the ISO build process is triggered.

I should however point out, Ubuntu mini remix has been a dead project since 2016 last I checked.

I had a heck of a time tracking the UMR 16.04 AMD64 ISO down. magnet:?xt=urn:btih:C81842ADBD29D5DBBAD5BE2E9D0309482179F567 There's the magnet link in case anyone else was trying to get the original ISO. 16.04.2 is here as of late 2018. https://archiveos.org/ubuntu-mini-remix/

I've talked to Fabrizio long ago when I took over ubuntu-builder on launchpad back in 2013 -- but it was GAMBAS3 based; as was Customizer at the time. Later on, Customizer got a python2/QT4 port, and I sent in some patches fixing it for python3 and QT5. The previous maintainer wasn't a coder, so I was asked to take the repo over, then the previous maintainer left github.

Here is Fabrizio's buildscripts for UMR though. https://gist.github.com/fballiano/357810cf7eb70f09d87e

melodie's been active in other Customizer issues, and I partially documented the unmkinitramfs workaround as part of that.

My own buildscripts for Customizer are here: https://github.com/kamilion/kamikazi-core

kamilion avatar Sep 07 '19 01:09 kamilion

Thanks asharrem and kamilion. I was able to build an ISO based on asharrem's instructions, in the end I used the following command to pack my ISO directory

sudo xorriso \
-as mkisofs \
-r \
-V Ubuntu-amd64-18.04 \
-isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin  \
-b isolinux/isolinux.bin \
-c isolinux/boot.cat \
-J \
-l \
-isohybrid-gpt-basdat \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
-eltorito-alt-boot \
-e boot/grub/efi.img \
-no-emul-boot \
-o /home/customizer/Ubuntu-amd64-18.04.iso \
-cache-inodes \
-input-charset utf-8 \
.

I wasn't able to boot the ISO in UEFI mode after writing with dd if=iso-path.iso of=/dev/sdX, but using rufus and flashing in ISO mode was successful.

willprice avatar Sep 16 '19 19:09 willprice