Filesystem inside Container?

My question may be stupid

When using ZFS as storage, what file system is used inside a container?
Does it inherit from the host, meaning also from ZFS?
Is it not EXT4 or another one?

Are you talking containers, or VMs?

If it’s a container, then it’s a zfs dataset on the host. The container has this mounted inside its chroot environment. It sees no block device.

It’s rather the opposite, what is the file system if on the host it’s ZFS? Is it also ZFS in the container?

I’m not sure how I can make it clearer than this:

  • If you create a zfs storage pool in incus, it is using ZFS on the host
  • When a container is created, a new dataset is created for it on the host
  • The filesystem for the container is really just a view of (a subset of) the host’s filesystem - in this case, a zfs dataset on the host
  • In other words, the filesystem that the container sees is simply part of the filesystem on the host.

For example:

# incus storage list
| default | zfs    | zfs/lxd |             | 10      | CREATED |

I have a container called “nfsen”. From the host side:

# zfs list zfs/lxd/containers/nfsen
NAME                       USED  AVAIL     REFER  MOUNTPOINT
zfs/lxd/containers/nfsen  34.7G   193G     34.7G  legacy

# ls -l /var/lib/incus/containers/nfsen
lrwxrwxrwx 1 root root 53 Mar 20 22:50 /var/lib/incus/containers/nfsen -> /var/lib/incus/storage-pools/default/containers/nfsen

# ls -l /var/lib/incus/storage-pools/default/containers/nfsen
total 26
-r--------  1 root root 7021 Mar 21 10:56 backup.yaml
-rw-r--r--  1 root root 1050 Jun 10  2020 metadata.yaml
drwxr-xr-x 22 root root   22 Mar 21 10:55 rootfs
drwxr-xr-x  2 root root    7 Jun 10  2020 templates

# ls -li /var/lib/incus/storage-pools/default/containers/nfsen/rootfs/etc/hosts
706 -rw-r--r-- 1 root root 221 Jun  5  2020 /var/lib/incus/storage-pools/default/containers/nfsen/rootfs/etc/hosts

Inside the container, a file such as /etc/hosts is actually /var/lib/incus/storage-pools/default/containers/nfsen/rootfs/etc/hosts on the host system, which is the file rootfs/etc/hosts within the zfs dataset zfs/lxd/containers/nfsen

The container’s view of the same file:

# incus shell nfsen
root@nfsen:~# mount | grep 'on / '
zfs/lxd/containers/nfsen on / type zfs (rw,relatime,idmapped,xattr,posixacl,casesensitive)
root@nfsen:~# ls -li /etc/hosts
706 -rw-r--r-- 1 root root 221 Jun  5  2020 /etc/hosts

What I’m trying to say is: it makes no sense to talk about the file system in the container being something other than the file system in the host, because they are the same file system.

Perfect, that’s exactly the answer I was expecting, sorry for the confusion. I have a MariaDB server in a container, and I’ve seen that it needs to be fine-tuned to get better performance when we’re under ZFS