vulcanridr

FreeBSD tribal knowledge: pkg upgrades

I am starting a new blog thread called FreeBSD Tribal Knowledge. It is basically a guide on basic tasks on FreeBSD that I have refined a bit, and how I do it. This first topic is my method of doing pkg upgrades. While this is obviously not for those that have been using FreeBSD for a while, maybe some new user will stumble across this blog and it may help.

FreeBSD supports the concept of boot environments (BE). Every time you do a freebsd-update fetch install, it saves the running BE and updates the running one. So by default, bectl list will show

bectl1.jpg

In this case, the previous versions of the base system (14.2-RELEASE-p1, p2, and p3) are all snapshotted and saved. The system can be booted on to any of these BEs. The final one, default, is the current version of the system, in this case, 14.2-RELEASE-p4. The NR listing under Active on default indicates Now and Reboot. `bectl activate <BEname> to activate the <BEname> boot environment. Giving "activate -t" will set the temporary flag.

So I have done something similar with my pkg upgrades. Before I start a pkg upgrade, I do a bectl create Before_pkgUpgrade. Then do a pkg upgrade. This gives the ability to roll back in case the upgrade goes sideways. It's something I have wanted the ability to do since the early days of running linux, but never got that wish. Thanks to ZFS, rolling back snapshots is a thing...In fact a thing of beauty. My BE list now looks like

bectl1.jpg

And I have had the need to roll back both a bad upgrade and my home directory. For example, the upgrade of pkg to 2.0 from 1.2, along with the upgrade from KDE Plasma from 5 to 6, things did not go well, and I had to roll back to my Before_pkgUpgrades BE...On more than one occasion.

I then wrote a script for it, and once I started using ansible, I adapted a playbook to work with my systems. Both are available on request.

Thoughts? Leave a comment