Re: Beadm can't create snapshot

From: Peter Jeremy <peterj_at_freebsd.org>
Date: Tue, 23 Aug 2022 21:43:51 UTC
On 2022-Aug-23 15:19:34 +0200, Ronald Klop <ronald-lists@klop.ws> wrote:
>Van: Kyle Evans <kevans@freebsd.org>
>> I was not aware that beadm touches loader.conf, but I find that
>> slightly horrifying. I won't personally make bectl do that, but I
>> guess I could at least document that it doesn't...
>
>Today I looked up something for boot environments myself and read this: https://wiki.freebsd.org/BootEnvironments#Setting_Boot_Dataset
>
>"In order for boot environments to be effective, you must let the bootfs zpool property control which dataset gets mounted as the root. Particularly, /etc/fstab must be purged of any / mount, and /boot/loader.conf must not be setting vfs.root.mountfrom directly. "
>
>So it is documented somewhere at least.

Looking at the wiki history, Kyle wrote that in January 2020.  I
wonder if he recalls where that requirement came from.

I've gone rummaging through the mailing list history and other wiki
pages.  It seems that vfs.root.mountfrom used to be required - e.g.
 https://lists.freebsd.org/pipermail/freebsd-fs/2011-September/012482.html
 https://lists.freebsd.org/pipermail/svn-src-head/2011-October/030641.html
and people wanted to change that - e.g.
 https://lists.freebsd.org/pipermail/freebsd-current/2009-October/012933.html
 https://lists.freebsd.org/pipermail/freebsd-fs/2010-March/008010.html
resulting in it becoming optional in May 2012:
 https://lists.freebsd.org/pipermail/svn-src-head/2012-May/036902.html

Based on the quoted wiki entry, it seems that sometime between May
2012 and January 2020, vfs.root.mountfrom went from "must be set" to
"must not be set" and I can't find anywhere where that is publicised.
This is a serious problem because we now have the situation where
some documentation still says to set vfs.root.mountfrom - e.g.
 https://wiki.freebsd.org/RootOnZFS/GPTZFSBoot/Mirror step 2.6
and people are still using it without being warned that it shouldn't
be used - e.g. the thread starting
 https://lists.freebsd.org/pipermail/freebsd-fs/2020-July/028351.html

I've had a look at the beadm source and it preserves/updates
vfs.root.mountfrom if it's present in loader.conf but doesn't add it
if it's not present.

IMO, if bectl isn't going to update loader.conf, it needs to warn and
fail if loader.conf contains a vfs.root.mountfrom that points to a
BE that's different to bootfs.  (And ideally, a similar check of
/etc/fstab, though beadm doesn't touch that).

-- 
Peter Jeremy