This article is published at Debian Administration
Anyone doing Debian installations regularly might be interested in the preseed method of the Debian installer. This document describes how to use this technique.
Just get yourself a recent Sarge install CD and a system you can test this on. (or vmware :)) For generating preseed answers you will need the debconf-utils package.
Please note that the given preseed example will automatically format your entire hardrive!!!
The preseed method is quite simple. It's simply an answer file for all questions asked by the debian installer. The only thing the installer needs to know is where to find the file which answers all questions.
When the CD boots you have the opportunity to add parameters. It is advised to also set the debconf priority by adding 'debian/priority=critical' to the paramaters. For using preseeding you have the following options.
i.e. linux26 preseed/file=/floppy/preseed.cfg debian/priority=critical
Please note that providing more than 3 extra kernel options to the debian installer will result in a kernel panic. This is because older 2.6 kernel can only handle 8 kernel options. Anymore will result in a kernel panic.
The preseed file is generated with the command:
debconf-get-selections --installer > preseed.cfg debconf-get-selections >> preseed.cfg
However this does not seem to work all the time. It is also noted in the Debian documentation that you should modify the example preseed file with this generated file.
After installation you probably want some extra packages installed. This also scriptable using the preseed method. First of all in the preseed file you have the option of specifying a command to execute after installation. For example installing squid after installation:
base-config base-config/late_command string apt-get install squid
But then you will be presented with some questions. To prevent these question we will have to add the answers to the preseed file. From a system were squid has been installed on run:
debconf-get-selections |grep squid
It will return something like:
squid squid/fix_cachedir_perms boolean false # Upgrade squid.conf automatically? squid squid/fix_lines boolean true # There is no automatic upgrade path to squid 2.5. squid squid/old_version boolean false
Paste this in your preseed.cfg file and the question won't appear again.
So now we will have a file resembling like this. This example also includes a custom partioning scheme!
debconf debconf/priority string critical
unknown debconf/priority string critical
d-i debconf/priority string critical
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string example.com
d-i netcfg/wireless_wep string
d-i mirror/country string enter information manually
d-i mirror/http/hostname string http.us.debian.org
d-i mirror/http/directory string /debian
d-i mirror/suite string stable
d-i mirror/http/proxy string
d-i partman-auto/disk string /dev/discs/disc0/disc
#d-i partman-auto/choose_recipe select Separate /home, /var, and /tmp partitions
# select Multi-user workstation
d-i partman-auto/expert_recipe string exampleserver :: 2000 50 5000 ext3 $primary{ } $bootable{ } method{ format } format{ } use_filesystem{ } filesystem{ ext3 } mountpoint{ / } . 5000 10000 1000000000 ext3 method{ format } format{ } use_filesystem{ } filesystem{ ext3 } mountpoint{ /var } . 64 512 300% linux-swap method{ swap } format{ } .
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition select Finish partitioning and write changes to disk
d-i partman/confirm boolean true
d-i grub-installer/only_debian boolean true
d-i prebaseconfig/reboot_in_progress note
base-config base-config/intro note
base-config base-config/login note
base-config tzconfig/gmt boolean true
base-config tzconfig/choose_country_zone_single boolean true
base-config tzconfig/verify_choices boolean true
passwd passwd/make-user boolean false
passwd passwd/md5 boolean false
passwd passwd/shadow boolean true
base-config apt-setup/uri_type select http
base-config apt-setup/country select enter information manually
base-config apt-setup/hostname string ftp.us.debian.org
base-config apt-setup/directory string /debian
base-config apt-setup/another boolean false
base-config apt-setup/security-updates boolean true
base-config base-config/late_command string apt-get install squid
exim4-config exim4/dc_eximconfig_configtype select no configuration at this time
exim4-config exim4/no_config boolean true
exim4-config exim4/no_config boolean true
exim4-config exim4/dc_postmaster string admin@example.com
tasksel tasksel/first multiselect Standard system
ssh ssh/new_config boolean true
# Do you want to continue (and risk killing active ssh sessions)?
ssh ssh/use_old_init_script boolean true
ssh ssh/protocol2_only boolean true
# Do you want to run the sshd server?
ssh ssh/run_sshd boolean true
# Do you want /usr/lib/ssh-keysign to be installed SUID root?
ssh ssh/SUID_client boolean true
ssh ssh/disable_cr_auth boolean false
# Which ispell dictionary should be the system's default?
dictionaries-common dictionaries-common/default-ispell select british (British English)
dictionaries-common dictionaries-common/default-wordlist select american (American English)
# Remove obsolete /etc/dictionary link?
dictionaries-common dictionaries-common/old_wordlist_link boolean true
# Move non-FHS stuff under /usr/dict to /usr/dict-pre-FHS?
dictionaries-common dictionaries-common/move_old_usr_dict boolean true
# Remove obsolete /usr/dict symlink?
dictionaries-common dictionaries-common/remove_old_usr_dict_link boolean false
squid squid/fix_cachedir_perms boolean false
# Upgrade squid.conf automatically?
squid squid/fix_lines boolean true
# There is no automatic upgrade path to squid 2.5.
squid squid/old_version boolean false
You will now be able to install Debian unattended and with some creativity you will be able to do some really nice things. For example I use the late command to download a script which sets up everything according to it's hostname.
base-config base-config/late_command string wget http://example.com/late-cmd -O /tmp/late-cmd; chmod +x /tmp/late-cmd; /tmp/late-cmd
The preseed method isn't perfect. I had lots of trouble preseeding exim and eventually I replaced exim with postfix. There was a security advisory for the 2.6 kernel recently and I haven't found a way of skipping the reboot warning yet. Also note that when using a preseed file from the network no answers will be answered automatically untill the installer has set up networking!
For more information about the Preseed method have a look at the following sites: