How to set up an Ubuntu 20.04 ISO image to auto-install a server

May 6, 2020

In Ubuntu 20.04 LTS, Canonical has switched to an all new and not yet fully finished system for automated server installs. Yesterday I wrote some notes about the autoinstall configuration file format, but creating a generally functional configuration file is only the first step; now you need to set up something to install it. Around here we use DVDs, or at least ISO images, in our install setup, so that's what I've focused on.

The first thing you need (besides your autoinstall configuration file) is a suitable ISO image. At the moment, the only x86 server image that's available for Ubuntu 20.04 is the 'live server' image, so that's what I used (see here for the 18.04 differences between the plain server image and the 'live server' one, but then Ubuntu 20.04 is all in on the 'live' version). To make this ISO into a self-contained ISO that will boot with your autoinstall configuration, we need to add some data files to the ISO and then modify the isolinux boot configuration.

The obvious data file we have to add to the ISO is our autoconfigure file. However, it has to be set up in a directory for itself and a companion file, and each has to be called special names. Let's say that the directory within the ISO that we're going to use for this is called /cslab/inst. Then our autoinstall configuration file must be called /cslab/inst/user-data, and we need an empty /cslab/inst/meta-data file beside it. At install time, the path to this directory is /cdrom/cslab/inst, because the ISO is mounted on /cdrom.

(I put our configuration in a subdirectory here because we put additional bootstrap files under /cslab that are copied onto the system as part of the autoinstall.)

The isolinux configuration file we need to modify in the ISO is /isolinux/txt.cfg. We want to modify the kernel command line to add a new argument, 'ds=nocloud;s=/cdrom/cslab/inst/'. So:

default live
label live
  menu label ^Install Ubuntu Server
  kernel /casper/vmlinuz
  append   initrd=/casper/initrd quiet ds=nocloud;s=/cdrom/cslab/inst/ ---
[...]

(You can modify the 'safe graphics' version of the boot entry as well if you think you may need it. I probably should do that to our isolinux txt.cfg.)

The purpose and parameters of the 'ds=' argument are described here. This particular set of parameters tells the autoinstaller to find our configuration file in /cslab/inst/ on the ISO, where it will automatically look for both 'user-data' and 'meta-data'.

Some sources will tell you to also add an 'autoinstall' parameter to the kernel command line. You probably don't want to do this, and it's only necessary if you want a completely noninteractive install that doesn't even stop to ask you if you're sure you want to erase your disks. If you have some 'interactive-sections' specified in your autoinstall configuration file, this is not applicable; you're already having the autoinstall stop to ask you some questions.

For actually modifying the ISO image, what I do is prepare a scratch directory, unpack the pristine ISO image into it with 7z (because we have 7z installed and it will unpack ISOs, among many other things), modify the scratch directory, and then build a new ISO image with:

mkisofs -o cslab_ubuntu_20.04.iso \
  -ldots -allow-multidot -d -r -l -J \
  -no-emul-boot -boot-load-size 4 -boot-info-table \
  -b isolinux/isolinux.bin -c isolinux/boot.cat \
  SCRATCH-DIRECTORY

isohybrid cslab_ubuntu_20.04.iso

(isohybrid makes this ISO bootable as a USB stick. Well, theoretically bootable. I haven't actually tried this for 20.04.)

You can automate all of this with some shell scripts that take an ISO image and a directory tree of things to merge into it (overwriting existing files) and generate a new image.


Comments on this page:

By Nick at 2020-07-08 15:22:06:

Hi Chris,

Thanks for documenting this. Would it be possible to add the exact commands or screenshots you used when creating the `/cslab/init` folder?

I attempted to edit the scratch directory and `mkisofs`, but end up with a USB stick that won't boot. I'm putting the generated ISO on USB with mkusb.

Thanks

By cks at 2020-07-09 12:03:50:

What we do in the root of the ISO image to be is basically:

mkdir -p cslab/inst
touch cslab/inst/meta-data
cp -a ../master/user-data cslab/inst/user-data

The meta-data file is empty, but it has to be there. The user-data comes from where you keep your master copy under version control and so on.

By Jessi at 2020-09-27 11:15:54:

Hi Chris,

I'm trying out the method of putting the user-data file on my DVD. Everything works until curtin hits the apt stage upon which I hit a fatal error and can't continue. Any idea what's wrong?

I'm almost thinking this is a bug but since you got things up and urnning it seems unlikely.

By cks at 2020-09-28 15:57:53:

Unfortunately I have no idea what might be wrong in general; I don't think I ever hit apt errors during developing our ISO image (but I don't really customize the apt packages or anything). If we ran into this, I would have to inspect the specific apt error to figure out if I could identify what the problem was.

From 176.100.1.2 at 2020-10-01 06:45:24:

Hi Chris!

I have a strange situation with Ubuntu 20.04 iso Autoinstall. My steps:

  1. Get release from https://releases.ubuntu.com/20.04/ubuntu-20.04.1-live-server-amd64.is
  2. mount iso, unsquashfs casper/filesystem.squashfs,
  3. editing isolinux/txt.cfg
  4. creating in new.iso subdir pressed and put meta-data & user-data
  5. rebuild .iso by dint of xorriso
  6. boot guest host on EXSi from .iso
  7. Selected "Automatically instalation"

... but nothing happens.

  • isolinux/txt.cfg

default install-auto label install-auto

 menu label ^Automatically instalation
 kernel /casper/vmlinuz
 append   initrd=/casper/initrd quiet autoinstall ds=nocloud;s=/cdrom/preseed/ ---

label install-manual

 menu label ^Manually instalation
 kernel /casper/vmlinuz
 append   initrd=/casper/initrd quiet ---
  • meta-data

proto: none

  • user-data

#cloud-config autoinstall:

 version: 1
 locale: en_US.UTF-8
 keyboard:
   layout: us
 interactive-sections:
   - network
   - identity
 ssh:
   install-server: true

in the logs of the booted system, I see ั‚ัƒั‡ะต message:

  • /var/log/installer/subiquity-debug.log

2020-10-01 10:16:33,363 DEBUG cloudinit.sources.DataSourceNoCloud:154 Seed from /cdrom/preseed/ not supported by DataSourceNoCloudNet [seed=None][dsmode=net]

2020-10-01 10:16:33,363 DEBUG cloudinit.sources:665 Datasource DataSourceNoCloudNet [seed=None][dsmode=net] not updated for events: New instance first boot

2020-10-01 10:16:33,363 DEBUG cloudinit.sources:770 Seeing if we can get any data from <class 'cloudinit.sources.DataSourceNone.DataSourceNone'>

2020-10-01 10:16:33,364 DEBUG cloudinit.sources:654 Update datasource metadata and network config due to events: New instance first boot

Maybe you have an idea - what is wrong?!

Written on 06 May 2020.
« Notes on the autoinstall configuration file format for Ubuntu 20.04
Modern versions of systemd can cause an unmount storm during shutdowns »

Page tools: View Source, View Normal, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Wed May 6 00:54:54 2020
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.