upgrading to OpenBSD-current, the stupid way

My desktop runs an OpenBSD snapshot from April 2010. It’s well past time I upgraded. OpenBSD’s usual upgrade path works quite well, but I’m simultaneously lazy and willing to reinstall this system from scratch if something ghastly happens. (This might also invalidate any bug report you send.)

Don’t do this if you have any need or respect for your computer. I treat my desktop with a mix of indifference and contempt, so I’ll proceed.

Back up your data. I attached my external 1TB USB drive. /var/log/messages shows:

Jan 21 10:08:17 avarice /bsd: sd0 at scsibus2 targ 1 lun 0: SCSI2 0/direct fixed
Jan 21 10:08:17 avarice /bsd: sd0: 953869MB, 512 bytes/sec, 1953525168 sec total

It’s device sd0. What partitions are on it?

$ sudo disklabel sd0
...16 partitions:
# size offset fstype [fsize bsize cpg]
c: 1953525168 0 unused
i: 1953520002 63 MSDOS

I want to mount sd0i.

$ sudo mount_msdos /dev/sd0i /mnt/
$ cd /home
$ sudo gtar -cvMf /mnt/laptop.tar mwlucas

One annoyance with using an MSDOS-formatted disk for backup is that you can’t have a file larger than 4GB. My home directory is multiple times that. I must use gtar to back up my home directory, and use the multiple-volumes option. When gtar completes a 4GB file, it asks me to prepare a new volume. Move the existing backup file to a different file, then hit return to have gtar continue.

While that’s running, let’s get the download files. Go to the OpenBSD mirror list and choose one near you. Use a web browser to verify that the shapshot on the site is current. Open a FTP session to that site, and grab all the bsd* and *.tgz files.

ftp> cd pub/OpenBSD/snapshots/amd64
250 Directory successfully changed.
ftp> prompt
Interactive mode off.
ftp> mget bsd*
wait
ftp> mget *.tgz
wait…

Verify the checksums of the downloaded files against the checksums in the SHA256 file on the FTP site.

$ cksum -a sha256 *

I have backups. I have the files, and they aren’t corrupt. We are now at the point of no return. You can still follow the recommended upgrade procedure. I encourage you to do so.

Shut down all unnecessary processes. If you’re forwarding packets, stop. If you’re in X, exit to a text console. Kill all daemons that aren’t necessary for a minimally-running system.

Copy your desired kernel to the root directory. I’m using the multiprocessor kernel. Also save a copy of your current reboot command.

$ rm /obsd ; ln /bsd /obsd && cp bsd.mp /nbsd && mv /nbsd /bsd
$ cp bsd.rd /
$ cp bsd /bsd.sp

Now overwrite the nonessential parts of your userland.

$ tar -C / -xzvphf xserv49.tgz
$ tar -C / -xzphf xfont49.tgz
$ tar -C / -xzphf xshare49.tgz
$ tar -C / -xzphf xbase49.tgz
$ tar -C / -xzphf game49.tgz
$ tar -C / -xzphf comp49.tgz
$ tar -C / -xzphf man49.tgz

Do not extract the etc49.tgz distribution, as that will overwrite your core system configuration! You must update /etc separately.

Update the core programs last. The core system includes programs like tar and reboot. Once you update the core, your system is running a new userland on an old kernel.

$ tar -C / -xzphf base49.tgz

Your system is now basically unusable; you have new binaries running on an old kernel. You must reboot now. Afterwards, I’m running:

OpenBSD 4.9-beta (GENERIC.MP) #777: Tue Jan 18 13:56:34 MST 2011

Generate the new device nodes.

$ cd /dev/
$ sudo ./MAKEDEV all

I prefer to reboot after recreating device nodes. The new reboot command is now usable. After the next reboot everything looks fine, except for this message:

Could not load host key: /etc/ssh/ssh_host_ecdsa_key

So, there’s a new key type. I’ll get that as I upgrade /etc, by running sysmerge(8). Go to the snapshot directory and run:

$ sudo sysmerge -s etc49.tgz -x xetc49.tgz

Sysmerge will compare your installed /etc with the snapshot fileset and show you the diffs. You can install the new file, delete the new file, or merge the two together. If you’ve used mergemaster(8), sysmerge(8) will be no surprise.

Then reboot again. With the new /etc, OpenBSD automatically generates the missing SSH key for the new crypto algorithm.

My system is now upgraded.

In the interest of sanity, I need to remove and reinstall all the packages on this system. This isn’t a big deal, except for those few that must be built as ports because I require something unusual. Set PKG_PATH to the packages directory of your closest FTP mirror and run pkg_add -ui

$ sudo pkg_add -iu
quirks-1.32: ok
ORBit2-2.14.19:libiconv-1.13p0->libiconv-1.13p2: ok
ORBit2-2.14.19:pcre-7.9->pcre-8.02p1: ok
ORBit2-2.14.19:libgamin-0.1.10->libgamin-0.1.10p3: ok
ORBit2-2.14.19:gettext-0.17p0->gettext-0.18.1p0: ok
...

Walk away.

In this particular case, pkg_add crashed when my chosen FTP mirror limited the number of successive connections from my IP address. I raised this on misc@, and got an answer and a fix almost immediately.

So, even fools like me can get help. But don’t count on it.

Stalk me on social media

6 Replies to “upgrading to OpenBSD-current, the stupid way”

  1. I tend to use a variation of this, the keywords being

    1) get the contents of your platform’s snapshots directory, (in my case /pub/OpenBSD/snapshots/amd64) to a local directory
    2) cd to that directory, run two commands
    $ sudo cp bsd.rd /
    $ sudo sudo sysmerge -s etc49.tgz -x xetc49.tgz

    3) reboot, at the boot> prompt type
    boot> boot bsd.rd

    This gets you the installer, choose U)pgrade, answer a few easy questions. When prompted, specify your local directory (likely somewhere under /mnt/home/) for the sets. At the end, reboot.

    4) upgrade any packages from your reasonably local mirror (in my case http://ftp.eu.openbsd.org):

    $ export PKG_PATH=http://ftp.eu.openbsd.org/pub/OpenBSD/snapshots/packages/amd64
    $ sudo pkg_add -vvui

    yes, those two v’s mean ‘extra verbose’ – my curiousity in practice.

    The main difference here is that you get to see any useful new features of the snapshot’s installer, and the system will automagically choose the correct kernel for your system.

  2. That’s a very nice way of staying current, indeed. However, I would have concerns regarding stability. Do you experience any stability issues? I know OpenBSD is compiled in a way [or the *state* in particular] in which everything works fine, but … you’ll probobly have some bugs no matter how well the fundamental code is written.

    Regards and thanks for this useful info!

  3. Here is a nicely detailed account on how to get “current”. See http://alokat.org/blog/2013/02/12/update-to-the-latest-openbsd-snapshot/
    There are screen captures included to help new adoptees to OpenBSD:)

    Here is a snipped portion of it.

    ————snipped————-S

    OpenBSD provides three possibilities to update your system. The first possibility is to update from one release to another – e.g. 5.2 to 5.3.

    The second one is to use snapshots to keep your system up-to-date. The OpenBSD developers provides reference releases called snapshots. Those snapshots will be created from the current source daily or weekly – depends on the architecture.

    The third one is to compile the kernel / userland yourself by using the source from the cvs repository – but the developers don’t really appreciate this method. Only if you really know what you are doing!

Comments are closed.