Zfs child dataset file not mounted

Hello,

I have a parent dataset ‘outerdir’ which has a child dataset ‘innerdir’ which has a file ‘somefile.txt’. I mounted the ‘outerdir’ on the host filesystem and the file (somefile.txt) is accessible on the host file system. However when i passeded the outerdir to LXD instance, the file in the child dataset is not visible.

Following are the steps i followed. The zfs pool is rpool and LXD container is test2:

$ zfs create rpool/outerdir
$ zfs create rpool/outerdir/innerdir

$ zfs get mounted rpool/outerdir/innerdir
NAME                     PROPERTY  VALUE    SOURCE
rpool/outerdir/innerdir  mounted   yes      -

$ zfs get mountpoint rpool/outerdir/innerdir
NAME                     PROPERTY    VALUE               SOURCE
rpool/outerdir/innerdir  mountpoint  /outerdir/innerdir  inherited from rpool

#create file
$ touch /outerdir/innerdir/somefile.txt

#File is accessible on the host
$ ls /outerdir/innerdir -1             
somefile.txt

#pass outerdir to container
$ lxc config device add test2 mystorage disk source=/outerdir path=/outerdir
Device mystorage added to test2

#File is not accessible in the container
$ lxc exec test2 -- ls /outerdir/innerdir/somefile.txt
ls: cannot access '/outerdir/innerdir/somefile.txt': No such file or directory

How do i get files to show up in the container?

Try setting recursive=true on the disk device, see

https://documentation.ubuntu.com/lxd/en/latest/reference/devices_disk/#device-options

Thanks, that worked.

1 Like