ZFS Dataset /zroot mounted by default

Hello guys,

I'm discovering FreeBSD and ZFS, I recently installed FreeBSD-RELEASE-14.2 on my home server.
It may be a stupid question, but i dont understand why I have a /zroot directory, a quick search lead me to https://forums.freebsd.org/threads/question-about-partition-zroot.74370/ and if I understand well, /zroot should not be mounted.
But it is.

I have 1 disk, I let the pool name on default value "zroot" and used AutoZFS option during the install process.

Its almost a fresh install : I only updated it to FreeBSD-RELEASE-14.2-p2, created an encrypted dataset /zroot/myuser/safe and installed sysutils/iocage.

Code:
# ls -l /
total 100
-rw-r--r--   2 root wheel 1011 Nov 29 10:58 .cshrc
-rw-r--r--   2 root wheel  495 Nov 29 10:58 .profile
-r--r--r--   1 root wheel 6109 Nov 29 11:42 COPYRIGHT
drwxr-xr-x   2 root wheel   49 Mar 29 18:16 bin
drwxr-xr-x  15 root wheel   71 Mar 29 18:18 boot
dr-xr-xr-x  10 root wheel  512 Mar 30 21:10 dev
-rw-------   1 root wheel 4096 Mar 30 21:11 entropy
drwxr-xr-x  30 root wheel  111 Mar 30 20:23 etc
drwxr-xr-x   3 root wheel    3 Mar 29 18:10 home
drwxr-xr-x   4 root wheel   78 Nov 29 11:20 lib
drwxr-xr-x   3 root wheel    5 Nov 29 10:57 libexec
drwxr-xr-x   2 root wheel    2 Nov 29 10:54 media
drwxr-xr-x   3 root wheel    3 Mar 29 18:10 mnt
drwxr-xr-x   2 root wheel    2 Nov 29 10:54 net
dr-xr-xr-x   2 root wheel    2 Nov 29 10:54 proc
drwxr-xr-x   2 root wheel  150 Nov 29 11:15 rescue
drwxr-x---   2 root wheel    8 Mar 31 23:00 root
drwxr-xr-x   2 root wheel  150 Nov 29 11:23 sbin
lrwxr-xr-x   1 root wheel   11 Nov 29 10:54 sys -> usr/src/sys
drwxrwxrwt   6 root wheel    6 Mar 31 14:43 tmp
drwxr-xr-x  16 root wheel   16 Nov 29 10:54 usr
drwxr-xr-x  24 root wheel   24 Mar 30 21:10 var
drwxr-xr-x   2 root wheel    2 Mar 29 17:56 zroot

Code:
# mount
zroot/ROOT/default on / (zfs, local, noatime, nfsv4acls)
devfs on /dev (devfs)
/dev/gpt/efiboot0 on /boot/efi (msdosfs, local)
zroot/tmp on /tmp (zfs, local, noatime, nosuid, nfsv4acls)
zroot/home on /home (zfs, local, noatime, nfsv4acls)
zroot on /zroot (zfs, local, noatime, nfsv4acls)
zroot/var/log on /var/log (zfs, local, noatime, noexec, nosuid, nfsv4acls)
zroot/var/audit on /var/audit (zfs, local, noatime, noexec, nosuid, nfsv4acls)
zroot/usr/ports on /usr/ports (zfs, local, noatime, nosuid, nfsv4acls)
zroot/var/mail on /var/mail (zfs, local, nfsv4acls)
zroot/var/crash on /var/crash (zfs, local, noatime, noexec, nosuid, nfsv4acls)
zroot/usr/src on /usr/src (zfs, local, noatime, nfsv4acls)
zroot/home/myuser on /home/myuser (zfs, local, noatime, nfsv4acls)
zroot/var/tmp on /var/tmp (zfs, local, noatime, nosuid, nfsv4acls)

