How to remove all the bectl versions and will I damage anything?

Hi,

So, I upgraded to FreeBSD 14.0-RELEASE. It looks like bectl shows:

13.1-RELEASE-p4_2023-12-22_152118 NR / 75.9G 2023-12-22 15:21
13.1-RELEASE-p4_2023-12-22_153018 - - 943M 2023-12-22 15:30
13.1-RELEASE-p4_2023-12-30_151926 - - 5.79M 2023-12-30 15:19
13.2-RELEASE-p8_2023-12-30_155536 - - 825M 2023-12-30 15:55
13.2-RELEASE-p8_2023-12-30_155916 - - 1.27M 2023-12-30 15:59
14.0-RELEASE-p3_2024-01-03_231405 - - 5.97G 2024-01-03 23:14
14.0-RELEASE-p4_2024-01-11_170520 - - 34.1M 2024-01-11 17:05

Can I simply boot from the 'last' entry by doing:

bectl activate 14.0-RELEASE-p4_2024-01-11_170520

I need confirmation this is going to work.

After I boot to the activated one, I assume it will be marked with 'NR /'

At that point, can I bectl destroy everything in the 13.x range without damaging anything?

Once I have this done, I have to move on to why my USB ports keep rebooting and attach/detach'ing.

Thank you for the help!!

Paul
 
There is a nice article by Dru Lavigne which is a good read, suggest you do read it and also take necessary backups before proceeding


It is not apparent how you have managed to set NR flags on your oldest boot environment

You should be able to use the FreeBSD boot loader to select different boot environments and test them as per above article

You may want to look at deleting snapshots if you decide to delete the BEs

# zfs list -t snapshot

# bectl destroy -o <selected BE>
 
It is not apparent how you have managed to set NR flags on your oldest boot environment

The header row (at least) is missing from the opening post.

Dates are probably dates of creation. The active boot environment is typically the oldest (created), is typically the most recently updated, and may be named Default.

Things can become confusing if the active environment is thought of as the default but is something other than Default.
 
… a nice article by Dru Lavigne which is a good read, …

Undated (the Klara collection might gain dates in due course). Probably mid-2021.

Where there's advice to create a boot environment before using freebsd-update(8): probably best to ignore the advice.
 
I'm using attached script to delete no longer needed boot environments. Added extension ".txt" to be accepted here.
This uses sysutils/beadm, but should be easily modiied for bectl.

First, create list file, /tmp/bes, by beadm list | cut -f1 -w -s > /tmp/bes, then, edit it to remove entry that you do NOT want to be deleted. Default is dry-run so you need option "-f" for actual deletion.
The list file name can be overridden on command line.
 

Attachments

Well, I activated the latest by date. Booted into it. Everything looked and ran fine. *Shrugged*

Started doing: bectl destroy <BE environments>

Got to last two and stopped there. Everything is good. Happy, Happy, Joy, Joy! :D
 
the latest by date.

That was probably the environment that preceded an update.

Now, please:

freebsd-version -kru ; uname -aKU

bectl list -c creation

Hint: include the header row(s), and format as code.

1705127223398.png
 
Just do, bectl destroy <selected BE>
Did the "-o" option become the default on bectl destroy? "destroy the origin"? I know it was not the default for a while, there was discussion about making it the default, just wondering if it happened.
beadm always asks you unless you "force". It's been a while since I've used beadm so I could be wrong.

grahamperrin has a few good points in this thread, I'd like to emphasize.
From a standard install, the only boot environment is named "default", no version information in the name.
freebsd-update install will create a boot environment that is "your current environment before any changes are applied" (provides rollback) and then applies all changes in your current boot environment (typically marked with NR)

I use the bectl rename command a lot; after install rename "default" to something versioned so I know what it is, then after freebsd-update rename the BEs to match contents.

Example:
you are currently in a 13.2-p4 BE (named 13.2-p4) and run freebsd-update to get to 13.2-p8.
freebsd-update creates a new be name 13.2-p4-timestamp that is before applying updates, then it applies the updates to get to 13.2-p8.
bectl list will show a 13.2-p4-timestamp and one named 13.2-p4. The one named 13.2-p4 actually contains 13.2-p8.
I then bectl rename the named 13.2-p4 to 13.2-p8 and then bectl rename the 13.2-p4-timestamp to 13.2-p4.
 
