Automated Customized Debian Installation Using Preseed
December 14, 2011 5 Comments
I’ve always wanted to create a custom Debian installer CD with a preseed file for automated installation. This post is the first step in realizing that dream. There are many steps and details involved in the process but creating a CD with a preseed.cfg file is the easiest because it’s repeatable step-by-step. So that’s where I start my quest.
I tested these steps using a Debian Squeeze 64-bit VM. I downloaded the daily Debian testing netinstall ISO image to use for customization. Therefore, the steps may need to be altered based on the contents of the downloaded CD.
Install required software
I found that I needed the following packages to create my customized Debian installer. You may need to install some of the other required packages based on your installation.
sudo aptitude install curl
sudo aptitude install rsync
sudo aptitude install genisoimage
You will need to create some directories for your work. I like to create them all at once.
mkdir iso loopdir isofiles workspace
Download testing installer
The URL used here may not always work. Your best bet is to download directly from Debian FTP/HTTP site.
curl http://hammurabi.acc.umu.se/cdimage/daily-builds/daily/arch-latest/amd64/iso-cd/debian-testing-amd64-netinst.iso -o debian-testing-amd64-netinst.iso
Mount installer ISO and extract files
sudo mount -o loop iso/debian-testing-amd64-netinst.iso loopdir
rsync -v -a -H --exclude=TRANS.TBL loopdir/ isofiles/
sudo umount loopdir
chmod u+w isofiles
You need to add your preseed.cfg file to initrd.gz so you first need to extract it.
gzip -d < ../isofiles/install.amd/initrd.gz | cpio --extract --verbose --make-directories --no-absolute-filenames
Create preseed.cfg file
You can create the preseed.cfg file in the workspace directory. You can look at the Debian Squeeze preseed example file and customize it for your needs.
Create new ISO
Create a new initrd.gz and replace the original one with it.
su -c 'find . | cpio -H newc --create --verbose | gzip -9 > ../isofiles/install.amd/initrd.gz'
chmod u+w md5sum.txt
Create new md5sum.txt file with updated MD5. You may see an error “find: File system loop detected; `./debian’ is part of the same file system loop as `.’.” but it seems harmless and may be ignored (please correct me if I’m wrong).
md5sum `find -follow -type f` > md5sum.txt
Finally, create the new customized automated installer ISO.
sudo genisoimage -o debian-testing-amd64-netinst-custom-preseed.iso -r -J -no-emul-boot -boot-load-size 4 -boot-info-table -b isolinux/isolinux.bin -c isolinux/boot.cat .
You can burn the ISO to a CD and install from there. When using the installer, use command line install NOT GUI install because we only modified the command line initrd.gz. If you want to use GUI install, I assume you would need to add the preseed.cfg file to that initrd.gz as well.
This post would not have been possible without the following resources.
Debian-Installer: How to modify an existing CD image to preseed d-i; Automating the installation using preseeding; Debian Remaster Netinstaller – Integrate Firmware bnx2x and Preseed; Genisoimage – Creates ISO-9660 CD-ROM filesystem images