Use Packer to build AMIs that use ZFS for the file system

(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at:, or follow me on Twitter.

This is a great article: Building ZFS Root Ubuntu AMIs with Packer. You can do the same thing with Docker but I would not want my software engineers taking on those devops tasks. Indeed, one reason I’m so hostile to Docker is because it disrupts the specialization of tasks that I want to see on my teams. I expect to work with great devops people, and I’ll leave devops decisions to them.

From the article:

For all applications of importance or significance, we recommend using ZFS. On bare metal servers, ZFS is king of the hill, but on AWS and Linux it is still gaining traction. Data integrity guarantees as well as features such as “instantaneous” snapshots, compression, quotas, and the ability to send/receive datasets make ZFS very compelling. In this post, we’re going to demonstrate how to build from-scratch AMIs booting Ubuntu Linux with a ZFS root file system.

One of the precipitating events that spurred our decision to use root ZFS in AWS was a blog post by Scott Emmons who detailed how to build Amazon AMIs running with a root ZFS filesystem for both the Ubuntu and Debian Linux distributions.

We were already using ZFS on data volumes, but not for the root filesystem, so when I was looking to build trusted base images for a recent AWS infrastructure project, I decided to use Scott’s detailed post of the manual steps, cross referenced with Canonical’s own documentation as the basis for an automated build using HashiCorp’s Packer – in codified build processes we trust!

The reasons for wanting a ZFS root file system are well described in Scott’s post and across the internet (as is why ZFS is preferable to BTRFS, for example!). Similarly, the reasons for wanting to scratch-build AMIs instead of using the prebuilt ones are well understood at this point – so I’m not going to rehash either argument here.

In this example, we’re building images for Ubuntu “Yakkety” (16.10), though it’s easy enough to adapt for 16.04 – the latest LTS Ubuntu release – or Debian. The Packer template and accompanying scripts for both “Yakkety” and “Xenial” are available on GitHub.

Post external references

  1. 1
  2. 2