Skip to content

Instantly share code, notes, and snippets.

@fishd72
Created October 8, 2025 09:01
Show Gist options
  • Save fishd72/11133f2b5445f92b822f6354d1cdb109 to your computer and use it in GitHub Desktop.
Save fishd72/11133f2b5445f92b822f6354d1cdb109 to your computer and use it in GitHub Desktop.
#!/bin/sh
orig_iso="$HOME/Downloads/debian-12.1.0-amd64-netinst.iso"
new_files="$HOME/Desktop/ISOFILES"
new_iso="$HOME/Desktop/debian-12.1.0-amd64-modified.iso"
iso_name="Debian 12.1.0 amd64 n"
mbr_template=isohdpfx.bin
mkdir -p $new_files
xorriso -osirrox on -indev $orig_iso -extract / $new_files
chmod +w -R ISOFILES/install.amd/
gunzip ISOFILES/install.amd/initrd.gz
echo preseed.cfg | cpio -H newc -o -A -F ISOFILES/install.amd/initrd
gzip ISOFILES/install.amd/initrd
chmod -w -R ISOFILES/install.amd/
cd ISOFILES
chmod +w md5sum.txt
find -follow -type f ! -name md5sum.txt -print0 | xargs -0 md5sum > md5sum.txt
chmod -w md5sum.txt
cd ..
# Extract MBR template file to disk
dd if="$orig_iso" bs=1 count=432 of="$mbr_template"
# Create the new ISO image
xorriso -as mkisofs \
-r -V "$iso_name" \
-o "$new_iso" \
-J -J -joliet-long -cache-inodes \
-isohybrid-mbr "$mbr_template" \
-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 \
"$new_files"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment