Your submission was sent successfully! Close

You have successfully unsubscribed! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates about Ubuntu and upcoming events where you can meet our team.Close

ZFS is *the* FS for Containers in Ubuntu 16.04!

This article was last updated 4 years ago.

Ubuntu 16.04 LTS (Xenial) is only a few short weeks away, and with it comes one of the most exciting new features Linux has seen in a very long time…

ZFS — baked directly into Ubuntu — supported by Canonical.

What is ZFS?

ZFS is a combination of a volume manager (like LVM) and a filesystem (like ext4, xfs, or btrfs).

ZFS one of the most beloved features of Solaris, universally coveted by every Linux sysadmin with a Solaris background. To our delight, we’re happy to make to OpenZFS available on every Ubuntu system. Ubuntu’s reference guide for ZFS can be found here, and these are a few of the killer features:

  • snapshots
  • copy-on-write cloning
  • continuous integrity checking against data corruption
  • automatic repair
  • efficient data compression

These features truly make ZFS the perfect filesystem for containers.

What does “support” mean?

You’ll find zfs.ko automatically built and installed on your Ubuntu systems. No more DKMS-built modules!

$ locate zfs.ko

You’ll see the module loaded automatically if you use it.

$ lsmod | grep zfs
zfs                  2801664  11
zunicode              331776  1 zfs
zcommon                57344  1 zfs
znvpair                90112  2 zfs,zcommon
spl                   102400  3 zfs,zcommon,znvpair
zavl                   16384  1 zfs
  • The user space zfsutils-linux package will be included in Ubuntu Main, with security updates provided by Canonical (as soon as this MIR is completed).
  • As always, industry leading, enterprise class technical support is available from Canonical with Ubuntu Advantage services.

How do I get started?

It’s really quite simple! Here’s a few commands to get you up and running with ZFS and LXD in 60 seconds or less.

First, make sure you’re running Ubuntu 16.04 (Xenial).

$ head -n1 /etc/issue
Ubuntu Xenial Xerus (development branch) \n \l

Now, let’s install lxd and zfsutils-linux, if you haven’t already:

$ sudo apt install lxd zfsutils-linux

Next, let’s use the interactive lxd init command to setup LXD and ZFS. In the example below, I’m simply using a sparse, loopback file for the ZFS pool. For best results (and what I use on my laptop and production servers), it’s best to use a raw SSD partition or device.

$ sudo lxd init
Name of the storage backend to use (dir or zfs): zfs
Create a new ZFS pool (yes/no)? yes
Name of the new ZFS pool: lxd
Would you like to use an existing block device (yes/no)? no
Size in GB of the new loop device (1GB minimum): 2
Would you like LXD to be available over the network (yes/no)? no 
LXD has been successfully configured.

We can check our ZFS pool now:

$ sudo zpool list
lxd   1.98G   450K  1.98G         -     0%     0%  1.00x  ONLINE  -
$ sudo zpool status
  pool: lxd
 state: ONLINE
  scan: none requested

        NAME                    STATE     READ WRITE CKSUM
        lxd                     ONLINE       0     0     0
          /var/lib/lxd/zfs.img  ONLINE       0     0     0
errors: No known data errors
$ lxc config get storage.zfs_pool_name
storage.zfs_pool_name: lxd

Finally, let’s import the Ubuntu LXD image, and launch a few containers. Note how fast containers launch, which is enabled by the ZFS cloning and copy-on-write features:

$ newgrp lxd
$ lxd-images import ubuntu --alias ubuntu
Downloading the GPG key for
Progress: 48 %
Validating the GPG signature of /tmp/tmpa71cw5wl/download.json.asc
Downloading the image.
Image manifest:
Image imported as: 54c8caac1f61901ed86c68f24af5f5d3672bdc62c71d04f06df3a59e95684473
Setup alias: ubuntu
$ for i in $(seq 1 5); do lxc launch ubuntu; done
$ lxc list
|          NAME           |  STATE  |       IPV4        | IPV6 | EPHEMERAL | SNAPSHOTS |
| discordant-loria        | RUNNING | (eth0) |      | NO        |         0 |
| fictive-noble           | RUNNING | (eth0)  |      | NO        |         0 |
| interprotoplasmic-essie | RUNNING | (eth0) |      | NO        |         0 |
| nondamaging-cain        | RUNNING | (eth0)   |      | NO        |         0 |
| untreasurable-efrain    | RUNNING | (eth0)  |      | NO        |         0 |

We’ve written a short reference guide to help with getting started, and understanding the ZFS terminology. This touches the basics on setting up ZFS pools as well as creating and using ZFS file systems.

If you are new to ZFS, I recommend having a look at the reference guide to get you started.

Ubuntu cloud

Ubuntu offers all the training, software infrastructure, tools, services and support you need for your public and private clouds.

Newsletter signup

Get the latest Ubuntu news and updates in your inbox.

By submitting this form, I confirm that I have read and agree to Canonical's Privacy Policy.

Related posts

Tutorial: Setup a ZFS storage pool

ZFS is a handy way of pooling disks together into a single filesystem. Whether you want to transparently mirror content across disks to preserve yourself from...

Ubuntu 16.04 LTS transitions to Extended Security Maintenance (ESM)

This article was updated in September 2021 to reflect the new lifecycle of 16.04. Ubuntu 16.04 LTS ‘Xenial Xerus’ transitions into the extended security...

How does Ubuntu 16.04 entering Extended Security Maintenance (ESM) affect snap publishers?

At the end of April, Ubuntu 16.04 LTS will reach the end of its five years of mainstream support and enter the Extended Security Maintenance (ESM) phase. If...