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.
Jan 21 10:08:17 avarice /bsd: sd0 at scsibus2 targ 1 lun 0:
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
# 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.
Interactive mode off.
ftp> mget bsd*
ftp> mget *.tgz
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
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