ZFS ZFS: mounting dataset on non empty directory

Hello all,

I was recently surprised to see that it is possible to define a not empty directory as mountpoint for a dataset.
for example :

Bash:
$ mkdir /var/dir_not_empty
$ touch /var/dir_not_empty/test
$ ls -l /var/dir_not_empty/
total 1
-rw-r--r--  1 root  wheel  0 Nov 25 15:59 test
$ zfs create -o mountpoint=/var/dir_not_empty zroot/test_dataset
$ ls -l /var/dir_not_empty/
total 0
$ zfs destroy zroot/test_dataset
$ ls -l /var/dir_not_empty/
total 1
-rw-r--r--  1 root  wheel  0 Nov 25 15:59 test

Is it a freebsd feature or a bug ?

If I refer to Oracle doc, this is not possible on another ZFS implementation.
Thank you in advance for all your answers.
 
After some little research, i found that:
- Linux makes the choice to keep consistency with the other ZFS implementations (overlay = OFF by default) but leaves the choice to change this option if needed.
- FreeBSD remains consistent with its OS which by default allows it with all other filesystems AND does not support this option at all.
- Oracle doesn't allow overlay by default.


Linux man zfs ----> https://manpages.debian.org/unstable/zfsutils-linux/zfs.8.en.html

- overlay=off|on
Allow mounting on a busy directory or a directory which already contains files or directories.
This is the default mount behavior for Linux file systems.
For consistency with OpenZFS on other platforms overlay mounts are off by default.
Set to on to enable overlay mounts.


FreeBSD man ZFS ----> https://www.freebsd.org/cgi/man.cgi?zfs(8)
-O Perform an overlay mount. Overlay mounts are not supported on FreeBSD.

Oracle:
ZFS Doc ----> https://docs.oracle.com/cd/E19253-01/819-5461/gamns/index.html
By default, ZFS does not allow mounting on top of a nonempty directory. To force a mount on top of a nonempty directory, you must use the -O option. For example:
 
Back
Top