Ubuntu server 18.04 with ZFS root?

I’ve been using proxmox for a long time, and I only need LXC. I have played around with LXD regularly for years and really want to use it instead.

But my problem is that all the servers only has two drives each, and I think I would like to continue using ZFS.

Sadly the Ubuntu server 18.04 installer does not support ZFS.

What would you guys recommend I do?

You would install Ubuntu on ext4 as normal.
In another partition you would format as ZFS and keep there the containers. In fact, you can keep the partition unformatted and lxd init will format for you.

1 Like

Do you know if there is any downsides to doing it that way? :slight_smile:

There are no downsides that I can think of.

It is feasible to install Ubuntu 18.04 with the root filesystem on ZFS,
https://github.com/zfsonlinux/zfs/wiki/Ubuntu-18.04-Root-on-ZFS
However, the process is quite involved and it has not been implemented in the Ubuntu installer yet.

In terms of what LXD would prefer to have, that would be any of the good supported filesystems from the list, https://lxd.readthedocs.io/en/stable-2.0/storage-backends/
It’s just the storage of the container that has to be in a suitable filesystem.

I ended up with the following:

  1. Created two partitions on each drive and then set up an md raid 1.
  2. Installed zfsutils and created a pool consisting of one partition from each drive and used the drive id when doing so.
  3. Used lxd init and specified the pool.
  4. Happiness!
  5. Reboot.
  6. Pool is gone…sadness

Steps:

zpool create -o ashift=12 -O atime=off -O canmount=off -O compression=lz4 -O normalization=formD rpool mirror /dev/disk/by-id/ata-WDCThis text will be hidden_WD10EARS-22Y5B1_WD-WCAV5H111111-part2 /dev/disk/by-id/ata-WDC_WD10EARS-22Y5B1_WD-WCAV5H222222-part2

I then set up LXD to use the pool, created a container and started using it.

root@zfstest:~# zfs list
NAME                                                                            USED  AVAIL  REFER  MOUNTPOINT
rpool                                                                           423M   806G    96K  none
rpool/containers                                                               10.8M   806G    96K  none
rpool/containers/c1                                                            10.8M   806G   411M  /var/lib/lxd/storage-pools/default/containers/c1
rpool/custom                                                                     96K   806G    96K  none
rpool/deleted                                                                    96K   806G    96K  none
rpool/images                                                                    411M   806G    96K  none
rpool/images/b36ec647e374da4816104a98807633a2cc387488083d3776557081c4d0333618   411M   806G   411M  none
rpool/snapshots                                                                  96K   806G    96K  none

Then I rebooted and got this:

root@zfstest:~# zfs list
no datasets available
root@zfstest:~# zpool list
no pools available

Does anyone know why the pool disappears?

Does zpool import rpool get it back online?

ZFS is supposed to cache the list of pools and re-import them automatically on reboot…

I “normally” always do a zpool export and zpool import just after creating the pool. Just to be sure the cache file is updated. So far it always worked for me :slight_smile:

Turns out that the partitions I created and used for ZFS was extended partitions when I should have used primary partitions.

The pool disappeared after a reboot and could not be imported using zpool import rpool when using extended partitions.

It took me forever to figure out, but it seems to work perfectly now that I switched to primary partitions. :slight_smile:

It is easy to install Ubuntu to ZFS root if you have a MAAS server setup: