[Bug 261446] freebsd-update should not create boot environment when it's not making changes to the boot environment

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 24 Jan 2022 21:39:57 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261446

            Bug ID: 261446
           Summary: freebsd-update should not create boot environment when
                    it's not making changes to the boot environment
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: delphij@FreeBSD.org

I have noticed that f28f138905416c45ebaa6429f44a0b88a72f54b1 have implemented a
feature that would create a new boot environment upon installation.

While the feature itself is very useful, there are some scenarios that we don't
want a new boot environment to be created unconditionally.  One of these
scenarios would be poudriere, which runs freebsd-update without jailing into
the jails.

I think the behavior should be disabled when -b is specified AND when it's not
/, because the boot environment is not going to be changed.

I'd like to make the following feature requests:

1) Make the creation of boot environment to be named after both freebsd-version
-k and freebsd-version -u results, in other words:

diff --git a/usr.sbin/freebsd-update/freebsd-update.sh
b/usr.sbin/freebsd-update/freebsd-update.sh
index 1776115d0776..a6f758813cd8 100644
--- a/usr.sbin/freebsd-update/freebsd-update.sh
+++ b/usr.sbin/freebsd-update/freebsd-update.sh
@@ -911,7 +911,7 @@ install_create_be () {
                esac
                if [ ${CREATEBE} = yes ]; then
                        echo -n "Creating snapshot of existing boot
environment... "
-                       VERSION=`freebsd-version -k`
+                       VERSION=`freebsd-version -ku | sort -V | tail -n 1`
                        TIMESTAMP=`date +"%Y-%m-%d_%H%M%S"`
                        bectl create ${VERSION}_${TIMESTAMP}
                        if [ $? -eq 0 ]; then


2) Make freebsd-update to not create boot environment when -b is specified and
the base directory is /

3) It's probably reasonable to have a RC script or periodic script to do
something like:

(bectl list -H | awk '{print $1;}' | grep -q $(freebsd-version -k) ) || bectl
create $(freebsd-version -k)_$(date +%Y-%m-%d_%H%M%S)

4) There should be some way to clean up the automatically created boot
environments.  It makes sense to keep them around for e.g. a few weeks, but
running out of disk space on / is not really fun.

-- 
You are receiving this mail because:
You are the assignee for the bug.