As a Linux instructor for Guru Labs, I get the opportunity to do a great deal of system administration. One of those responsibilities as an admin is performing installations of RHEL, Fedora, SLES, OpenSUSE and OEL. Soon, hopefully, we'll be adding Debian and Ubuntu to the mix of courses and courseware. As such, along with Christer Edwards who also teaches at Guru Labs, I've taken it upon myself to find the necessary admin tools to bring to the table for our future courses. One such tool that has bothered me as of late, is automating an Ubuntu or Debian install.
With Red Hat and Fedora, the Anaconda installer automatically creates a /root/anaconda-ks-cfg file. This file is a Kickstart file necessary for automating installs if I want to build machines exactly like the one I just installed. In other words, this file is all the answers to the questions that I just entered for that installation. This is a handy feature. Why doesn't Debian and Ubuntu do this? Actually, they do. Kind of.
When asked the necessary questions in the Debian text-based installer, a database is created keeping track of each of those answers. When the system is finished installing, that database is stored under /var/log/installer/questions.dat. Unfortunately, if you installed your system via the GUI installer, this file is not created. Further, you will need a utility to extract the answers to those questions, as the questions.dat file is a binary database.
So, we need to install debconf-utils for access to a couple of binaries necessary to build this preeseed config file for automating the rest of the installations that I wish to perform.
sudo aptitude install debconf-utils
After installed, I now have access to the debconf-get-selections tool for helping be exctract the answers out of the questions.dat database. So...
sudo debconf-get-selections --installer > preseed.cfg sudo debconf-get-selections >> preseed.cfg
I now have a preseed config file necessary for my automated installs. However, that config file may have a bunch of unnecessary stuff that I may not want for the install. So, I should open up that config file, and edit it as necessary, removing a lot of the bloat. It is best, rather, to build a preseed.cfg file from scratch, or using an example template, and building from there. This approach is superior for a couple of reasons. First, I will learn the internals of preseed itself. Second, I will become intimately familiar with the Debian installer questions, and the power that I probably take for granted. After building my own preseed file from scratch, I can then customize it to fit my needs, or my network needs, as necessary.
To build one such file, the Debian documentation team has some decent docs for helping me get started. However, the docs are hardly exhaustive, so you may find yourself spending a bit of time on Google, before getting the hang of it. At the documentation site, I have "Creating a preconfiguration file" and "Contents of the preconfiguration file" documents available. Spending some time there, learning preseed is time well spent. After the file is created, there is a syntax checker to make sure the contents of the preseed file are sound:
sudo debconf-get-selections -c preseed.cfg
Now that I have my built preseed file, it's time to boot my boxes using the file. Obviously, I will need to make the file accessible somehow. I can make this preseed file accessible via HTTP, FTP, NFS, locally on a hard drive or partition, CDROM or even built into the initial RAM disk itself. Once I have that access, at the boot prompt, I enter the following (adjusting as necessary for the location of the preseed file):
And, based on the contents of the preseed file located at that web address, the installer starts, and off we run with installing the new Debian or Ubuntu system, completely hands-off (again, based on the file contents).
As an ending thought, preseed can read Anaconda Kickstart files, but there is still a bit to yet be implemented. If you prefer using Kickstart as a method for automating your installs, you should probably build a hybrid file for the missing Kickstart features with preseed. There is also a GUI tool for building Kickstart files available in the Debian and Ubuntu repositories:
sudo aptitude install system-config-kickstart
However, using Kickstart files to build your Debian or Ubuntu box isn't as flexible or powerful as preseed, and further, you really won't learn the internals of the Debian installer. Kickstart is heavily documented, unlike the sparse documentation that exists for preseed, so you'll likely find more answers if building a Kickstart file.