It may not have happened on the mailing lists, but there was at least a minor discussion here around -o.
I know it bit me a little simply because it was different behavior than beadm.
I simply "reprogrammed" my brain to always add it.
 
Need advice. I'm studying ZFS. So:
1. Yesterday I downloaded version 14.0. I didn't install pkg, because the message said that from October 1, 2014 everything is... I'm too late. Okay.
2. Updated to 14.1. Successfully.
3. Installed pkg. Updated. Everything is fine.
4. Today I look at:
# bectl list
Bash:
BE                                 Active Mountpoint Space Created
14.0-RELEASE-p11_2024-11-17_185640 -      -          1.92M 2024-11-17 18:56
14.0-RELEASE_2024-11-17_183005     -      -          400M  2024-11-17 18:30
14.1-RELEASE-p5_2024-11-17_190050  -      -          1.68M 2024-11-17 19:00
default                            NR     /          7.72G 2024-11-17 20:17
# zfs list
Bash:
NAME                                            USED  AVAIL  REFER  MOUNTPOINT
zroot                                          7.73G  18.9G    96K  /zroot
zroot/ROOT                                     7.73G  18.9G    96K  none
zroot/ROOT/14.0-RELEASE-p11_2024-11-17_185640     8K  18.9G  2.32G  /
zroot/ROOT/14.0-RELEASE_2024-11-17_183005         8K  18.9G  1.43G  /
zroot/ROOT/14.1-RELEASE-p5_2024-11-17_190050      8K  18.9G  2.40G  /
zroot/ROOT/default                             7.73G  18.9G  6.59G  /
# beadm list
Bash:
BE                                 Active Mountpoint  Space Created
14.0-RELEASE_2024-11-17_183005     -      -          400.0M 2024-11-17 18:30
14.0-RELEASE-p11_2024-11-17_185640 -      -            1.9M 2024-11-17 18:56
14.1-RELEASE-p5_2024-11-17_190050  -      -            1.7M 2024-11-17 19:00
default                            NR     /            7.7G 2024-11-17 20:17
# zpool get bootfs zroot
Bash:
NAME   PROPERTY  VALUE               SOURCE
zroot  bootfs    zroot/ROOT/default  local
zfs get all zroot/ROOT/default | grep "local\|NAME"
Bash:
NAME                PROPERTY              VALUE                     SOURCE
zroot/ROOT/default  mountpoint            /                         local
zroot/ROOT/default  canmount              noauto                    local
# freebsd-version -kru
Bash:
14.1-RELEASE-p5
14.1-RELEASE-p5
14.1-RELEASE-p6

If I delete everything except default, will everything be OK?
 
When deciding what is safe to remove you must pay attention to the "Active" column and the flags "N" and "R".
N means "this is the currently Active BE"
R means "this will be the active BE after a reboot"

the name "default" is used by the installer, you can rename after if you want to but if you do, then SirDice one liner would need to be modified.
The freebsd-update command by default will create a new BE representing "system prior to applying updates" when you do freebsd-update install.
So run bectl/beadm list once in a while and manage it before it gets out of hand.
 
You speak of deleting all the BE except default? If it is, that's Ok.
Anyway, you must delete from time to time the old BEs for freeing some room on the disk(s).
Yes, thanks for the help! That's right. It worked. Nothing broke. SirDice:
# bectl list -H | cut -f1 -w | grep RELEASE | xargs -n1 bectl destroy
# bectl list
Bash:
BE      Active Mountpoint Space Created
default NR     /          6.60G 2024-11-17 20:17
 
the name "default" is used by the installer, you can rename after if you want to but if you do, then @SirDice one liner would need to be modified.
As long as you don't put "RELEASE" in there it should be fine. But yeah, my one liner assumes everything with "RELEASE" in its BE name can be removed. I suggest leaving that last piped command out ( | xargs -n1 bectl destroy) and double check it only wants to remove the right BEs before committing to the destruction.
 
My routine is to rename the "NR" BE to reflect freebsd-version, so my "default" becomes "14.1-RELEASE-p2" and everything freebsd-update creates is that plus timestamp.
Yes more work on my part because I then need to bectl rename after each update, but it saves me when I stop in the loader and list available BEs. I don't need to go "what is in default"?

Like everything else in life, find what works for you and stick with it. Be open to listening to alternatives, try them if they make sense, but do what works for you.
 
Back
Top