Article Listing 1 Listing 2 Listing 3 apr2006.tar

Quick and Dirty Debian Preseeds

Joe Blaylock

For a long time, my co-workers and I have been taking part in an evolutionary movement that will sound familiar to many readers. We've been migrating from huge, expensive, proprietary systems, to small, inexpensive, open ones. Like the fast-breeding shrew-like rodents that replaced the dinosaurs, our systems have been proliferating wildly. Clusters of cheap, relatively disposable systems are replacing powerful singleton hosts. Like the prolific mammals, the survival of our service no longer depends too much on any single host. If a given node or set of nodes dies, there are ample replacements.

At the heart of our appliance-computing evolution, we've placed the Debian GNU/Linux operating system. Debian is famous (some would say infamous) as a Linux distribution committed to free software, portability, and stability. Being appropriately conservative with releases in their quest for stability, the Debian project has gotten a reputation for cruftiness in some circles. Releases have been known to take years to freeze. Still, it is the extreme amount of care taken that makes Debian so appealing to so many. When you run a Debian system, you know what to expect, from package documentation to upgrade procedures.

All is not puppies and chocolate-chip cookies in the land of Debian systems administration, however. In particular, when you find yourself handling large numbers of systems, host automation and easy installation become critical. This is an area in which Debian has historically lagged. There has been at least one attempt over the years to make things better; Progeny packaged Kickstart for its Debian-based distribution. However, this didn't really catch on in the larger Debian community, and systems administrators were left to fend for themselves. Until Sarge.

Since the release of Sarge, Debian has supported partially or fully automated installation using pre-configuration files ("preseeds"). Preseed files are simple sets of key/value pairs that tell most Debian software (including the Debian Installer) how you would like various debconf package configuration questions answered. This frees you, the extremely valuable human being, from having to answer them yourself. Preseed files can be stored on modified installation media, on removable media, such as a USB stick, or even on the network (provided you can help your host onto the network, one way or another). Thus, they can provide significant help to the working systems administrator, whether you have one system or one hundred.

Getting Started

Starting a Debian installation with a preseed file is easy. At the boot prompt, simply provide the kernel with an extra parameter, "preseed/url" or "preseed/file". If you wanted to install Sarge using the default startup options and a preseed file on your trusty floppy disk, you would just use:

linux preseed/file=/floppy/preseed.cnf
This would boot Linux, passing the preseed/file parameter to the Debian Installer, which would then look in that location to load a set of defaults. Similarly, a preseed file can be passed in from the network using:

linux preseed/url=http://example.com/preseed.cnf
But take care! If no local resource provides the Debian Installer with a meaningful set of parameters to help it set up the networking, it will default to trying to get a DHCP lease. If it can't get one, then it won't be able to reach your preseed file. This might be okay -- you might be perfectly happy to sit at the keyboard long enough to set up networking on the machine, and then go for coffee. Try not to be too surprised, though, if you seed your installation from the network and go to lunch, only to find later that the machine hasn't done much of anything because it's not plugged into the Ethernet or you forgot to register your MAC address.

Simple Sample, Explained

Listing 1 (first.cnf) contains a simple pre-configuration for the Debian Installer, which sets a few installation parameters and then loads additional data from the file second.cnf (Listing 2). As you can see, the format has the (possibly abbreviated) name of the package to be preconfigured, the package configuration query to be configured, and the setting to assign, separated by whitespace. In Listing 1, the time zone is preconfigured, and in Listing 2, the system's default locale setting. This shows how preseeding might be useful for often-repeated and rarely altered settings that would be made to all of your nodes -- even if a fully automated installation would be overdoing it.

FAI and Preseed

To prepare a set of pre-configuration files for a fully automated system installation, it is best to begin by installing the system manually and to keep careful notes. In particular, a record of the extra packages installed from outside of base would be useful. Any services configured outside of debconf should be recorded, too.

If your system has the "debconf-utils" package, then a small script like the one in Listing 3 might come in handy. The debconf-dump-settings.sh script will create a file, /root/selections-tidy, which will contain a listing of all of the debconf selections (both explicit and implicit) made during your system installation, sorted for easy reference. Using this, you can add entries to your preseed file, and then try installing the system again -- this time, specifying your new preseed file to try things out. A certain amount of trial and error may be necessary to get things just right, particularly if you're going for a fully automatic system installation.

The effort to develop a smooth system installation is well worth it, however. Preseeding can make the Debian installation itself painless. Even better, an annotated preseed file set serves as comprehensive documentation of the system's initial state. Keeping the preseed in CVS ensures a record of systems architecture changes over time. What working systems administrator isn't excited by the thought of systems documentation that comes almost for free?

References

1. The Debian GNU/Linux Installation Guide, found at: http://www.debian.org/releases/stable/i386/ has a section on automated installations, with a more complete sample configuration than provided here: http://www.debian.org/releases/stable/i386/ch04s07.html.en

2. John Borwick wrote an article about installation automation with a lot of great ideas, which was published in last October's Sys Admin, "System Automation with PXE, Kickstart, and Cfengine" (http://www.samag.com/documents/s=9881/sam0510b).

3. The DebianInstallerPreseed node on the Debian Wiki, with links to other valuable resources, tips, and gotchas: http://wiki.debian.org/?DebianInstallerPreseed

Since 2002, Joe Blaylock has been administering Linux and Unix systems for the Indiana University Knowledge Base team. He has great fun preaching about open systems, pursuing his Bachelor's degree, and attending meetings. Actually, that bit about meetings is a lie. Questions, comments? Send to: blaylock@indiana.edu.