Can LXC containers mount a zfs dataset from TrueNAS host?

,

I know i can bind a dataset from truenas to a folder inside an LXC container but, can i mount the truenas dataset as a dataset in the container?

I’m trying to install urbackup with ZFS and that software creates child datasets for each backup. Similarly, it destroys those datasets when the associated backup is deleted. In order to do that, it needs to mount a parent dataset and have permissions to create/destroy zfs datasets inside such parent dataset.

I used to have this properly set in a Jail in truenas core and, in that system, jails had the options “allow_mount”, “allow_mount_zfs” and even “jail_zfs” to achieve this intent.

How can i achieve a similar functionality in Truenas scale 25.10.5?

As a side note, i have tried urbackup in a docker container but the ZFS functionality implementation is unreliable, at least on my system. I’m now trying the LXC container route to replicate the installation i had in Truenas Core which worked perfectly for years.

I dont believe it’s possible. As far as i understand it the lxc can’t load the hosts zfs modules and since it shares the hosts kernel you can’t install them in the lxc.
But i haven’t tried so i may be wrong…
I believe it’s similar to the nivida drivers… the lxc uses the drivers installed on the host…

@LarsR is correct. You can’t mount the dataset directly in an LXC container, but you can mount the filesystem path corresponding to the dataset’s mount point.

Interesting.

If i mount the filesystem path and i install OpenZFS inside the LXC container, would a software inside the container be able to create/destroy child datasets inside that mounted filesystem path?

As written in my first reply i don’t believe you can install openzfs since the lxc shares the hosts kernel and will try to load the hosts kernel modules, similar to gpu drivers. But i may be wrong. You would have to try it…

No, because root inside the LXC container only has permissions for UID/GID 50014 outside the container.

@LarsR i was experimenting earlier today and i was able to install openzfs inside the container. Or i think i did since apt install zfs-utils did not give me any errors.

I tried to mount the parent dataset from within the container and it didn’t find any. This is consistent with what @Samuel_Tai indicated.

What i didn’t try was to mount the parent dataset as a folder inside the container and then try to create child datasets inside those folders.

is this true even if i use the the special host user truenas_container_unpriv_root (UID 2147000001)?

Sorry, I got the number wrong. It’s been a while since I had to use LXC on my system. I don’t think it’s possible to grant this UID/GID capabilities to manage datasets; IIRC, it’s only possible to grant permissions via setfacl or API calls within a mapped path to mimic the host’s root permissions.

I have Jellyfin in Docker and use NFS to serve up the filesystem/share off of the TrueNAS Scale hypervisor. I only allow RO, since I don’t want Jellyfin to manage the files themselves, just read them.

1 Like

@Allan_Wolfe your Jellyfin setup makes sense since it is only reading data and does not need to interact with ZFS snapshots.

In my case, Urbackup needs to read/write data and also create/destroy zfs snapshots.

I’m experimenting a bit and will report back if i’m sucessful.