Skip to content

Instantly share code, notes, and snippets.

@fishd72
Created October 9, 2023 10:28
Show Gist options
  • Save fishd72/ec8d3b4be3aa3a1537baaf0e0c02a972 to your computer and use it in GitHub Desktop.
Save fishd72/ec8d3b4be3aa3a1537baaf0e0c02a972 to your computer and use it in GitHub Desktop.
Debian auto-installer
#!/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"
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 'Debian 12.1.0 amd64 n' \
-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