I'm on Ubuntu 22.04 and I'm trying to extract all the files from a (bootable) Debian ISO and then re-generate a bootable ISO image. Below you can see the commands that I've issued. For some unknown reason,the generated ISO image does not boot. Can someone help me to understand why ? thanks.
apt update && apt -y install xorriso genisoimage
wget https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.5.0-amd64-netinst.iso
xorriso -osirrox on -indev debian-11.5.0-amd64-netinst.iso -extract / isofiles/
genisoimage -r -J -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o debian-11-unattended.iso isofiles
as you can see I haven't done any modification to the files inside the ISO image,so the error should be most likely on the latest command.
According with this post :
https://unix.stackexchange.com/questions/572751/how-to-make-a-reproducible-iso-file-with-mkisofs-genisoimage
I have also tried with this command :
mkisofs -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -R -v -T -V 'd-live 11.5.0 xf amd64' "isofiles/" > file.iso
but also in this case the ISO produced is not bootable : https://ibb.co/GstvTvR
I've omitted the parameter "-reproducible-date=20221009" because it hasn't been accepted. The error produced is : "genisoimage: Uh oh, I cant find the boot image 'producible-date=20221009' and the ISO produced is only 32k.
This is how is the internal structure of the debian ISO file produced by the command above :
# isoinfo -d -i debian-11-unattended.iso
CD-ROM is in ISO 9660 format
System id: LINUX
Volume id: d-live 11.5.0 xf amd64
Volume set id:
Publisher id:
Data preparer id:
Application id: GENISOIMAGE ISO 9660/HFS FILESYSTEM CREATOR (C) 1993 E.YOUNGDALE (C) 1997-2006 J.PEARSON/J.SCHILLING (C) 2006-2007 CDRKIT TEAM
Copyright File id:
Abstract File id:
Bibliographic File id:
Volume set size is: 1
Volume set sequence number is: 1
Logical block size is: 2048
Volume size is: 224756
El Torito VD version 1 found, boot catalog is in sector 1020
Joliet with UCS level 3 found
Rock Ridge signatures version 1 found
Eltorito validation header:
Hid 1
Arch 0 (x86)
ID ''
Key 55 AA
Eltorito defaultboot header:
Bootid 88 (bootable)
Boot media 0 (No Emulation Boot)
Load segment 0
Sys type 0
Nsect 4
Bootoff 3FD 1021
the problem is in the lack of EFI boot lures: EFI System Partition for USB stick,EFI El Torito boot image for CD-ROM.
The solution is :
orig_iso=debian-live-11.5.0-amd64-xfce.iso
new_files=debian-live-11.5.0-amd64-xfce
new_iso=debian-live-11.5.0-amd64-mod-xfce.iso
mbr_template=isohdpfx.bin
# Extract MBR template file to disk
dd if="$orig_iso" bs=1 count=432 of="$mbr_template"
xorriso -as mkisofs \
-r -J --joliet-long \
-V 'd-live 11.5.0 xf amd64' \
-o "$new_iso" \
-isohybrid-mbr "$mbr_template" \
-partition_offset 16 \
-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 -isohybrid-gpt-basdat -isohybrid-apm-hfsplus \
"$new_files"