Ubuntu Server 20.04 autoinstall


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

Prepare autoinstall configuration file

In this automated Ubuntu installation, I uses cloud-init’s nocloud-net datasource provider to fetch the autoinstall configuration file from an HTTP server.

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

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.
  • I’ve setup early commands to update the hostname during the installation. Otherwise the installer environment defaults to a hostname called ubuntu-server.
  • The username: root is not supported in the identity section.
  • In the late-commands section, allows the ubuntu user to sudo without a password. This will make ansible playbooks a little 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 .

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.
autoinstall net.ifnames=0 biosdevname=0 ip=dhcp ds=nocloud-net;s=http://repo/files/ubuntu2004/
  • 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.
  • ds=nocloud-net;seedfrom=<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 Ubuntu Live Server ISO is too fast for Hashicorp Packer

I use a utility called Packer by Hashicorp to automate the entire VM building process.

# request DHCP IP address
# chain load an iPXE script located on an HTTP server
dhcp && chain http://repo/files/ubuntu2004/ubuntu2004.ipxe
Ubuntu iPXE script



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store