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.

Overview

  • Get the Ubuntu Live Server ISO file.

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.

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.
Great success, now automate even the boot commands…

Notes

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.

build_empty_iso.sh

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”.

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