Ubuntu Server 20.04 autoinstall

Ubuntu Server 20.04 comes with a new automated OS installation method called autoinstall. It is a replacement of the debian-installer (preseed). Overall, it is a better system that removes the headaches of using commands to interact with a GUI based installer.

Update: The AutoInstall documentation provided by Canonical is much much better than when I initially read it. Please consider using that as a resource too.


  • Get the Ubuntu Live Server ISO file.
  • Prepare the autoinstall configuration file.
  • Prepare the boot commands.

Prepare autoinstall configuration file

In this example, the cloud-init’s nocloud-net datasource provider is used to present the autoinstall configuration file via HTTP.

The nocloud-net datasource provider looks for two files, meta-data and user-data file at the URL path provided to the seedfrom variable (s is a short-form).

autoinstall ds=nocloud-net;seedfrom=http://repo/files/ubuntu2004/

In this automated Ubuntu OS installation the meta-data file is not needed, but it must be present at the URL path; basically an empty file. The user-data file will contain the autoinstall configuration.

Hint: Run python -m SimpleHTTPServer 8080 to serve the static content on a desired port. In Python 3, it is python3 -m http.server 8080.

Simple web server, serving meta-data and user-data files

Example autoinstall user-data file

user-data file

Autoinstall gotchas

  • The comment line #cloud-config is important.
  • It’s best to stop the SSH service in the installer environment. Leaving it enabled can confuse packer into initiating SSH connection and failing the packer build after 10 failed attempts.
  • The network key needs to be nested twice, it is a bug.
  • The dhcp-identifier: mac was needed to stop the DHCP server from leasing another IP address to the same MAC address. This confused packer because on the next boot the VM could have a different IP address and packer would get stuck waiting to form an SSH connection to the VM.
  • The username: root is not supported in the identity section.
  • In the late-commands section, enable the ubuntu user to sudo without a password. This will make ansible playbooks more manageable and simpler.
  • In the late-commands section, if you update the grub file, make sure to run update-grub2 in the target filesystem afterwards. The curtin command needs to have a --target /target . The documentation fails to mention this correctly.
  • The default ubuntu-vg/ubuntu-lv configuration for the root filesystem is set to 4 GiB in size. You have to extend the logical volume and resize the filesystem in a post-install step.

Preparing your boot commands for automated OS installation

Interrupt into the GRUB menu by tapping Shift key.

  1. At language selection click Enter key for the default English selection.

Edit the default boot commands by hitting F6, followed by Esc key. At this point your cursor will be at the end of the default boot commands.

autoinstall net.ifnames=0 biosdevname=0 ip=dhcp ipv6.disable=1 ds=nocloud-net;s=http://repo/files/ubuntu2004/

The autoinstall keyword is needed for the Live Installer to select the autoinstall method.

  • net.ifnames=0 and biosdevname=0 is needed to revert the OS naming of interface names to older eth0, eth1 formats.
  • ip=dhcp enables the use of DHCP during the automated OS installation.
  • ipv6.disable=1 disables the use of IPv6 in the OS.
  • ds=nocloud-net;s=<url> is the cloud-init datasource options for nocloud-net. The seedfrom url’s trailing slash is important because cloud-init’s nocloud-net datasource does not prepend the forward slash when requesting the meta-data and user-data files on the web server.
Great success, now automate even the boot commands…


The root filesystem is only 4GiB after autoinstall?

The default size of the root filesystem (/dev/ubuntu-vg/ubuntu-lv) appears to use only 4 GiB of the disk space. In a post-install step it would be best to expand the logical volume to the desired size.

Below is an example ansible task to update the logical volume in a post-install playbook. My ansible local post-install playbook can be found here.

The Ubuntu Live Server ISO is too fast for packer

I ran into some difficulty where the packer boot_command arrives too late and the Live Server ISO had already initiated the default interactive installer.

I settled on setting up an iPXE infrastructure to drop into the PXE shell, where I can allow packer to enter the appropriate commands and launch an iPXE script via HTTP.

chain http://repo.home.local/artifactory/files/ubuntu2004/ubuntu2004.ipxe

In the iPXE script I have the freedom to configure the exact boot arguments to the installer.

Ubuntu iPXE script

I no longer need to provide an ISO file to packer, since the iPXE scripts can handle that component far better. To bypass the packer’s requirement for an iso_url I fed it an empty.iso.


Here is the git repo I use to maintain my homelab infrastructure’s packer build workflow: https://github.com/tlhakhan/packer-esxi

No Network Installer ISO?

In the alternative downloads, Canonical is no longer easily providing the network installer ISO.

However searching in the comments section of the Netbooting the Live Server article, the mini.iso file can be found hidden in the legacy-images directory. The comments indicate that Canonical is planning to remove this build artifact in later Ubuntu releases.

The message is, “Get onboard with using the Live Server ISO file for network installs”.