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

Dean Henrichsmeyer
on 6 November 2015

Using LXD with a file-based ZFS pool on Ubuntu Wily


Ubuntu 15.10 (Wily) comes natively with some technology previously only available in PPAs. LXD is a container hypervisor that enables and facilitates extensive and powerful management of LXC containers. It’s great for dense deployments, development environments, and specifically workloads that need to be as performant as possible… ones where you don’t want the overhead of heavy virtualization.

At any rate, I wanted to play with both ZFS and LXD on my laptop that has only one disk so I thought I’d share the quick set of instructions I used. Thanks to the LXD team at Canonical for their pointers.

First, install the ZFS utilities

sudo apt install zfsutils-linux

If the ZFS module isn’t loaded automatically, you can load it with:

sudo modprobe zfs

Then create a file that you’ll use to back the zpool. It’s important to note here that if you use eCryptfs (FDE is your friend), you can’t use sparse files (enjoy your encrypted zeros) so this will take a long time. Anyway, to create a sparse file that can grow to 100GB, use something like:

truncate -s 100G filename.img

Then you create a zpool using that file with:

sudo zpool create nameofzpool /absolute/path/to/filename.img

When you’re finished you should be able to type ‘sudo zpool list’ and see something like

NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
pool 99.5G 2.83G 96.7G - 1% 2% 1.00x ONLINE -

Next you need to tell LXD to use that for its storage. You do that with:

lxc config set storage.zfs_pool_name nameofzpool

As of right now, those zpools are not automatically added at boot so you’ll want to place something like the example below in rc.local or your initialization location of choice. The path should be to the location of where you stored the filename.img.

zpool import -d /path/to/directory/ -a

Ideally you would have a separate device to create your zpool on. In the absence of that, at least you can exercise LXD and ZFS on a single disk to see how things work. Enjoy the speed and power of LXD.

Related posts


Felipe Vanni
20 November 2024

Join Canonical in London at Dell Technologies Forum

AI Storage

Canonical is excited to be partnering with Dell Technologies at the upcoming Dell Technologies Forum – London, taking place on 26th November. This prestigious event brings together industry leaders and technology enthusiasts to explore the latest advancements and solutions shaping the digital landscape. Register to Dell Technologies Forum ...


Canonical
15 November 2024

Canonical announces the first MicroCloud LTS release 

Cloud and server Article

Canonical announces the first MicroCloud LTS release. MicroCloud 2.1.0 LTS features support for single-node deployments, improved security posture, and more flexibility during the initialization process. ...


Felipe Vanni
13 November 2024

Join Canonical in Paris at Dell Technologies Forum

AI Article

Canonical is thrilled to be joining forces with Dell Technologies at the upcoming Dell Technologies Forum – Paris, taking place on 19 November. This premier event brings together industry leaders and technology enthusiasts to explore the latest advancements and solutions shaping the digital landscape. Register to Dell Technologies Forum – ...