Bug 274421

Summary: bectl mount does not recognize intermediate canmount=off partitions for deep boot environments
Product: Base System Reporter: tamaru
Component: binAssignee: Kyle Evans <kevans>
Status: New ---    
Severity: Affects Some People CC: bugs, kevans, pat, tamaru
Priority: ---    
Version: 14.0-STABLE   
Hardware: Any   
OS: Any   

Description tamaru 2023-10-12 02:30:37 UTC
I have tested this on FreeBSD 14.0-BETA5.
 
Following is a sample zfs layout to describe the issue.

NAME                      canmount mountpoint
root/ROOT/default         noauto   /
root/ROOT/default/usr     off      /usr
root/ROOT/default/usr/src noauto   /usr/src
root/ROOT/default/usr/obj noauto   /usr/obj
root/home                 on       /home
root/var                  off      /var
root/var/log              on       /var/log

It is close to the "deep boot environment" as described in btctl(8),
but differs in that canmount=off for /root/ROOT/default/usr .

/etc/rc.d/zfsbe correctly mounts this BE as:

Filesystem                 Mounted on
root/ROOT/default          /
root/ROOT/default/usr/src  /usr/src
root/ROOT/default/usr/obj  /usr/obj
root/home                  /home
root/var/log               /var/log

and the contents of /usr such as /usr/bin is included in root/ROOT/default .

However, running
btctl -r root/ROOT mount default
when the system is booted from another BE or pool, it only mounts
as deep as just before the first non- canmount=off partition,
in this case root/ROOT/default only:

Filesystem                Mounted on
root/ROOT/default         /tmp/be_mount.WsGI

and differs from the preferred behavior that zfsbe gives.


When we are at this, bectl create misbehaves in this regard as well. Running
bectl create -r backup
correctly replicates the whole hierarchy, but does not honor canmount properties.

NAME                      canmount mountpoint
root/ROOT/default         noauto   /
root/ROOT/default/usr     off      /usr
root/ROOT/default/usr/src noauto   /usr/src
root/ROOT/default/usr/obj noauto   /usr/obj
root/ROOT/backup          noauto   /
root/ROOT/backup/usr      noauto   /usr     <====
root/ROOT/backup/usr/src  noauto   /usr/src
root/ROOT/backup/usr/obj  noauto   /usr/obj
root/home                 on       /home
root/var                  off      /var
root/var/log              on       /var/log

and thus, by switching to this backup BE by
bectl activate backup
the next boot looses /usr/bin (and others) when zfsbe (correctly) mounts /usr .