Automate Linux Installs With Debian Pre-Seeds, Part 2

By Carla Schroder (Send Email)
Posted Jun 21, 2006


Plugging a new PC into your network, going out for a healthy walk, and returning to a completed operating system installation is one of life's little pleasures. Remember, laziness is a virtue in network administration. Hamsters spend their lives running the same circles. Network administrators automate repetitive tasks.

Need to roll out a collection of servers? Want to add a new one quickly? Debian pre-seeding makes it easy. We look at pre-seeding from CDs, floppies, and USB sticks.

Last week's installment discussed how to generate a quick 'n' dirty pre-seed configuration file for replicating a Debian installation, and how to perform a minimal custom installation with a USB stick.

Here, we'll cover how to start a network installation with either a newfangled USB stick or an oldfangled CD-ROM, or an even more antique 3.5" diskette.

Network Installation Options

If your BIOS and NIC support netbooting, you don't need a boot disk. You do need a TFTP and DHCP server, which are easy to set up. See Chapter 4.6. "Preparing Files for TFTP Net Booting" of the Etch installation manual.

An option for machines that do not support netbooting is to use Etherboot on a floppy disk. This works fine, even though the Etherboot project's primary purpose is to enable diskless netbooting. The preferred method is to copy the boot code to an add-on ROM chip on the NIC. Note that not all NICs support netbooting, or have an extra socket for a ROM chip.

To start a network installation from a CD-ROM, download the mini.iso image, which is about 8.7 MB.

We recommend using a removable boot device. That way you don't have to worry if the PC supports netbooting, and you don't have to hassle with changing the boot order in the BIOS after installation. The Etch installer supports all boot media: hard drive, diskette, CD/DVD, and USB sticks, and probably anything else you can cobble together. You can also find all the boot images you need on any Debian mirror.

Booting From a USB Stick

You must go into the BIOS of your PC to enable booting from a USB stick. Make sure it is plugged in when you start up so the BIOS can detect it.

Network Installation With a USB Stick

Follow these steps to turn your sleek USB stick into a lean-mean network installin' machine:

  • Follow the instructions in Part 1 to repartition and format the USB stick
  • Extract the boot files to the USB stick, as shown in Part 1
  • Do not copy an .iso image to the USB stick
  • Do copy your preseed.cfg file to the USB stick
  • Finally, replace the initrd.gz image with a netboot initrd.gz image

To complete the last step, download a new initrd.gz from a Debian mirror, like mirrors.kernel.org. Make sure it comes from a netboot/debian-installer/*/2.6/ directory. Rename it to initrd26.gz and copy it to the USB stick. You need the netboot initrd.gz image because the original one from boot.img.gz does not support a network installation, but instead requires local installation media.

When you boot up your USB stick, use the usual boot parameters as we learned in part 1:

linux26 preseed/file=/hd-media/preseed.cfg debconf/priority=critical

You'll walk through a few localization screens, configure networking, then be presented with a list of installation mirrors from which to choose. Scroll up to the top to find the option for entering your own mirror. Tell it where it to find your local mirror, and let 'er rip. If your pre-seed file is configured correctly, the rest of the installation will be fully automatic.

This isn't completely hands-off, because the pre-seed file is not loaded until after the installation mirror is selected, so you still have to answer a few questions. A completely hands-off automatic installation requires either netbooting and loading all options from the network, or modifying initrd.gz. Here's a hint for modifying initrd: It's not that difficult, and you should use the newfangled Yaird — "Yet Another mkInitRD" — to do it.

Building a Local Debian Mirror

You'll need a local installation server. This can contain either a complete mirror of your desired Debian archives or a partial mirror that caches only packages requested by clients on the network. A complete mirror requires anywhere from 10 to 40 or more GB of storage, depending on which archives are mirrored. You might want a complete mirror if you are continually trying out different builds and configurations, or if maximum installation speed is important. A partial mirror requires considerably less storage space and is a good choice for network admins who don't need every last available package to be on site.

It is easy to create either type of local mirror. For creating a complete mirror, use the Apt-mirror command. For creating a partial mirror, use Apt-proxy. Both are easy to set up and use. We recommend using apt-proxy anyway to reduce the load on the official mirrors and to speed up routine package installations and updates on your LAN.

Creating A Good Pre-seed File

A good starting point is the official example file. This is nicely organized and easily adaptable. Creating one with the debconf-get-selections command, discussed in Part 1, is useful because you can copy and paste specific sections from it to get any extra packages you want.

The pre-seed file is used by the debconf-set-selections command, and requires these fields:

  <owner>   <question name>    <question type>    <value> 

Beware of whitespace! The most common reason for pre-seed files not working correctly is wrong whitespace. There must be only a single space or tab between type and value. Use backslashes when you need to span a single line over several linebreaks. Check the syntax of your file with this command:

# debconf-set-selections -c preseed.cfg

Some Useful Installation Boot Options

When you pass in parameters at boot, always start with naming the kernel, which in these examples are linux26. linux24 selects the 2.4 kernel. To see all the different installation types, look in the syslinux.cfg file on your USB key. In fact, you may put any boot parameters in this file, instead of entering them on the boot command line.

If you're installing Debian on a multi-homed box, like a Linux router, be sure to specify the correct interface to use at boot:

netcfg/choose_interface=eth0
The Debian Installer automatically tries DHCP first. You can disable it this way if you prefer manual network configuration:

netcfg/disable_dhcp
Turning off pcmcia services on laptops prevents a number of problems:

hw-detect/start_pcmcia
You may use any Debian installation media as a rescue disk:

rescue/enable
As you can see, the new Debian installer is very versatile, and with a bit of work, you will be spared a lot of work.

Resources

This article originally appeared on EnterpriseNetworkingPlanet.com.  

Page 1 of 1


Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.