Debian-Installer: How to modify an existing CD image to preseed d-i

If you want to preseed DebianInstaller right from booting the installer CD, you can modify it to use an initrd which has your preseed.cfg file.

Create copy of image

You need one of the already built ISO images, which will be used as the basis that we modify. Because you can't modify an ?ISO9660 image, you've to copy it first:

... as root ...

 # mkdir loopdir
 # mount -o loop your-image.iso loopdir
 # mkdir cd
 # rsync -a -H --exclude=TRANS.TBL loopdir/ cd
 # umount loopdir

<!> If the above "mount -o loop" step produces errors you may need to load the loop module using # modprobe loop

Hack the initrd

... as root ...

# mkdir irmod
# cd irmod
# gzip -d < ../cd/install/2.6/initrd.gz | \
        cpio --extract --verbose --make-directories --no-absolute-filenames
# cp ../my_preseed.cfg preseed.cfg
# find . | cpio -H newc --create --verbose | \
        gzip -9 > ../cd/install/2.6/initrd.gz
# cd ../
# rm -fr irmod/

2006-12-06 15:12:53

Fix md5sum's

 # cd cd
 # md5sum `find -follow -type f` > md5sum.txt
 # cd ..

Create new image

To make the cdrom bootable, you need to run mkisofs with appropriate parameters. Here is how to do it for x86/amd64, using isolinux.

Change to the top of the cd directory then:

To create the cdrom image using the isolinux boot image:

 # mkisofs -o test.iso -r -J -no-emul-boot -boot-load-size 4 \
 -boot-info-table -b isolinux/isolinux.bin -c isolinux/boot.cat ./cd

If you want you can do a quick test of the iso using qemu:

 # qemu -net user -cdrom test.iso

Burn the image to cdrom

 # cdrecord -dev /dev/hd? test.iso

Much of this information was gleaned from the wiki document DebianInstaller/Modify.