Code:
# zfs list
NAME                                        USED  AVAIL  REFER  MOUNTPOINT
zroot                                      2.24G  1.75T    96K  /zroot
zroot/ROOT                                 1.41G  1.75T    96K  none
zroot/ROOT/14.2-RELEASE_2025-03-29_181624     8K  1.75T  1.02G  /
zroot/ROOT/default                         1.41G  1.75T  1.40G  /
zroot/home                                  472K  1.75T    96K  /home
zroot/home/myuser                          376K  1.75T   172K  /home/myuser
zroot/home/myuser/safe                     204K  1.75T   204K  /home/myuser/safe
zroot/tmp                                    96K  1.75T    96K  /tmp
zroot/usr                                   852M  1.75T    96K  /usr
zroot/usr/ports                              96K  1.75T    96K  /usr/ports
zroot/usr/src                               852M  1.75T   852M  /usr/src
zroot/var                                  1008K  1.75T    96K  /var
zroot/var/audit                              96K  1.75T    96K  /var/audit
zroot/var/crash                              96K  1.75T    96K  /var/crash
zroot/var/log                               404K  1.75T   404K  /var/log
zroot/var/mail                              220K  1.75T   220K  /var/mail
zroot/var/tmp                                96K  1.75T    96K  /var/tmp

And there is the bsdinstall_log (It was not my first installation attempt, as you can see)
Code:
# cat /var/log/bsdinstall_log | grep zroot
DEBUG: Checking zroot against zroot
DEBUG: Pool zroot already taken
DEBUG: zfs_create_boot: poolname=[zroot] vdev_type=[]
DEBUG: zfs_create_boot: zpool destroy "zroot"
cannot open 'zroot': no such pool
DEBUG: zfs_create_boot: zpool create -o altroot=/mnt -O compress=lz4 -O atime=off -m none -f "zroot"   nda0p4
DEBUG: zfs_create_boot: zfs create -o mountpoint=none "zroot/ROOT"
DEBUG: zfs_create_boot: zfs create -o mountpoint=/ "zroot/ROOT/default"
DEBUG: zfs_create_boot: zfs create -o mountpoint=/home "zroot/home"
DEBUG: zfs_create_boot: zfs create -o mountpoint=/tmp -o exec=on -o setuid=off "zroot/tmp"
DEBUG: zfs_create_boot: zfs create -o mountpoint=/usr -o canmount=off "zroot/usr"
DEBUG: zfs_create_boot: zfs create -o setuid=off "zroot/usr/ports"
DEBUG: zfs_create_boot: zfs create  "zroot/usr/src"
DEBUG: zfs_create_boot: zfs create -o mountpoint=/var -o canmount=off "zroot/var"
DEBUG: zfs_create_boot: zfs create -o exec=off -o setuid=off "zroot/var/audit"
DEBUG: zfs_create_boot: zfs create -o exec=off -o setuid=off "zroot/var/crash"
DEBUG: zfs_create_boot: zfs create -o exec=off -o setuid=off "zroot/var/log"
DEBUG: zfs_create_boot: zfs create -o atime=on "zroot/var/mail"
DEBUG: zfs_create_boot: zfs create -o setuid=off "zroot/var/tmp"
DEBUG: zfs_create_boot: zfs set "mountpoint=/zroot" "zroot"
DEBUG: zfs_create_boot: zpool set bootfs="zroot/ROOT/default" "zroot"
DEBUG: zfs_create_boot: Configuring zpool.cache for zroot...
DEBUG: zfs_create_boot: zpool set cachefile="/mnt/boot/zfs/zpool.cache" "zroot"
DEBUG: zfs_create_boot: zfs set "canmount=noauto" "zroot/ROOT/default"

To be sure I have not done any mistake, I tried a fresh install on a VM, and there's also that /zroot directory, and zroot is mounted on /zroot.

Is it normal ? Is it a new freebsd installer's behavior ?
Should I unmount /zroot ?

Sorry for my poor knowledge,
Thanks.
 
