Apr 152021
 

I like boot environments (BE) on FreeBSD. They were especially handy when building the AWS host for FreshPorts, since I had no serial console. I would create a BE saving the current status, then make some changes. I’d mark the current BE as boot once, so I could boot back in the known good BE. Worst case, I could mount the storage onto a rescue EC2 instance and adjust the bootfs value of the zpool.

This the current status of that host’s boot environments.

[dan@aws-1:~] $ bectl list
BE                  Active Mountpoint Space Created
12.2-RELEASE-p4     -      -          1.03M 2021-04-13 16:47
before-adding-alias NR     /          9.13G 2021-03-28 20:41
default             -      -          3.00M 2019-02-11 04:58

My goals:

  1. delete 12.2-RELEASE-p4
  2. get off before-adding-alias and onto default

My steps

First, I’ll delete 12.2-RELEASE-p4, but I’m very cautious about this, so I’m going to look closely at what will be deleted. Here are the filesystems which are related to those BE:

[dan@aws-1:~] $ bectl list -a
BE/Dataset/Snapshot                                      Active Mountpoint Space Created

12.2-RELEASE-p4
  zroot/ROOT/12.2-RELEASE-p4                             -      -          1K    2021-04-13 16:47
    zroot/ROOT/before-adding-alias@2021-04-13-16:47:09-0 -      -          1.03M 2021-04-13 16:47

before-adding-alias
  zroot/ROOT/before-adding-alias                         NR     /          9.13G 2021-03-28 20:41

default
  zroot/ROOT/default                                     -      -          214K  2019-02-11 04:58
    zroot/ROOT/before-adding-alias@2020-09-26-16:49:50-0 -      -          2.79M 2020-09-26 16:49
[dan@aws-1:~] $ 

If I want to delete 12.2-RELEASE-p4, I will first inspect zroot/ROOT/12.2-RELEASE-p4. Notice that I am running this command as non-root and with the dry-run option (-n).

[dan@aws-1:~] $ zfs destroy -nrv zroot/ROOT/12.2-RELEASE-p4
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_02:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_03:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_15:00:01_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_01:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_17:00:01_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_00:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_13:00:01_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_20:45:00_frequently
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_20:30:00_frequently
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_05:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_04:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-14_00:00:00_daily
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_21:30:00_frequently
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_07:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-14_23:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-14_22:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_21:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_20:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_21:15:00_frequently
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-13_16:50:00_daily
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_09:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_18:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_21:00:00_frequently
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_19:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_08:00:01_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_16:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_00:00:00_daily
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_14:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_11:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_06:00:01_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_10:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4@autosnap_2021-04-15_12:00:00_hourly
would destroy zroot/ROOT/12.2-RELEASE-p4
[dan@aws-1:~] $ 

Reviewing that output, everything looks fine. Here we go:

[dan@aws-1:~] $ sudo bectl destroy -o 12.2-RELEASE-p4
[dan@aws-1:~] $ bectl list
BE                  Active Mountpoint Space Created
before-adding-alias NR     /          9.13G 2021-03-28 20:41
default             -      -          3.00M 2019-02-11 04:58
[dan@aws-1:~] $ 

So far so good.

Now, for fun, and I’m not planning to destroy that BE, let’s look at before-adding-alias. It is the one I want to keep and it’s the one the system is booting from right now.

