This repository contains Packer templates for building Amazon Machine Images for Ubuntu with a ZFS root filesystem. Currently the following distributions are supported:
- Ubuntu 20.04 ("Focal") LTS with AWS-Optimized Kernel
- Ubuntu 18.04 ("Bionic") LTS with AWS-Optimized Kernel
- Ubuntu 16.04 ("Xenial") LTS with AWS-Optimized Kernel
The template is easily modified for Debian and other Ubuntu distributions.
You can read about how this template works on the jen20.dev blog. Some relevant posts:
- Ubuntu 20.04 with Root ZFS on AWS
- Ubuntu 18.04 with Root ZFS on AWS
- Building ZFS Root Ubuntu AMIs with Packer
As well as installing different versions of the Ubuntu distribution, the templates in this repository have
evolved at different rates. The focal
template is the most complete, and includes the following changes
compared to other versions:
- Support for AWS NVME device rules
- Support for expanding the ZFS root filesystem via Cloud-Init
- Clearing of the apt-cache as part of the build
These changes could likely be backported to other distributions, but they are mostly there for information only since I personally only use (and test) the latest LTS distribution for new images.
Use the focal
target of the Makefile in the root of the repository to build an AMI in us-west-2
. If you wish to copy
the AMI to other regions, edit the template to specify aws_regions
in the amazon-ebssurrogate.source
source. It is
also possible to change the region in which the AMI is built directly, though editing files/sources-us-west-2.list
is
necessary if the initial packages must be obtained from a region other than us-west-2
.
AWS credentials are sourced from the environment using the standard AWS chain exposed by Packer. The template has only been tested using v1.6.0 of Packer - the latest available at the time of writing.
Use the bionic
or xenial
targets of the Makefile in root of the repository to build an AMI in us-west-2
, and copy
it to all regions. Use a recent version of Packer - version 1.3.1 has been tested.
The following environment variables must be set in order for the build to succeed:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
Thanks to:
- Scott Emmons for this post about the steps required to build Linux AMIs with a ZFS root filesystem.
- Sean Chittenden for reviewing the template and blog post prior to publication.
- Zachary Schneider for reviewing the template and blog post prior to publication.