ServersAutomate Linux Installs With Debian Pre-Seeds, Part 1

Automate Linux Installs With Debian Pre-Seeds, Part 1

ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

Red Hat and its many clones and offspring, like Fedora, CentOS, White Box Linux, have long had a simple built-in mechanism for cloning installations on diverse hardware: Kickstart. With Kickstart you can easily create a customized configuration, set up an installation server, plug a new PC into the network, and perform an unattended network installation. SUSE has AutoYaST.
Whether you’re rolling out a collection of servers or looking for a way to get new ones in service quickly, Debian pre-seeding makes it easy.

Debian users have not been so fortunate. FAI, the Fully-Automated Installer, works beautifully when it’s set up correctly. But learning to use FAI is not so easy.

Of course, the Linux world does not stand still. The shiny new Debian Sarge installer introduced a new feature called pre-seeding. Pre-seeding means creating an answer file that answers all questions asked by the installer. Pre-seeding supports both local installations from bootable media and network installations. There are a number of ways to do this:

  • Local installation with the standard installation CD/DVDs, plus the preseed file on removable media
  • Local installation with the standard installation CD/DVDs, plus the preseed file fetched from a network drive
  • Network installation from a Debian mirror or a local mirror
  • Using a remastered CD or DVD containing the preseed file

This two-part series covers network installation of Etch, the Testing release of Debian. (There are a lot of changes from Sarge, the Stable Debian release. Each one has its own excellent official Debian installation manual, so make sure you have the right one.) Part 1 will illustrate a couple of simple ways to generate and use a preseed configuration file. Part 2 will detail how to configure the preseed configuration file and set up a local mirror for fast automatic installations.

Quick Start For the Madly Impatient

You can easily test this with your existing Debian installation. It should also work with Ubuntu/Kubuntu/Edubuntu/Xubuntu/Metoobuntu/etc. Two important limitations you should know about are: There is no way to use an existing partitioning scheme, so you must use either free space or the entire hard disk, and you cannot set up RAID yet with pre-seeding.

First install debconf-utils, then extract the contents of /var/log/installer/cdebconf, which is a database of everything installed on the system, into a preseed.cfg file:

# apt-get install debconf-utils
# debconf-get-selections --installer > preseed.cfg
# debconf-get-selections >> preseed.cfg

preseed.cfg is a plain-text file, as this snippet from a Kubuntu system shows:

# Which specific keymap do you want ?
console-data console-data/keymap/qwerty/czech/standard/keymap select
# Update /etc/network/interfaces?
ifupdown ifupdown/convert-interfaces boolean true
# Which specific keymap do you want ?
console-data console-data/keymap/qwerty/latvian/standard/keymap select
# Choose the Ubuntu mirror to use:
base-config apt-setup/mirror select

You can copy this file to removable media and use it with your Debian (or *buntu) installation CD to create a duplicate installation on a second PC. To do this, boot up the installation disk with a parameter telling the installer where to find the preseed file, and to not pester you with any but the most important questions:

linux26 preseed/file=/floppy/preseed.cfg  debconf/priority=critical

This is a easy method for replicating installations on a small network. A useful hack is to store several different preseed files on a USB stick for different types of installations (e.g., workstations, firewalls, and file servers). You might still have to answer a configuration question or two, but you can tweak also the preseed configuration files to make it completely automatic, which we’ll discuss in Part 2.

USB Stick Network Installation

If you have a USB stick with 128 MB or greater capacity, you can use it to boot the Etch installer, and then start the installation with a small .iso image. The installer will give you a list of Debian mirrors to choose from to complete the installation. First, download hd-media/boot.img.gz to your PC’s hard drive. You’ll find it on any Debian mirror, like Then, download the business-card CD image.

Now prepare your USB stick. Delete all existing partitions, then create at least one new partition, and format it with the FAT filesystem. If your USB stick is larger than 128 MB you may create more than one partition; just be sure to reserve the first partition for the Etch installer.

Find the drive’s block device name:

$ lsscsi
4:0:0:0] disk LEXAR JUMPDRIVE 1.10 /dev/sdb

Make sure it is not mounted. If it is, unmount it. This example shows that it is not:

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda1             4.7G  3.9G  819M  83% /
tmpfs                 253M     0  253M   0% /dev/shm
/dev/hda2             3.8G  1.5G  2.3G  41% /home

Now display the existing partitions:

# fdisk /dev/sdb
Command (m for help): P
Disk /dev/sdb: 128 MB, 128974848 bytes
4 heads, 62 sectors/track, 1015 cylinders
Units = cylinders of 248 * 512 = 126976 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1015      125829    1  FAT12

Go ahead and delete the partition(s):

Command (m for help): d
Selected partition 1
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

Fire up fdisk again, this time to create and label a new partition:

# fdisk /dev/sdb
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
Partition number (1-4): 1
First cylinder (1-1015, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1015, default 1015):
Using default value 1015
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 1
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

Now give it a filesystem:

 # mkfs.vfat /dev/sdb1 
mkfs.vfat 2.11 (12 Mar 2005)

If you’re wondering why you need to do this when you know you have a perfectly reliable USB stick, feel free to omit all the partitioning and creating-filesystem steps. In my estimable opinion it prevents strange and vexing errors.

Copying the Boot Files

Now extract the boot files to the USB stick:

# zcat boot.img.gz > /dev/sdb1

This will take a few minutes. When it’s finished, mount the USB stick and copy the CD image to it. You’ll have plenty of room left over for your preseed configuration file, or even several of them. To use preseed files on the USB stick, make sure they are in the top-level directory. Boot up with the USB stick, then boot with these parameters:

linux26 preseed/file=/floppy/preseed.cfg debconf/priority=critical

With a small modification you may use this same technique for local network installations. Come back next week to learn how to do this, plus how to fine-tune the preseed configuration file.


This article originally appeared on  

Get the Free Newsletter!

Subscribe to Daily Tech Insider for top news, trends & analysis

Latest Posts

Related Stories