[dan@aws-1:~] $ zfs destroy -nrv zroot/ROOT/before-adding-alias
cannot destroy 'zroot/ROOT/before-adding-alias': filesystem has dependent clones
use '-R' to destroy the following datasets:
zroot/ROOT/default@autosnap_2021-04-15_17:00:01_hourly
zroot/ROOT/default@autosnap_2021-04-15_01:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-15_00:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-15_02:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-15_15:00:01_hourly
zroot/ROOT/default@autosnap_2021-04-15_03:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-15_00:00:00_daily
zroot/ROOT/default@autosnap_2021-04-15_07:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-15_05:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-12_00:00:00_daily
zroot/ROOT/default@autosnap_2021-04-15_13:00:01_hourly
zroot/ROOT/default@autosnap_2021-04-15_04:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-15_21:15:00_frequently
zroot/ROOT/default@autosnap_2021-04-14_23:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-14_22:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-15_09:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-15_20:30:00_frequently
zroot/ROOT/default@autosnap_2021-04-15_20:45:00_frequently
zroot/ROOT/default@autosnap_2021-04-15_21:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-15_21:30:00_frequently
zroot/ROOT/default@autosnap_2021-04-15_20:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-15_21:45:00_frequently
zroot/ROOT/default@autosnap_2021-04-11_00:00:00_daily
zroot/ROOT/default@autosnap_2021-04-15_18:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-15_19:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-15_08:00:01_hourly
zroot/ROOT/default@autosnap_2021-04-14_00:00:00_daily
zroot/ROOT/default@autosnap_2021-04-15_21:00:00_frequently
zroot/ROOT/default@autosnap_2021-04-15_14:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-13_00:00:00_daily
zroot/ROOT/default@autosnap_2021-04-15_16:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-15_12:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-15_11:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-15_10:00:00_hourly
zroot/ROOT/default@autosnap_2021-04-15_06:00:01_hourly
zroot/ROOT/default

Well, that would have unintended consequences. That would delete the default BE (i.e. zroot/ROOT/default). Ouch. I am going to delete that one anyway, but that is not the point.

On to the next.

[dan@aws-1:~] $ zfs destroy -nrv zroot/ROOT/default
would destroy zroot/ROOT/default@autosnap_2021-04-15_17:00:01_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_01:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_00:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_02:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_15:00:01_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_03:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_00:00:00_daily
would destroy zroot/ROOT/default@autosnap_2021-04-15_07:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_05:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-12_00:00:00_daily
would destroy zroot/ROOT/default@autosnap_2021-04-15_13:00:01_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_04:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_21:15:00_frequently
would destroy zroot/ROOT/default@autosnap_2021-04-14_23:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-14_22:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_09:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_20:45:00_frequently
would destroy zroot/ROOT/default@autosnap_2021-04-15_21:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_21:30:00_frequently
would destroy zroot/ROOT/default@autosnap_2021-04-15_20:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_21:45:00_frequently
would destroy zroot/ROOT/default@autosnap_2021-04-11_00:00:00_daily
would destroy zroot/ROOT/default@autosnap_2021-04-15_18:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_19:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_08:00:01_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-14_00:00:00_daily
would destroy zroot/ROOT/default@autosnap_2021-04-15_21:00:00_frequently
would destroy zroot/ROOT/default@autosnap_2021-04-15_14:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-13_00:00:00_daily
would destroy zroot/ROOT/default@autosnap_2021-04-15_16:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_12:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_11:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_10:00:00_hourly
would destroy zroot/ROOT/default@autosnap_2021-04-15_06:00:01_hourly
would destroy zroot/ROOT/default
[dan@aws-1:~] $ 

Yes, that looks OK to delete.

[dan@aws-1:~] $ sudo bectl destroy -o default
[dan@aws-1:~] $ bectl list
BE                  Active Mountpoint Space Created
before-adding-alias NR     /          9.13G 2021-03-28 20:41

The rename

Now we are at my goal, the rename.

[dan@aws-1:~] $ sudo bectl rename before-adding-alias default
[dan@aws-1:~] $ bectl list
BE      Active Mountpoint Space Created
default NR     /          9.13G 2021-03-28 20:41
[dan@aws-1:~] $ 

For me I like reboot after this. I want to know now that there is a problem, not later when I’m working on something else.

Post reboot

We’re good.

[dan@aws-1:~] $ uptime
10:24PM  up 3 mins, 1 user, load averages: 0.16, 0.17, 0.08
[dan@aws-1:~] $ bectl list
BE      Active Mountpoint Space Created
default NR     /          9.13G 2021-03-28 20:41
[dan@aws-1:~] $ 
Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive