ZFS Boot environment and filesystem hierarchy

On my zpool ZT I created my own dataset hierarchy ie
ZT/ROOT/default/usr 39.0G 168G 1.33G none
ZT/ROOT/default/usr/home 22.3G 168G 22.1G /ZT/usr/home
ZT/ROOT/default/var 21.0G 168G 2.41M none
ZT/ROOT/default/var/audit 96K 168G 96K /ZT/var/audit

whereas freebsd installer uses:
ZT/usr 39.0G 168G 1.33G none
ZT/usr/home 22.3G 168G 22.1G /ZT/usr/home
ZT/default/var 21.0G 168G 2.41M none
ZT/var/audit 96K 168G 96K /ZT/var/audit

The question i have is :
-Am i'm doing something wrong ?
-Can i safely use freebsd boot-environments ?
 
I would guess you may run into trouble.
zpool history on one of my systems. Pay close attention to the mountpoint and canmount options.
Boot environments work based on "if there is not an explicit data set mounted, it comes under the root dataset".
See zroot/usr dataset? Has canmount off. That means /usr/local falls under the root dataset. Also means /usr/bin also falls under the root dataset.
Code:
2019-12-06.07:34:53 zpool create -o altroot=/mnt -O compress=lz4 -O atime=off -m none -f zroot ada0p3
2019-12-06.07:34:53 zfs create -o mountpoint=none zroot/ROOT
2019-12-06.07:34:53 zfs create -o mountpoint=/ zroot/ROOT/default
2019-12-06.07:34:53 zfs create -o mountpoint=/tmp -o exec=on -o setuid=off zroot/tmp
2019-12-06.07:34:53 zfs create -o mountpoint=/usr -o canmount=off zroot/usr
2019-12-06.07:34:53 zfs create zroot/usr/home
2019-12-06.07:34:53 zfs create -o setuid=off zroot/usr/ports
2019-12-06.07:34:53 zfs create zroot/usr/src
2019-12-06.07:34:53 zfs create -o mountpoint=/var -o canmount=off zroot/var
2019-12-06.07:34:53 zfs create -o exec=off -o setuid=off zroot/var/audit
2019-12-06.07:34:53 zfs create -o exec=off -o setuid=off zroot/var/crash
2019-12-06.07:34:53 zfs create -o exec=off -o setuid=off zroot/var/log
2019-12-06.07:34:53 zfs create -o atime=on zroot/var/mail
2019-12-06.07:34:53 zfs create -o setuid=off zroot/var/tmp
2019-12-06.07:34:53 zfs set mountpoint=/zroot zroot
2019-12-06.07:34:53 zpool set bootfs=zroot/ROOT/default zroot
2019-12-06.07:34:53 zpool set cachefile=/mnt/boot/zfs/zpool.cache zroot
2019-12-06.07:34:58 zfs set canmount=noauto zroot/ROOT/default
 
You aren't doing anything wrong here. I use similar layout, where all datasets are part of poolname/default.
And you can safely use boot-environments with such layout, with complete snapshot of everything
 
whereas freebsd installer uses:
ZT/usr 39.0G 168G 1.33G none
ZT/usr/home 22.3G 168G 22.1G /ZT/usr/home
ZT/default/var 21.0G 168G 2.41M none
ZT/var/audit 96K 168G 96K /ZT/var/audit
This is strange. I used the installer several times in the past few months and it always created $pool/ROOT/default for / and a bunch of filesystems outside of ROOT.
I never saw anything like ZT/default/var.

Also, regarding your manual setup.
Are you really sure that you want homes and various databases that live under /var to be parts of boot environments?

Suppose you upgraded to a newer BE. You used it for some time and noticed a regression. You decided to go back to the previous BE.
Meanwhile, you did a bunch of modifications in your home. Changed configuration files, edited some important documents, etc.
Now, if you simply discard the problematic BE you would lose all those changes.
You'd have to be careful and somehow move those changes to the current BE.
 
This is strange. I used the installer several times in the past few months and it always created $pool/ROOT/default for / and a bunch of filesystems outside of ROOT.
I never saw anything like ZT/default/var.
Agreed. The default installation would create a zroot/var, not zroot/default/var.

Apart from zroot/home (I added that one myself) this is what a default install would create:
Code:
dice@maelcum:~ % zfs list -o name,mountpoint,canmount
NAME                MOUNTPOINT  CANMOUNT
zroot               /zroot      on
zroot/ROOT          none        on
zroot/ROOT/default  /           noauto
zroot/tmp           /tmp        on
zroot/usr           /usr        off
zroot/usr/home      /usr/home   on
zroot/usr/ports     /usr/ports  on
zroot/usr/src       /usr/src    on
zroot/var           /var        off
zroot/var/audit     /var/audit  on
zroot/var/crash     /var/crash  on
zroot/var/log       /var/log    on
zroot/var/mail      /var/mail   on
zroot/var/tmp       /var/tmp    on

zroot/usr and zroot/var have a mountpoint set but also have canmount=off.
 
To be more in line with the default install i renamed the datasets
Code:
zfs rename ZT/ROOT/default/usr ZT/usr                          
zfs rename ZT/ROOT/default/var ZT/var
Then i used bectl
Code:
zpool checkpoint ZT
bectl activate default
 
Back
Top