Rolling Out Unattended Debian Installations (Part 1)

By: Carla Schroder
Monday, December 6, 2004 03:47:59 PM EST

Requirements and Overview

The next time you have a hankerin' to install a new batch of Debian machines, make it easy on yourself and use FAI (Fully Automatic Installation). FAI is a versatile, intelligent installer for performing mass unattended Debian installations. Use it to install clusters, server farms, classroom computer labs, or new LANs. An automatic installer has all kinds of possible uses:

  • Fast installation after replacing a hard drive
  • Fast setup for temporary installations, like trade shows, demonstrations, LAN parties, and such
  • Quick re-format and re-installation at the start of new classes in school, so that students do not inherit the messes their predecessors created.
  • Quick re-format and re-installation for new hires or temporary workers.

You will build a central installation server containing a Debian mirror. This can be any old PC with a large hard drive; you'll need around 10 gigabytes of storage space just for the Debian package files. (Don't even try this without a high-speed Internet connection.) A laptop makes a great portable FAI server. The installation clients will get their files from this server. The clients need only to be connected to the network, and booted either from floppy disk or network card. Files are transferred to the clients via your choice of HTTP, FTP, or NFS.

Installing and configuring FAI has two parts: the installation server configuration, and customizing the client installation scripts. Once this is done FAI does all the work, and all you need to do is not make it look too easy. Part 1 covers building the server; Part 2 will show how to set up the client configurations and run a client installation.

Setting Up A Local Debian Mirror

As always, run apt-get update first to update your package lists. Then install all the necessary packages for FAI:

# apt-get install fai fai-kernels debmirror mknbi dhcp3-server bootp tftpd-hpa rsh-server rsync

You'll find out what all of these do as we go along. Next, create a directory to house your mirror. Remember, you'll need a lot of disk space. In this example it is /debmirror, isolated on its own partition, and there are 15 nice plump gigabytes allocated for it.

Now you can download the files. Check the mirror list to find a close download site. Use the mkdebmirror script, located in /usr/share/doc/fai/examples/utils/ to download and build the mirror. mkdebmirror uses debmirror and rsync, and creates the mirror directories. First edit the script to suit your preferences. This example creates a Sid mirror. Note that the original script included with FAI mirrors the security archive. This is not a good idea. For one thing, there is no security archive for Sid. For another, security updates should be downloaded directly from, so get rid of the debian-security section. It also helpful to add the -v flag to the debmirror commands, so you that can monitor progress. This is a complete example:

#! /bin/sh
# $Id: mkdebmirror,v 1.19 2004/07/08 11:35:44 lange Exp $
# Thomas Lange,, (c) 2001-2004
# create partial debian mirror using command debmirror(1) and rsync

# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
rsync_disks() {
# get the boot disks
rsync --delete -av $2::debian/dists/$1/main/disks-$arch $destdir/debian/dists/$1/main/
# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
update_from() {
# update local mirror from a host
allopt="$debug --passive --getcontents --nosource --arch=$arch --ignore=disks-$arch/"
defopt="$allopt --host=$host --dist=$dist"
echo "------------------ create mirror for debian ------------------"
# add the -v flag for verbosity
debmirror -v $destdir/debian $defopt
echo "------------------ create mirror for debian-non-US ------------------"
debmirror -v $destdir/debian-non-US $defopt -r /debian-non-US -s non-US/main,non-US/contrib,non-US/non-free
# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# main program
# here you have to adjust the hostnames of the mirror and the names of the distributions

dist=sid destdir=/files/scratch/debmirror
# first sync from a mirror near to you
# get installation disk images via rsync
rsync_disks sid

Save your changes and run your mkdebmirror script:

# /usr/share/doc/fai/examples/utils/mkdebmirror
------------------ create mirror for debian ------------------
Mirroring to /files/scratch/debmirror/debian from
Arches: i386
Dists: sid
Sections: main,contrib,non-free,main/debian-installer
Passive mode on.
Attempting to get lock, this might take 2 minutes before it fails.
Get Release files.
[0%] Getting: dists/sid/Release
[0%] Getting: dists/sid/Release.gpg
Get Packages and Sources files and other miscellany
. dists/sid/main/binary-i386/Packages.gz needs fetch
[0%] Getting: dists/sid/main/binary-i386/Packages.gz

rsync can be a bit funky; if it fails with an error message, try re-running the script a couple of times before looking for script errors.

Configuring The FAI Server

While the mirror files are downloading is a good time to configure the server. Open /etc/fai/sources.list and configure one section to point to your local FAI server; this is what the client machines will use. See /usr/share/doc/examples/etc/sources.list for help with this.

Next, edit /etc/fai/fai.conf. In this example, the mirror server is Windbag, configured to use FTP. You may choose FTP, HTTP, or NFS:


# if your server has multiple network cards, specify
# the correct one here SERVERINTERFACE=eth0

FAI_DEBMIRROR=$mirrorhost:/files/scratch/debmirror # the fai-setup script will create the "fai" user
# Name of log-server. If undefined, the install server will be used.
# writable directory on remote server, when using FTP protocol
# password for login to log server, when using FTP protocol

# the configuration space on the install server
# the location of the config space, as seen by the install client
# it can also be overwritten with T170 via BOOTP
# the local configuration directory on the install client

# the type of operating system (linux, sunos)
OS_TYPE=`uname -s | tr /A-Z/ /a-z/`

Finally, edit /etc/fai/make-fai-nfsroot.conf. NFS is the fastest method for the client installations, the FAI server installation requires it, and you'll still have the option to use FTP or HTTP for the client installation.

NFSROOT_ETC_HOSTS=" $mirrorhost"
FAI_DEBOOTSTRAP="sid file:/files/scratch/debmirror"

Now run the fai-setup script:

# fai-setup

This will take awhile, as it needs to build a nice chrooted NFS filesystem, generate SSH keys, and copy lots of files. When it is all finished, your FAI server is ready to go. Come back next week to learn how to configure and perform the client installation.


FAI comes with an excellent manual, which is also installed to /usr/share/doc/fai/fai-guide.html. The /usr/share/doc/fai/ directory is full of scripts and configuration examples.
Troubleshooting help is here.
FAI uses standard Linux utilities glued together with Perl and Bash scripts, so you can refer to their individual man pages, such as rsync, debmirror, NFS, and so forth.
See Information for mirror owners for more information on mirror sizes, and useful resources on mirroring.

Copyright © 1999 Corp. All Rights Reserved.