Posted by sphaero on Wed 3 May 2006 at 10:04
Anyone doing Debian installations regularly might be interested in the preseed method of the Debian installer. This document describes how to use this technique.
Requirements
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 installed.
**Please note that the given preseed example will automatically format your entire hardrive!!!**
Preseeding
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.
Installer parameters
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.
preseed/url=http://some.example.com/preseed.cfg preseed/file=/floppy/preseed.cfg
(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 kernels can only handle 8 kernel options. Anymore will result in a kernel panic.
Preseed file
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.
Adding answers for extra packages
After installation you probably want some extra packages installed. This is 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 where squid has been installed on run:
debconf-get-selections |grep squidIt 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! (Remember the warning; using this file will trash your disk.)
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
End notes and further reading
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. If you are using a preseed file from the network you are not able to answer questions automatically until the installer has setup networking.
For more information about the preseed method have a look at the following sites:
[ Parent ]
[ Parent ]
[ Parent ]
Old thread, I know. But I figured this was less intrusive than making a duplicate blog post. I've got some of my preseeding experiences written up at this location.
The positive stuff not necessarily found elsewhere in this form:
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
For the kernel update, I use:
echo -e "\n\n" | apt-get install --assume-yes kernel-image-2.*
[ Parent ]