Automating Ubuntu Installation: Creating Unattended Setup with Preseed Configuration


13 views

For system administrators and DevOps engineers looking to automate Ubuntu deployments, preseed files provide the equivalent functionality to Red Hat's Kickstart. The Debian-installer (d-i) used by Ubuntu fully supports unattended installations through this mechanism.

To implement automated Ubuntu installation, you'll need three key elements:

  • A preseed configuration file (text-based answer file)
  • Modified boot parameters for the installer
  • Proper network accessibility for package retrieval

Here's a basic preseed.cfg file that handles partitioning, user creation, and package selection:

# System language
d-i debian-installer/language string en
d-i debian-installer/country string US

# Network configuration
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string ubuntu-auto
d-i netcfg/get_domain string example.com

# Partitioning
d-i partman-auto/method string lvm
d-i partman-auto-lvm/guided_size string max
d-i partman-auto/choose_recipe select atomic

# User setup
d-i passwd/user-fullname string Admin User
d-i passwd/username string admin
d-i passwd/user-password password secure123
d-i passwd/user-password-again password secure123
d-i user-setup/allow-password-weak boolean true

# Package selection
tasksel tasksel/first multiselect standard, ubuntu-server

There are multiple ways to incorporate the preseed file:

Network-based via HTTP

Append this to your kernel boot parameters:

auto url=http://your-server/preseed.cfg

Embedded in ISO

For offline installations, modify the ISO by adding the preseed file to the isolinux/txt.cfg:

label autoinstall
  menu label ^Automated Install
  kernel /install/vmlinuz
  append file=/cdrom/preseed.cfg auto=true priority=critical debian-installer/locale=en_US

Post-Install Scripts

Add custom commands to run after installation:

d-i preseed/late_command string \
  in-target apt-get update; \
  in-target apt-get install -y docker.io; \
  in-target systemctl enable docker

Disk Encryption

For encrypted LVM setups:

d-i partman-auto-crypto/erase_disks boolean true
d-i partman-crypto/passphrase password encryption-pass
d-i partman-crypto/passphrase-again password encryption-pass

When debugging unattended installations:

  • Add fb=false debconf/frontend=noninteractive to boot params
  • Check /var/log/installer/syslog on the target system
  • Test in a VM before deploying to production

For cloud images, combine preseed with cloud-init for complete automation. The Ubuntu server image automatically looks for user-data and meta-data files on the NoCloud datasource.


For system administrators and DevOps engineers automating deployments, Ubuntu provides a powerful unattended installation system through preseed files. This functionality is comparable to Red Hat's Kickstart but uses Debian's debian-installer framework.

You'll need three essential elements:

  1. A modified Ubuntu ISO with preseed.cfg
  2. Kernel boot parameters pointing to your configuration
  3. Proper partitioning and post-install scripts

Here's a basic preseed.cfg example that handles partitioning, package selection, and user setup:


# System language
d-i debian-installer/language string en
d-i debian-installer/country string US

# Network configuration
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string ubuntu-auto
d-i netcfg/get_domain string local

# Partitioning (LVM example)
d-i partman-auto/method string lvm
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-auto-lvm/guided_size string max
d-i partman-auto/choose_recipe select atomic

Modify the ISO's boot parameters in isolinux/txt.cfg:


label autoinstall
  menu label ^Automated Install
  kernel /install/vmlinuz
  append auto=true file=/cdrom/preseed.cfg priority=critical debian-installer/locale=en_US keyboard-configuration/layoutcode=us

For PXE boot environments, you can host the preseed file on a web server:


d-i preseed/url string http://192.168.1.100/preseed.cfg

Include custom scripts in your preseed to run after installation:


d-i preseed/late_command string \
  in-target sh -c "apt-get update && apt-get install -y docker-ce"; \
  in-target wget http://example.com/scripts/postinstall.sh -O /root/postinstall.sh; \
  in-target chmod +x /root/postinstall.sh

Monitor the installation process with these techniques:

  • Add fb=false to boot parameters to see console output
  • Check /var/log/installer/syslog on the target system
  • Test in a VM before deploying to production