paulgorman.org/technical

Ubuntu (and Debian) Preseed for Unattended Installs

(March 2019)

Debian-based distributions automate installation using preseed. (At one point, maybe kickstart was supported, but now kickstart is only for Red Hat-derived distributions.)

Like kickstart, preseed uses an answer file to make installer selections. The file might be as simple as this:

d-i debian-installer/locale string en_US
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/xkb-keymap select us
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/wireless_wep string
d-i hw-detect/load_firmware boolean true
d-i mirror/country string manual
d-i mirror/http/hostname string archive.ubuntu.com
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string
d-i passwd/user-fullname string Ubuntu User
d-i passwd/username string ubuntu
d-i passwd/user-password-crypted password [crypt(3) hash]
d-i passwd/user-uid string 1010
d-i user-setup/allow-password-weak boolean true
d-i passwd/user-default-groups string audio cdrom video adm plugdev sudo
d-i user-setup/encrypt-home boolean false
d-i clock-setup/utc boolean true
d-i time/zone string America/Detroit
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string 10.0.0.1
[…]
d-i preseed/late_command string \
wget https://firefly.example.com/it/preseed/leasingdesktops/admin_rsa.pub -O /home/admin/.ssh/authorized_keys
d-i finish-install/reboot_in_progress note

Any unanswered questions will require manual selection in the installer.

debian-installer keeps its templates in /var/cache/debconf/*.dat.

Some sources recommend doing a manual install, then output a preseed file based on those selections using debconf-get-selections from the debconf-utils package. A file generated this way is an OK source of information, but it fails to capture significant selections like the user created or the partitioning scheme or even the time zone selected. So, not as useful as one might hope.

$  debconf-get-selections --installer > file
$  debconf-get-selections >> file

Validate a preseed file like:

$  debconf-set-selections -c preseed.cfg

The available methods to deliver the preseed answers depends on the install type.

Installation method initrd file network
CD/DVD yes yes yes†
netboot yes no yes
hd-media or usb-stick yes yes yes†

† but only if you have network access, and set preseed/url appropriately

Assuming we’re installing a simple machine with a single disk, and we control the DHCP server on our network, specifying the preseed file using a DHCP option is simplest. After adding the DHCP option, simply select the “auto” boot image. For ISC DHCP:

if substring (option vendor-class-identifier, 0, 3) = "d-i" {
    filename "http://host/preseed.cfg";
}

With the DHCP option being served, and the preseed file available via HTTP, select “Advanced options” → “Automated install”.