Create Preseed Installation File

This provides answers for the debconf installer during installation. Providing these answers enables the installation to complete without interaction. Most of the options here are required for automated installation.

Reading the the preseed manual is recommended. See the complete example file here: ubuntu-template.seed.

To get avaliable parameters for a section:
debconf-get-selections | grep <option>
Localization Section.
1# -------- Localization --------
2d-i debian-installer/locale string en_US.UTF-8

Note

Set the installer’s locale.

Keyboard Section.
4# -------- Keyboard --------
5d-i console-setup/ask_detect boolean false
6d-i console-setup/layoutcode string us
7d-i keyboard-configuration/xkb-keymap select us

Note

Set keyboard to US and remove detection prompt.

Network Section.
 9# -------- Network --------
10d-i netcfg/choose_interface select auto
11d-i netcfg/link_wait_timeout string 10
12d-i netcfg/dhcp_timeout string 10
13d-i netcfg/dhcpv6_timeout string 1
14
15# Set default names to prevent prompts, overwritten by DHCP names.
16d-i netcfg/get_hostname string unassigned-hostname
17d-i netcfg/get_domain string unassigned-domain
18
19# Disable that annoying WEP key dialog.
20d-i netcfg/wireless_wep string

Note

Grab the first active network connection, quick fail DHCPv6 and wait 10 seconds for a link. Hostname is automatically set via DHCP, so just set a template hostname for initial installation. Disable WEP dialog.

Firmware Section.
22# -------- Hardware Firmware --------
23d-i hw-detect/load_firmware boolean true

Note

Enable installation of close-sourced firmware updates for hardware.

Apt Mirror Section.
25# -------- Apt Mirror --------
26d-i mirror/country string manual
27d-i mirror/http/hostname string mirrors.mit.edu
28d-i mirror/http/directory string /ubuntu
29d-i mirror/http/proxy string
30d-i mirror/udeb/components multiselect main, restricted, multiverse, universe

Note

This is for the main OS installation, NOT package installation. Set a custom ubuntu mirror, and enable all for components.

Accounts Section.
32# -------- Accounts --------
33# disable root user
34d-i passwd/root-login boolean false
35
36# base user for system
37d-i passwd/user-fullname string
38d-i passwd/username string {USER}
39d-i passwd/user-password-crypted password {PRE HASHED PASSWORD}
40d-i passwd/user-uid string 1000
41d-i passwd/user-default-groups string cdrom video sudo ssh plugdev
42d-i user-setup/encrypt-home boolean false
Creating {PRE HASHED PASSWORD}.
mkpasswd -m sha-512

Note

Disables root login, creating an initial {USER}, with a sha512 password hash. Give {USER} sudo and ssh access, and default groups to function.

The password used should be an installation password and not a real one.

Clock & Time Section.
44# -------- Clock and Timezone --------
45d-i clock-setup/utc boolean false
46d-i time/zone string America/Los_Angeles
47d-i clock-setup/ntp boolean true

Note

Read hardware clock as non-UTC, set timezone and enable NTP.

Partition Section.
49# -------- Partitioning --------
50# Auto remove existing LVM/RAID partitions on disk
51d-i partman-lvm/device_remove_lvm boolean true
52d-i partman-lvm/confirm boolean true
53d-i partman-lvm/confirm_nooverwrite boolean true
54d-i partman-md/device_remove_md boolean true
55d-i partman-md/confirm boolean true
56
57# Unmount auto-mounted existing partitions on disks, if any
58d-i preseed/early_command string umount /media
59
60# Disable no-swap warning, create / with at least 1GB for entire disk.
61d-i partman-auto/disk string /dev/{BLOCK DEVICE}
62d-i partman-auto/method string regular
63d-i partman-basicfilesystems/no_swap boolean false
64d-i partman-auto/expert_recipe string root :: 1000 50 -1 ext4 \
65     $primary{ } $bootable{ } method{ format } \
66     format{ } use_filesystem{ } filesystem{ ext4 } \
67     mountpoint{ / } \
68    .
69d-i partman-auto/choose_recipe select root
70
71# Apply partitioning info with confirmation
72d-i partman-partitioning/confirm_write_new_label boolean true
73d-i partman/choose_partition select finish
74d-i partman/confirm boolean true
75d-i partman/confirm_nooverwrite boolean true

