Skip to main content

Your submission was sent successfully! Close

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

Thank you for contacting us. A member of our team will be in touch shortly. Close

  1. Blog
  2. Article

Dustin Kirkland
on 16 February 2016

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


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
/lib/modules/4.4.0-4-generic/kernel/zfs/zfs/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
NAME   SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
lxd   1.98G   450K  1.98G         -     0%     0%  1.00x  ONLINE  -
$ sudo zpool status
  pool: lxd
 state: ONLINE
  scan: none requested
config:

        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 http://cloud-images.ubuntu.com
Progress: 48 %
Validating the GPG signature of /tmp/tmpa71cw5wl/download.json.asc
Downloading the image.
Image manifest: http://cloud-images.ubuntu.com/server/releases/trusty/release-20160201/ubuntu-14.04-server-cloudimg-amd64.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 | 10.0.3.130 (eth0) |      | NO        |         0 |
+-------------------------+---------+-------------------+------+-----------+-----------+
| fictive-noble           | RUNNING | 10.0.3.91 (eth0)  |      | NO        |         0 |
+-------------------------+---------+-------------------+------+-----------+-----------+
| interprotoplasmic-essie | RUNNING | 10.0.3.242 (eth0) |      | NO        |         0 |
+-------------------------+---------+-------------------+------+-----------+-----------+
| nondamaging-cain        | RUNNING | 10.0.3.9 (eth0)   |      | NO        |         0 |
+-------------------------+---------+-------------------+------+-----------+-----------+
| untreasurable-efrain    | RUNNING | 10.0.3.89 (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.

Related posts


David Callé
9 February 2018

Tutorial: Setup a ZFS storage pool

Cloud and server Article

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 faulty hardware or unify an array of disks into a single storage unit, it’s a good fit for both personal devices and enterprise stacks. In this short tutorial, you ...


Canonical
3 May 2021

Ubuntu 16.04 LTS transitions to Extended Security Maintenance (ESM)

Cloud and server Article

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 maintenance (ESM) support phase at the end of April 2021 from its standard, five-year maintenance window for Ubuntu long term support (LTS) releases. Xenial Xerus is still supported until ...


Igor Ljubuncic
23 March 2021

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

Cloud and server Article

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 you’re a snap developer, and you have built or based your snaps on Ubuntu 16.04 (Xenial) packages and libraries, you may want to know how this milestone ...