Mount zfs dataset in LXC

(Pgauret) #1

I am running LXC with unprivileged containers on a ZFS backend.
I’d now like to split the container’s rootfs from the application data using two separate zfs datasets.
For example ‘rpool/LXC/containers/test’ for the container rootfs (already working) and ‘rpool/LXC/data/test’ for the data volume. This allows me to easily upgrade the container by destroying & recreating it based on a newer template, and just re-mounting the data volume.

For now the best I’ve found would be to mount the ‘rpool/LXC/containers/test’ dataset on the host and then have a bind mount in the LXC container through a lxc.mount.entry. What I’d prefer is to directly mount the dataset in the container - however something like ‘lxc.mount.entry = zfs:rpool/LXC/data/test’ does not work.

Any ideas ?

(On a related note, this is similiar to what LXD can do through ‘lxc storage’ but I’m stuck with LXC on this system)

(Stéphane Graber) #2

lxc.mount.entry = rpool/LXC/containers/test data/test zfs rw,zfsutil,mntpoint=/data/test 0 0

That may work.