genisoimage and UEFI

9.5k views Asked by At

How can I create UEFI ISO image on Debian Jessie machine?

When I use follow command on my Kubuntu everything is OK

genisoimage -quiet -V "my-amd64" -J -R -r -l -cache-inodes -c isolinux/boot.cat  -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot -o my-amd64.iso my-amd64/

isohybrid --uefi my-amd64.iso

But when I run this command on Debian Jessie I get follow error:

genisoimage: option '-e' is ambiguous; possibilities: '--eltorito-boot' '--exchange' '--ethershare' '--exclude-list' '--exclude' '--eltorito-catalog' '--eltorito-alt-boot'
Usage: genisoimage [options] -o file directory ...

It seems as genisoimage on Kubuntu (15.04) and Debian Jessie does not have same options. On Debian genisomage does not support UEFI.

Version on both system is same: genisoimage 1.1.11

But I must create ISO image on Debian Jessie. Any workaround for this?

5

There are 5 answers

1
weiyang On

Issue: genisoimage: unrecognized option '-efi-boot'

The solution is as follows:

apt install xorriso
mv /usr/bin/genisoimage /usr/bin/genisoimage.bak
ln -s /usr/bin/xorrisofs /usr/bin/genisoimage
0
Karsten On

You can install xorriso and replace genisoimage with xorrisofs in your script. It'll accept the same command line parameters.

1
Mantriur On

Apparently there was an incompatible change in Mondo or genisoimage. The problem was reported, but the provided wrapper-workaround got a bit mangled by the wiki. Using a wrapper solves the problem for everything depending on that syntax.

Here's what I did:

Prepare the wrapper:

mv /usr/bin/genisoimage /usr/bin/genisoimage.dist
YourFavoriteTextEditor /usr/bin/genisoimage

Copy/paste the wrapper:

#!/bin/bash

options=() # the buffer array for the parameters

while [[ $1 ]]
do
  case "$1" in
   -e)
     options+=("--eltorito-boot")
     shift
     ;;
   *)
     options+=("$1")
     shift
     ;;
  esac
done

echo Calling genisoimage.dist "${options[@]}"
eval exec /usr/bin/genisoimage.dist "${options[@]}"

Make wrapper executable:

chmod 755 /usr/bin/genisoimage

Live happily ever after. :-)

0
davolfman On

If you do an apt source genisoimage on an Ubuntu machine and look in the diff you'll find that they have a significant patch set added to cdrkit to get this capability. You could try to backport the changes. Or you could use xorriso which seems to have this capability if you have syslinux-utils installed for the files. The command would then be.

xorriso -as mkisofs \
  -o <output> \
  -isohybrid-mbr /usr/lib/syslinux/isohdpfx.bin \
  -c isolinux/boot.cat \
  -b isolinux/isolinux.bin \
   -no-emul-boot -boot-load-size 4 -boot-info-table \
  -eltorito-alt-boot \
  -e isolinux/efiboot.img \
   -no-emul-boot \
   -isohybrid-gpt-basdat \
   -r -J \
   <CD_root>
0
nbanba On

First, I didn't succeed in building an EFI bootable AMD64 image of Debian, bootable in every situation (on a DVD or on a USB stick or...).

But as I wanted to succeed, I did going back to the fundamentals, and I found instructions for Repacking a Debian ISO with its original boot equipment

Adapting the contents to 2023's ISO, I was able to write and successfully test the following procedure.

For the example, I will modify Debian 11.6 AMD64 stable ISO. I will add in its /firmware directory all firmware you can find on a Debian computer in /usr/lib/firmware after installing the following 3 Debian packages: firmware-linux firmware-linux-free firmware-linux-nonfree:

sudo apt install firmware-linux firmware-linux-free firmware-linux-nonfree

And after still for the example, I will repack the ISO, copying it on a USB key and successfully boot in legacy (MBR) and in UEFI mode The image also work when burned on a DVD.

Make a root mkiso directory:

mkdir /home/nba/mkiso
cd /home/nba/mkiso
wget https://cdimage.debian.org/debian-cd/current/amd64/iso-dvd/debian-11.6.0-amd64-DVD-1.iso

Extract source ISO:

mkdir deb
sudo apt install xorriso
xorriso -osirrox on -indev deb11.6-nba-amd64.iso -extract / ./deb

or

sudo apt install bsdtar
bsdtar -C ./deb -xf debian-11.6.0-amd64-DVD-1.iso

Add files / firmware. We want to add firmware to the ISO image:

