Automating new Debian installations with preseeding

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 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! (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:

 

 


Posted by Anonymous (83.132.xx.xx) on Wed 3 May 2006 at 11:32
Hi! Problems preseeding exim where probably due to the fact that debconf gets it's answers from '/etc/exim4/update-exim4.conf.conf' (something like this also happens in 'locales'). In a script I'm using, I first replace the original 'update-exim4.conf.conf' before updating/installing the packages.

For the kernel update, I use:
echo -e "\n\n" | apt-get install --assume-yes kernel-image-2.*

[ Parent | Reply to this comment ]

Posted by Anonymous (84.85.xx.xx) on Wed 3 May 2006 at 21:49
Note that if you use an Etch version of the installer, you should read the development version [1] of the installation guide rather than the Sarge version. There have been quite a few changes that impact preseeding since the release of Sarge and these are documented in the development version.
Preseeding has even been given a separate appendix with more background information.

[1] http://d-i.alioth.debian.org/manual/

[ Parent | Reply to this comment ]

Posted by ghostis (144.212.xx.xx) on Thu 17 Aug 2006 at 15:55
[ Send Message ]
This is a reinvention of the FAI wheel. Why not use FAI? We use FAI with PXE to do "bare-metal to desktop" installs on the 200+ Debian machines at my company.

http://www.informatik.uni-koeln.de/fai/

-Adam

[ Parent | Reply to this comment ]

Posted by Anonymous (150.101.xx.xx) on Thu 24 Aug 2006 at 12:29
Hardly re-inventing the wheel. preseedings a good 'built in' way of doing it, dont have to read a million miles of doco on fai :)
kamping_kaiser
kk

[ Parent | Reply to this comment ]

Posted by ghostis (144.212.xx.xx) on Thu 24 Aug 2006 at 17:30
[ Send Message ]
Hmm... Once I grokked FAI, it became fairly straightforward. But you are right: getting to that point was not easy. Maybe I need to start writing a "Get running quickly" FAI miniHowTo... ;) Preseeding seems simpler, and, as you say, it is built in. Perhaps the FAI folks can use it to simplify their set up.

-Adam

[ Parent | Reply to this comment ]

Posted by mwr (24.158.xx.xx) on Wed 18 Apr 2007 at 01:34
[ Send Message | View Weblogs ]

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:

  • After everything was set up, it takes one keypress to force a PXE boot, and everything else is unattended. I can go from power-up to a login prompt in under 10 minutes.
  • cfengine bootstrapping, so it can take over subsequent package installations and configuration file management.
  • Formatting a second drive with a very simple partitioning scheme, since partman-auto can only handle one drive on its own.

[ Parent | Reply to this comment ]

Posted by Anonymous (72.243.xx.xx) on Wed 30 May 2007 at 22:44
Another heads-up that may help someone:

if you see 'base-config' in any examples (as in this article), then the example is old -- base-config has been removed since March 2006 (http://www.debian.org/devel/debian-installer/News/2006/20060315).

So don't rely on base-config.

[ Parent | Reply to this comment ]

Posted by Anonymous (78.224.xx.xx) on Wed 24 Jun 2009 at 12:03
I think you can avoid the reboot warning with:

# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note

Sam
http://samj.net/

[ Parent | Reply to this comment ]

Posted by Anonymous (109.66.xx.xx) on Sat 25 Jun 2011 at 16:49
':)' don't look very respectable on an OS's formal web site, and the same goes for "vmware" when what is obviously meant is "virtual machine". It's not 'cool' to speak in a non official manner when instructing users, sometimes it is confusing, other times (like now) it just makes me feel I've stumbled across a bunch of nerds creating an OS for their own personal use and I have nothing to look for here. It's not even in a manual for multimedia or something, it's administration. The 'serious' stuff. It says "Debian Administration" in big blue shiny letters.
And it annoys me because it is my linux distro of choice for the ease of use and verity of packages, but sometimes you guys really piss me off! your OS looks serious. Too bad you don't.

[ Parent | Reply to this comment ]

Sign In

Username:

Password:

[Register|Advanced]

 

Flattr

 

Current Poll

Which init system are you using in Debian?






( 1604 votes ~ 7 comments )