Unattended Installations

4.3. Unattended Installations

The Debian and Kali installers are very modular: at the basic level, they are just executing many scripts (packaged in tiny packages called udeb—for µdeb or micro-deb) one after another. Each script relies on debconf(see The debconf Tool), which interacts with you, the user, and stores installation parameters. Because of this, the installer can also be automated through debconf preseeding, a function that allows you to provide unattended answers to installation questions.

4.3.1. Preseeding Answers

There are multiple ways to preseed answers to the installer. Each method has its own advantages and disadvantages. Depending on when the preseeding happens, the questions that can be preseeded vary.

4.3.1.1. With Boot Parameters

You can preseed any installer question with boot parameters that end up in the kernel command-line, accessible through /proc/cmdline. Some bootloaders will let you edit these parameters interactively (which is practical for testing purposes), but if you want to make the changes persistent, you will have to modify the bootloader configuration.

You can directly use the full identifier of the debconf questions (such as debian-installer/language=en) or you can use abbreviations for the most common questions (like language=en or hostname=duke). See the full list of aliases in the Debian installation manual.

There is no restriction on which questions you can preseed since boot parameters are available from the start of the installation process and they are processed very early. However, the number of boot parameters is limited to 32 and a number of those are already used by default. It is also important to realize that changing the boot loader configuration can be non-trivial at times.

In Section 9.3, "Building Custom Kali Live ISO Images" you will also learn how to modify the Isolinux configuration when you generate your own Kali ISO image.

4.3.1.2. With a Preseed File in the Initrd

You can add a file named preseed.cfg at the root of the installer's initrd (this is the initrd which is used to start the installer). Usually, this requires rebuilding the debian-installer source package to generate new versions of the initrd. However, live-build offers a convenient way to do this, which is detailed in Section 9.3, "Building Custom Kali Live ISO Images".

This method also does not have any restrictions on the questions that you can preseed as the preseed file is available immediately after boot. In Kali, we already make use of this feature to customize the behaviour of the official Debian installer.

4.3.1.3. With a Preseed File in the Boot Media

You can add a preseed file on the boot media (CD or USB key); preseeding then happens as soon as the media is mounted, which means right after the questions about language and keyboard layout. The preseed/file boot parameter can be used to indicate the location of the preseeding file (for instance, /cdrom/preseed.cfg when installing from a CD-ROM, or /hd-media/preseed.cfg when installing from a USB-key).

You may not preseed answers to language and country options as the preseeding file is loaded later in the process, once the hardware drivers have been loaded. On the positive side, live-build makes it easy to put a supplementary file in the generated ISO images (see Section 9.3, "Building Custom Kali Live ISO Images").

4.3.1.4. With a Preseed File Loaded from the Network

You can make a preseed file available on the network through a web server and tell the installer to download that preseed file by adding the boot parameter preseed/url=http://server/preseed.cfg (or by using the url alias).

However, when using this method, remember that the network must first be configured. This means that network-related debconf questions (in particular hostname and domain name) and all the preceding questions (like language and country) cannot be preseeded with this method. This method is most often used in combination with boot parameters preseeding those specific questions.

This preseeding method is the most flexible one as you can change the installation configuration without changing the installation media.

Delaying the Language, Country, Keyboard Questions


To overcome the limitation of not being able to preseed the language, country, and keyboard questions, you can add the boot parameter auto-install/enable=true (or auto=true). With this option the questions will be asked later in the process, after the network has been configured and thus after download of the preseed file.

The downside is that the first steps (notably network configuration) will always happen in English and if there are errors the user will have to work through English screens (with a keyboard configured in QWERTY).

4.3.2. Creating a Preseed File

A preseed file is a plain text file in which each line contains the answer to one Debconf question. A line is split across four fields separated by white space (spaces or tabs). For instance, d-i mirror/suite string kali-rolling:

  • The first field indicates the owner of the question. For example, "d-i" is used for questions relevant to the installer. You may also see a package name, for questions coming from Debian packages (as in this example: atftpd atftpd/use_inetd boolean false).

  • The second field is an identifier for the question.

  • The third field lists the type of question.

  • The fourth and final field contains the value for the expected answer. Note that it must be separated from the third field with a single space; additional space characters are considered part of the value.

The simplest way to write a preseed file is to install a system by hand. Then the debconf-get-selections --installer command will provide the answers you provided to the installer. You can obtain answers directed to other packages with debconf-get-selections. However, a cleaner solution is to write the preseed file by hand, starting from an example and then going through the documentation. With this approach, only questions where the default answer needs to be overridden can be preseeded. Provide the priority=critical boot parameter to instruct Debconf to only ask critical questions, and to use the default answer for others.

Installation Guide Appendix


The Debian installation guide, available online, includes detailed documentation on the use of a preseed file in an appendix. It also includes a detailed and commented sample file, which can serve as a base for local customizations.

https://www.debian.org/releases/stable/amd64/apb.html

https://www.debian.org/releases/stable/example-preseed.txt

Note however that the above links document the stable version of Debian and that Kali uses the testing version so you may encounter slight differences. You can also consult the installation manual hosted on the Debian-installer project's website. It may be more up-to-date.

http://d-i.alioth.debian.org/manual/en.amd64/apb.html