sudo apt install firmware-linux firmware-linux-free firmware-linux-nonfree

mkdir -p /home/nba/mkiso/fw
cp -rf /usr/lib/firmware /home/nba/mkiso/fw/

Extract xorriso build command from source ISO:

cat deb/.disk/mkisofs


xorriso -as mkisofs -r -checksum_algorithm_iso sha256,sha512 -V 'Debian 11.6.0 amd64 1' -o /srv/cdbuilder.debian.org/dst/deb-cd/out/3bullseyeamd64/debian-11.6.0-amd64-DVD-1.iso -checksum-list /srv/cdbuilder.debian.org/src/deb-cd/tmp/3bullseyeamd64/bullseye/checksum-check -jigdo-checksum-algorithm md5 -jigdo-force-checksum /pool/ -jigdo-min-file-size 1024 -jigdo-exclude 'README*' -jigdo-exclude /doc/ -jigdo-exclude /md5sum.txt -jigdo-exclude /.disk/ -jigdo-exclude /pics/ -jigdo-exclude 'Release*' -jigdo-exclude 'Packages*' -jigdo-exclude 'Sources*' -jigdo-jigdo /srv/cdbuilder.debian.org/dst/deb-cd/out/3bullseyeamd64/debian-11.6.0-amd64-DVD-1.jigdo -jigdo-template /srv/cdbuilder.debian.org/dst/deb-cd/out/3bullseyeamd64/debian-11.6.0-amd64-DVD-1.template -jigdo-map Debian=/srv/cdbuilder.debian.org/src/ftp/debian/ -jigdo-exclude boot1 -J -joliet-long -cache-inodes -isohybrid-mbr syslinux/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 boot/grub/efi.img -no-emul-boot -isohybrid-gpt-basdat -isohybrid-apm-hfsplus boot1 CD1

Modify xorriso build command (remove -jidgo options + related checksum...):

xorriso -as mkisofs -r -V 'deb11.6-nba-amd64' -o ./deb11.6-nba-amd64.iso -J -joliet-long -cache-inodes -isohybrid-mbr ./isohdpfx.bin -b isolinux/isolinux.bin -c isolinux/boot.cat -boot-load-size 4 -boot-info-table -no-emul-boot -eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot -isohybrid-gpt-basdat -isohybrid-apm-hfsplus deb fw

Generate MBR by extracting first 432 bytes from source ISO:

cd /home/nba/mkiso
dd if=debian-11.6.0-amd64-DVD-1.iso of=isohdpfx.bin bs=1 count=432 

Build new iso (adding deb/ and fw/firmware to the ISO):

xorriso -as mkisofs -r -V 'deb11.6-nba-amd64' -o ./deb11.6-nba-amd64.iso -J -joliet-long -cache-inodes -isohybrid-mbr ./isohdpfx.bin -b isolinux/isolinux.bin -c isolinux/boot.cat -boot-load-size 4 -boot-info-table -no-emul-boot -eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot -isohybrid-gpt-basdat -isohybrid-apm-hfsplus deb fw

Verify by extracting the newly created ISO:

mkdir /home/nba/mkiso/deb2
cd /home/nba/mkiso/
xorriso -osirrox on -indev deb11.6-nba-amd64.iso -extract / deb2

Verify firmware are present in /home/nba/mkiso/deb2/firmware:

ls /home/nba/mkiso/deb2/firmware

Test boot: use xorriso -report_system_area options on source ISO and on new ISO and compare:

xorriso -indev debian-11.6.0-amd64-DVD-1.iso -report_system_area as_mkisofs
xorriso -indev deb11.6-nba-amd64.iso -report_system_area as_mkisofs

Verify you have line:

-isohybrid-mbr --interval:local_fs:0s-15s:zero_mbrpt,zero_gpt,zero_apm:'deb11.6-nba-amd64.iso'

and lines:

-eltorito-alt-boot
-e '/boot/grub/efi.img'
-no-emul-boot

Copy to USB key and try to boot:

sudo dd if=deb11.6-nba-amd64.iso of=/dev/sda bs=256M status=progress

Reboot on key !

Please note :

  • It boot on a USB stick
  • It work when dd copy on an hard drive and try to boot on this drive
  • I also burn the ISO on a DVD and it was also bootable
  • I also try to boot on the ISO file directly from an hypervisor, and it was - working and booting

All that for say that my repacked ISO image was bootable in every situation (MBR and UEFI on all supports) like the original Debian ISO image.