How to build Ubuntu images

You can build and deploy your own customized Ubuntu images using Packer.

Canonical maintains a central repository of templates and instructions that cover Ubuntu and many other operating systems:

Packer MAAS templates on GitHub

The README in that repository explains:

  • How to install Packer and dependencies
  • Hardware requirements
  • How to build images for Ubuntu and non-Ubuntu systems
  • How to upload and test images in MAAS
  • Debugging tips and project structure for contributing

If you only need Ubuntu images, start in the ubuntu/ directory of the repository.
That folder provides a ready-made template and Makefile for building Ubuntu images.

For more background, see:

Overall Feedback

This guide seems to be a bit outdated as I ran into the issues mentioned below. I followed steps 2 and 3 from the other guide, How to build maas images, and that resolved all my issues below. My suggestion is to include adding the upstream repository in this guide as well as the following dependencies.

sudo apt install build-essential libnbd-bin nbdkit fuse2fs

Here are some of the issues I ran into following this guide step by step.

Issue 1

When running the command below:

make custom-ubuntu-lvm.dd.gz

Error

Command 'make' not found, but can be installed with:
apt install make        # version 4.3-4.1build1, or
apt install make-guile  # version 4.3-4.1build1

Resolution

sudo apt install sudo apt install build-essential

Issue 2

When running the command below:

make custom-ubuntu-lvm.dd.gz

Error

dpkg-query: package 'libnbd-bin' is not installed and no information is available
dpkg-query: package 'nbdkit' is not installed and no information is available
dpkg-query: package 'fuse2fs' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
make: *** [Makefile:27: check-deps] Error 1

Resolution

sudo apt install libnbd-bin nbdkit fuse2fs

Issue 3

When running the command below:

make custom-ubuntu-lvm.dd.gz

Error

make: *** [Makefile:63: custom-ubuntu-lvm.dd.gz] Error 127
rm OVMF_VARS.fd seeds-lvm.iso