Note

Automatically delete and remove LVM and RAID partitions. Umount any partitions that may have autmounted to /media. Create a single partition with no swap, EXT4, on block device /dev/{BLOCK DEVICE}.

Important

This can fail because there was no pre-existing partitions to umount. You can ignore this message or remove the umount command if you are sure you will not run into systems requiring to unmount /media.

See fix unmount problem in preseed and disks have mounted partitions which explains why these cause automated partitioning to fail.

Kernel Section.
77# -------- Base System Installation --------
78d-i base-installer/kernel/image string linux-generic

Note

Install the generic kernel. Use linux-server for server kernel.

Apt Setup Section.
80# -------- Apt Setup -------
81d-i apt-setup/restricted boolean true
82d-i apt-setup/universe boolean true
83d-i apt-setup/multiverse boolean true
84d-i apt-setup/backports boolean true

Note

Set system to use all four standard repos.

Package Selection Section.
80# -------- Package Selection --------
81# Main tasksel server packages
82tasksel tasksel/first multiselect server, openssh-server
83
84# Additional packages to install
85d-i pkgsel/include string openssh-server python-software-properties inotify-tools curl unattended-upgrades sysstat nmon tmux ssh vim haveged
86
87# Upgrade packages after bootstrap
88d-i pkgsel/upgrade select full-upgrade
89
90# Install security updates automatically
91d-i pkgsel/update-policy select unattended-upgrades

Note

Install the server and openssh-server tasks as well as other ubuntu packages. Upgrade all packages to latest version – this is currently broken in ubuntu and needs to be done manually in late_command.

Tip

Tasksel installs meta-packages for common setups.

List all avaliable tasks.
tasksel --list-task

These can be used in the tasksel/first line.

The packages installed in these meta packages can be found with:

tasksel --task-packages {PACKAGE}
apt --dry-run install {TASK}
  • The task includes ^, e.g. server^.

  • From ubuntu 16.04, --task-packages returns the meta-package name, not the list of packages. Other versions you can just use --task-packages.

  • See task packages from the germinate output templates here.

Console Setup Section.
 99# -------- Console Setup --------
100# Verbose startup output, drop to console (text) login by default.
101d-i debian-installer/quiet  boolean false
102d-i debian-installer/splash boolean false

Note

Disable the GUI boot login prompt, use console. Enable verbose logging on boot.

Tip

Everything works fine, but black screen on boot? You need to setup a proper GUI login (e.g. probably need to install desktop task) or enable the console.

You can still ctrl-alt-F1 to get to the console from the blank screen.

Boot Loader Installation Section.
104# -------- Boot Loader Installation --------
105# Assume one OS, install to default device, add other OS's if found.
106d-i grub-installer/only_debian boolean true
107d-i grub-installer/with_other_os boolean true
108d-i grub-installer/bootdev  string default
109d-i grub-installer/timeout  string 2

Note

Install grub to MBR with this OS as default. Detect other OS’s and add if needed. Default boot this OS in 2 seconds.

Finish Installation Section.
111# -------- Finish Installation --------
112d-i cdrom-detect/eject boolean true
113d-i finish-install/reboot_in_progress note

Note

Eject the CD before booting, don’t prompt for reboot.

Post Installation Section.
115# -------- Post Installation --------
116# After system is setup (before reboot), run post-install script.
117#
118# This command is run just before the install finishes, but when there is
119# still a usable /target directory. You can chroot to /target and use it
120# directly, or use the apt-install and in-target commands to easily install
121# packages and run commands in the target system.
122d-i preseed/late_command string cp -R /cdrom/post-install/* /target/tmp; in-target /tmp/post-preseed-complete

Note

Copy post-install directory from ISO to installed OS’s /tmp, and execute post-install script.

Commands must be done manually in late_command with in-target command to target the OS install, otherwise your scripts will fail. Using in-target behaves as a chroot to that system, meaning copy over your files to that system to find them.

You can pull your scripts and files using curl or wget.

References

  1. Contents of the Preseed file

  2. Example preseed file

  3. Preseed config

  4. Post install

  5. UEFI pressed install