Sunday, February 1, 2015

Rolling with snapshots

is not as scary as most people think. From the outside the OpenBSD upgrade process, especially when following bleeding edge development looks really intensive and risky. Here's how I feel about it after regular weekly snapshot upgrades for the past 7 weeks.


When I first started with OpenBSD I was advised to remain on the release and follow errata patches. Even though now I'm rolling with snapshots I still don't regret that and would advise anyone to start from there. The biggest gain I had from doing basic errata patches is knowledge on how the system is built - even on a really basic level this process removes a lot of unknowns that most package managers hide from people. Grab the source, apply the patch and follow the outlined steps to build the change and restart the system or just the required services. If my main goal was running OpenBSD as a server or a router that I don't intend to touch for the next 6 months it would still be the path that I would follow.

Since I'm running on a laptop and want to get involved with at least porting some software. I had to bump up my version to CURRENT or at least a recent snapshot. I come from a Linux background and that thought was a bit terrifying at first. I can handle the upgrade steps required by Arch Linux on some big infrastructure changes but I didn't feel that comfortable to run a bleeding edge version of an OS that I'm just beginning to learn. Especially since the process doesn't boil down to running a single command like in most Linux distributions. Well at least it looked like that from the outside.

What pushed me over the bump was two things. Great documentation of the process in the official OpenBSD documentation & a nice and calm explanation of it in the Absolute OpenBSD book. I spent the first two days reading the official documentation then did a full backup of the stuff I care about and armed with the mentioned book started the upgrade process anticipating everything going haywire. Twenty minutes later I was staring at a fully functional OpenBSD desktop from a snapshot built a day before. Fifteen minutes of that time can be accounted to me reading the related chapter in the Absolute OpenBSD book & staring at progress bars of packages being downloaded.

So how does the process actually look? First of all, this post again is not a tutorial. When in doubt please refer to the excellent documentation from the project as things greatly depend on current development efforts in the project. I will just outline the basic steps I do once a week to show you that the whole thing is not as scary as it seems.

When time arrives (mostly on weekends in my case) I check my mirror of choice for any new snapshots. I mostly just look at the timestamps of the bsd.rd file which is the installation kernel for OpenBSD. I have a pretty good idea of what went on between my last snapshot and the current one since I'm following the mailing lists (cvs commits, tech & misc) but before I even download the bsd.rd file I check the following current FAQ. Once I'm sure that I'm OK with any additionally required steps I proceed to grab the file.

The bsd.rd file is supposed to be dropped in your system root directory (/). Before doing that I make a backup copy of all the old kernels (bsd, bsd.sp & bsd.rd). Mostly I just make a copy with the same name suffixed with .b that way if my upgrade goes wrong I can always attempt to boot up the old kernel with 'boot bsd.b'. I also keep a copy of the file in my home directory in order to remember which snapshots I used.

$ tree openbsd/snapshots/                                                                                    
openbsd/snapshots/
|-- 10-Dec-2014
|   |-- base56.tgz
|   |-- bsd
|   |-- bsd.mp
|   |-- bsd.rd
|   `-- xbase56.tgz
|-- 10-Jan-2015
|   `-- bsd.rd
|-- 22-Jan-2015
|   `-- bsd.rd
|-- 23-Dec-2014
|   `-- bsd.rd
|-- 24-Dec-2014
|   `-- ports.tar.gz
|-- 27-Dec-2014
|   |-- 29-Dec-2014.pkg
|   `-- bsd.rd
|-- 30-Jan-2015
|   `-- bsd.rd

After that the only thing I need to do is reboot into the new kernel by entering boot bsd.rd in the boot prompt after a restart. This step triggers a regular OpenBSD installation with an 'Upgrade' option. The steps required are dead simple and mostly boil down to confirming the default choice the installer presents. The only thing I personally change is the mirror in case my current one starts having some issues.

The upgrade takes literally minutes, in my case most of the time is spent on downloading base packages from the network. When it's done just reboot and log in into your upgraded system.

The installer nicely reminds you to run sysmerge(8) in order to upgrade any existing system wide configuration files. Between OpenBSD 5.6 & 5.7 this step got a lot easier as you don't even have to specify file sets in the sysmerge command. I then perform any tasks mentioned in following current.

The last step of the upgrade is running pkg_add -uiv which upgrades any ports packages you installed. I was pleasantly surprised to see my otter port included in that process even though I only installed my personally built package but it got correctly picked up when the official one kicked in.

Update candidates: otter-browser-0.9.04 -> otter-browser-0.9.04
Update candidates: qt5-5.3.2p7 -> qt5-5.3.2p10
Update candidates: pulseaudio-5.0p2 -> pulseaudio-5.0p2
otter-browser-0.9.04:pulseaudio-5.0p2->5.0p2: ok
otter-browser-0.9.04:qt5-5.3.2p7->5.3.2p10: ok
New package otter-browser-0.9.04 will run the following commands
+ @exec /usr/local/bin/update-desktop-database
+ @exec /usr/local/bin/gtk-update-icon-cache -q -t /usr/local/share/icons/hicolor
Running update
otter-browser-0.9.04->0.9.04: ok
Finally the command will end and show any additional tasks you may need to perform.

Read shared items: ok
Look in /usr/local/share/doc/pkg-readmes for extra documentation.
--- -cyrus-sasl-2.1.26p12 -------------------
You should also run rm -rf /var/sasl2/*
--- -dconf-0.22.0p1 -------------------
You should also run rm -rf /etc/dconf/db/*
You should also run rm -rf /etc/dconf/profile/*
--- -iodbc-3.52.9p0 -------------------
You should also run rm -rf /etc/iodbc/ODBCDataSources/*
Couldn't find updates for quiterss-0.17.5
Extracted 1185387200 from 1756909918
That's it. The whole process literally is bottle necked by your network connection. It's not any harder then upgrading your system on a typical Linux distribution. The process is just divided into more steps.

On my first upgrade I was really pleasantly surprised that the OpenBSD project not only build snapshots but also packages that go along with it. This means that you obtain newer software packages without building them yourself (ie. Firefox).

In the 7 upgrades I did, not even once OpenBSD failed to work. It does happen and I do expect to hit that at some point in time as I saw people reporting snapshot issues on the mailing lists. Though that's a good thing, narrowing down issues introduced in a specific snapshot is much easier then going through 6 months of code changes (and believe me OpenBSD is in heavy development - just look at the 5.6 release notes). Additionally I love the fact that I can work on new ports, help people test their ports and even patches for developers since they now cleanly apply to my system.