Automated Customized Debian Installation Using Preseed

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

Create directories

You will need to create some directories for your work. I like to create them all at once.

cg@codeghar:~$ mkdir cgdeb
cg@codeghar:~$ cd cgdeb
cg@codeghar:~/cgdeb/$ mkdir iso loopdir isofiles workspace

Download testing installer

cg@codeghar:~/cgdeb/$ cd iso

The URL used here may not always work. Your best bet is to download directly from Debian FTP/HTTP site.

cg@codeghar:~/cgdeb/iso$ curl -o debian-testing-amd64-netinst.iso

cg@codeghar:~/cgdeb/iso$ cd ..

Mount installer ISO and extract files

cg@codeghar:~/cgdeb$ sudo mount -o loop iso/debian-testing-amd64-netinst.iso loopdir
cg@codeghar:~/cgdeb$ rsync -v -a -H --exclude=TRANS.TBL loopdir/ isofiles/
cg@codeghar:~/cgdeb$ sudo umount loopdir
cg@codeghar:~/cgdeb$ chmod u+w isofiles

Extract initrd.gz

You need to add your preseed.cfg file to initrd.gz so you first need to extract it.

cg@codeghar:~/cgdeb$ cd workspace
cg@codeghar:~/cgdeb/workspace$ 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.

cg@codeghar:~/cgdeb/workspace$ vim preseed.cfg

Create new ISO

Create a new initrd.gz and replace the original one with it.

cg@codeghar:~/cgdeb/workspace$ su -c 'find . | cpio -H newc --create --verbose | gzip -9 > ../isofiles/install.amd/initrd.gz'

cg@codeghar:~/cgdeb/workspace$ cd ../isofiles

cg@codeghar:~/cgdeb/isofiles$ 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).

cg@codeghar:~/cgdeb/isofiles$ md5sum `find -follow -type f` > md5sum.txt

Finally, create the new customized automated installer ISO.

cg@codeghar:~/cgdeb/isofiles$ 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/ .


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.

Hat Tips

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

About these ads


Get every new post delivered to your Inbox.

Join 34 other followers

%d bloggers like this: