16.14. Automating Debian Installations with Preseed Files

You want a fairly simple way to automate network installation of new Debian PCs, and to create custom installations for different roles, such as web servers, workstations, file servers, and so forth.

Create a preseed, or preconfiguration file, that answers the installer questions, and does your package selections for you. First, study the example preseed file at http://d-i.alioth.debian.org/manual/example-preseed.txt Then, create one from your own Debian system by running these two commands:

	# debconf-get-selections --installer > preseed.txt
	# debconf-get-selections >> file preseed.txt

Your own preseed.txt is going to look different from the example-preseed.txt; it's messier and has a lot more entries. You can't use your own preseed.txt as-is, but you can see exactly what was done on your system, and you can copy anything you want to duplicate to example-preseed.txt.

The tasksel command selects package groups. You can see a list of these:

	$ tasksel --list-tasks 
	u desktop  Desktop environment
	i web-server  Web server
	u print-server  Print server
	u dns-server  DNS server
	[...]

u means uninstalled, and i means installed. Display individual packages with this command:

	$ tasksel --task-packages desktop
	twm
	gimp-print
	xresprobe
	openoffice.org
	[...]

Use tasksel to select package groups in your preseed file like this:

	#tasksel tasksel/desktop multiselect kde-desktop, xfce-desktop 
	#tasksel tasksel/first multiselect standard, kde-desktop

This means when the desktop task is selected, install kde-desktop and xfce-desktop instead of the default selections. Individual packages are selected with pkgsel, like this:

	d-i pkgsel/include string openvpn tftpd-hpa dnsmasq

I like to automate creating the root login, and disable the creation of a normal user account (because I do it later manually):

	passwd passwd/root-password password $1$AiJg3$GHlS8/vqkSgBj9/1EKPUv0
	passwd passwd/root-password-again password $1$AiJg3$GHlS8/vqkSgBj9/1EKPUv0
	passwd passwd/make-user boolean false

Keeping cleartext passwords around is a bad idea, so you can encrypt them first with:

	$ grub-md5-crypt
	Password:
	Retype password:
	$1$AiJg3$GHlS8/vqkSgBj9/1EKPUv0

This command checks the format of your preseed file to make sure it is valid:

	$ debconf-set-selections -c preseed.txt

After you have fine-tuned your preseed file and debconf-set-selections approves, how do you use it? With PXE netboot clients, copy your preseed file to /var/lib/tftpboot. Then, edit the auto boot stanza in /var/lib/tftpboot/pxelinux.cfg/default to point to the file:

	LABEL auto
	    kernel debian-installer/i386/linux
	    append auto=true priority=critical vga=normal \
	preseed/url=http://host/path/to/preseed.cfg \
	initrd=debian-installer/i386/initrd.gz --

You can copy your preseed file to the top-level directory on your USB flash drive and then enter this boot command:

	linux preseed/file=/dev/sdb/preseed.cfg debconf/priority=critical

Or, you can park your preseed file on a network server and then, for both CD and USB boot media, enter the URL:

	linux preseed/url=http://servername/filename

Debian's preseed files are not as easy as Fedora's Kickstart. But, it is one of the easier methods for creating customized Debian autoinstalls. See the Debian-Gnu Installation Guide (http://d-i.alioth.debian.org/manual/en.i386/index.html) for a detailed discussion of preseed and boot options.