i dont understand why I have a /zroot directory
DEBUG: zfs_create_boot: zfs set "mountpoint=/zroot" "zroot"
I am not sure why it did that.

Apparently to have newly created datasets a mount point to inherit:

/usr/libexec/bsdinstall/zfsboot
Code:
1393    #
1394    # Set a mountpoint for the root of the pool so newly created datasets
1395    # have a mountpoint to inherit
1396    #
1397    f_dprintf "$funcname: Setting mountpoint for root of the pool..."
1398    f_eval_catch $funcname zfs "$ZFS_SET" \
1399           "mountpoint=/$zroot_name" "$zroot_name" || return $FAILURE
 
This may not help you, but I've never been much of a fan of the way the installer handles ZFS partitions, it's for this very reason why I prefer to handle all that myself. Anyway, some things look bizarre indeed, having several datasets mounted on / is obviously not the best of setups.

You may want to try and change (or remove) the mountpoint for some of those filesystems, see also zfs-set(8), zfsprops(7) and zfsconcepts(7) for that. You should be good with # zfs set mountpoint=none zroot, and for those other systems as well. Optionally use -u and have the changes apply after a reset.
 
Thank you for the answers, you made it a bit clearer : it's a normal behavior of bsdinstall.

I used the default setup because I was not comfortable with ZFS, ans I think I'll just set zroot's mountpoint to none.

One of the adverse effects with that /zroot mountpoint was iocage "initialization" : it created a dataset zroot/iocage and mounted it on /zroot/iocage.
But anyway, I wanted iocage jails on encrypted datasets, so i deleted iocage's datasets, and created a new dataset zroot/iocage with encryption and a custom mountpoint, then iocage made the child datasets.

Solved
 
I've always used the auto-installer ZFS because I don't have special needs, that mounted directory /zroot with nothing in there (with 13.x and now with 14.x) has always been there for me. Am I doing something wrong from the beginning?

For example this is a VM 14.2 (but that's also true for all my FreeBSD system) :
Code:
> zfs list -r zroot | head -n 2
NAME                                        USED  AVAIL  REFER  MOUNTPOINT
zroot                                      2.14G  14.8G    96K  /zroot
>  mount | grep "\/zroot"
zroot on /zroot (zfs, local, noatime, nfsv4acls)
>  ls -l /zroot
total 0

It may be a stupid question, but i dont understand why I have a /zroot directory, a quick search lead me to https://forums.freebsd.org/threads/question-about-partition-zroot.74370/ and if I understand well, /zroot should not be mounted.
if you look at the response from SirDice , if I am not mistaken his dir /zroot is actually mounted.
 
if you look at the response from SirDice , if I am not mistaken his dir /zroot is actually mounted.
Oh right.
Actually I have misread that message, and as he said that "zroot should not be mounted", my brain has probably been tricked and has not seen that line in his mount | grep zroot output.
Code:
zroot on /zroot (zfs, local, noatime, nfsv4acls)

So, everything seems fine :)
 
So, everything seems fine :)
I am not a pro, so I just wanted to let you know that my systems are just like yours and I never had any problem.
But reading the comments before was kind of intriguing that's why I asked the question "Am I doing something wrong?", it was a real question.
 
I'm just like you, not a pro, it's my third week on FreeBSD 😄 (and I love it)
If I understand well, you're not doing anything wrong, and having a /zroot directory is normal if you used the AutoZFS option from bsdinstall, it's the normal behavior of the /usr/libexec/bsdinstall/zfsboot script.
Code:
1393    #
1394    # Set a mountpoint for the root of the pool so newly created datasets
1395    # have a mountpoint to inherit
1396    #
1397    f_dprintf "$funcname: Setting mountpoint for root of the pool..."
1398    f_eval_catch $funcname zfs "$ZFS_SET" \
1399           "mountpoint=/$zroot_name" "$zroot_name" || return $FAILURE

It's just a bit weird in my opinion.
 
Back
Top