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)
I mounted datasets, configured in profiles the passtrough of mountpoints via type: disk, than created sub-container, and done the same for it. It seemed to work, but after reboot, I can’t find my data.
Dataset1 was mounted at host to /mnt1. /mnt1 was passed to container via profile as, also, /mnt1 and then passed to a sub-container as (also) /mnt1. So the data ought to be found either in host’s /mnt1, where Dataset1 is mounted or in ${CONTAINER_DATASET_MOUNTPOINT}/rootfs/mnt1 or in ${SUB_CONTAINER_DATASET_MOUNTPOINT}/rootfs/mnt1, if /mnt1 was not really pased to sub-container. But after reboot Dataset1 and ${CONTAINER_DATASET_MOUNTPOINT}/rootfs/mnt1 and ${SUB_CONTAINER_DATASET_MOUNTPOINT}/rootfs/mnt1 are empty. Seems all data was writen in tmpfs instead of zfs.
(Data was not critical, and there is a backup.)
So, as I see passing mounted zfs dataset through container to sub-container via:
my_dataset:
path: /container_mnt
source: /hosts_mnt
type: disk
and then via:
my_dataset:
path: /sub_container_mnt
source: /container_mnt
type: disk