With the release of OpenBSD 4.5, it was time to upgrade the home router (the alix6b2 from another post). The OpenBSD Upgrade Guide for 4.5 details a nice way to do the upgrade without having to have console access which I thought I’d try out as well, since I couldn’t find my serial cable and decided that if things went awry I could always scrounge for a serial cable and redo it. (Note from the upgrade documentation: This is NOT the recommended process. Use the install kernel method if at all possible!)

The following process assumes that you are following the “OpenBSD Upgrade Guide 4.5”. If you get lost, refer back to that document for more information. I will be detailing the process for “Upgrading without install kernel” on that page.

Place install files in a “good” location

The first order of business is to Place install files in a “good” location. For me, this meant downloading the install45.iso from my mirror of choice (purchase of the CD set is forthcoming), mounting it on my PowerBook, and copying all of the *.tgz files and the kernel (bsd) to the ALIX:

seth@gandalf /Volumes/OpenBSD:i386    4.5 Install CD/4.5/i386 $ scp *.tgz root@fw:/usr/rel
root@fw's password:
base45.tgz                                                        100%   46MB   5.7MB/s   00:08
comp45.tgz                                                        100%   86MB   6.1MB/s   00:14
etc45.tgz                                                         100%  501KB 501.0KB/s   00:00
game45.tgz                                                        100% 2556KB   2.5MB/s   00:01
man45.tgz                                                         100% 8032KB   7.8MB/s   00:01
misc45.tgz                                                        100% 2866KB   2.8MB/s   00:00
xbase45.tgz                                                       100% 9762KB   9.5MB/s   00:01
xetc45.tgz                                                        100%   73KB  73.5KB/s   00:00
xfont45.tgz                                                       100%   34MB   5.7MB/s   00:06
xserv45.tgz                                                       100%   19MB   6.3MB/s   00:03
xshare45.tgz                                                      100% 2698KB   2.6MB/s   00:00
seth@gandalf /Volumes/OpenBSD:i386    4.5 Install CD/4.5/i386 $ scp bsd root@fw:/usr/rel
root@fw's password:
bsd                                                               100% 6539KB   6.4MB/s   00:01
seth@gandalf /Volumes/OpenBSD:i386    4.5 Install CD/4.5/i386 $ scp bsd.rd root@fw:/usr/rel
root@fw's password:
bsd.rd                                                            100% 5462KB   5.3MB/s   00:01    

(Note that I’m following the guide’s convention of putting all the release files in /usr/rel.) Now, on to step two:

Stop any appropriate applications

For me, this included editing /etc/rc.conf/local to disable the few services running on the box:

# cat /etc/rc.conf.local
#ntpd_flags=            # enabled during install
#pf=YES                 # enable pf
#rtadvd_flags="vr1"     # IPv6 Router Advertisement Daemon
#ftpproxy_flags=""      # for ftp-proxy rules in pf

These will be re-enabled later on.

Check the kernel

The third step was something that I did not have to worry about, since I had not made any changes to the kernel. However, if you have made any kernel changes (either via config(8) or otherwise), make sure you read this particular section of the guide.

Install new kernel(s)

This step is easy; just cut and paste the lines from the guide into your SSH session:

# rm /obsd
rm: /obsd: No such file or directory
# ln /bsd /obsd
# cp bsd /nbsd
# mv /nbsd /bsd

Remove old X modules

Another easy one:

# rm -rf /usr/X11R6/lib/modules/*

Save yourself a copy of the old reboot(1) command

For an explanation why you’d want to do this, see the guide:

# cp /sbin/reboot /sbin/oreboot

Install new userland applications

This will update all (most?) of your userland. Obviously any packages you installed outside of the base system will need to be upgraded as well (see below).

# tar -C / -xzphf comp45.tgz
# tar -C / -xzphf game45.tgz
# tar -C / -xzphf man45.tgz
# tar -C / -xzphf misc45.tgz
# tar -C / -xzphf xbase45.tgz
# tar -C / -xzphf xfont45.tgz
# tar -C / -xzphf xserv45.tgz
# tar -C / -xzphf xshare45.tgz
# tar -C / -xzphf base45.tgz
# /sbin/oreboot
Connection to fw closed by remote host.
Connection to fw closed.

At this point, wait for the device to reboot (hopefully if you’ve done everything correct you won’t be crossing your fingers…).

seth@gandalf ~ $ ssh fw
seth@fw's password:
Last login: Sun May  3 14:43:41 2009 from [somewhere]
OpenBSD 4.5 (GENERIC) #1749: Sat Feb 28 14:51:18 MST 2009

Welcome to OpenBSD: The proactively secure Unix-like operating system.

Please use the sendbug(1) utility to report bugs in the system.
Before reporting a bug, please try to reproduce it with the latest
version of the code.  With bug reports, please try to ensure that
enough information to reproduce the problem is enclosed, and if a
known fix for it exists, include that as well.

$ su -
Password:
Terminal type? [xterm-color]
#

Sweet. On to the next step.

Upgrade /dev

The installation of base45.tgz copied over the latest version of the MAKEDEV script, so run that now:

# cd /dev
# ./MAKEDEV all

This concludes the section of the guide on how to upgrade without the install kernel. The rest of this post covers the “Final Steps” section of the upgrade guide. As such, it should be fairly straight-forward and therefore I won’t comment on everything like I did above.

New Users and Groups

Add the Bluetooth user:

# useradd -u94 -g=uid -c"Bluetooth Daemon" -d/var/empty -s/sbin/nologin _btd

Upgrading /etc

# export RELEASEPATH=/usr/rel
# tar -C /tmp -xzphf ${RELEASEPATH}/etc45.tgz
# cd /tmp/etc
# cp netstart rc rc.conf services /etc
# cp afs/CellServDB /etc/afs
# cp mtree/* /etc/mtree
# cp mail/README mail/submit.cf /etc/mail
# cp ../var/named/etc/root.hint ../var/named/etc/named-*.conf /var/named/etc
# cp ../var/named/etc/named.conf /var/named/etc/
# cd /

Merging locally changed files via a patch file

# pfctl -f /etc/pf.conf -e
pf enabled
# ftp http://www.openbsd.org/faq/upgrade45.patch
Trying 129.128.5.191...
Requesting http://www.openbsd.org/faq/upgrade45.patch
100% |**********************************************************************|  2694       00:00
Successfully retrieved file.
# patch -C -p0 < upgrade45.patch
[snip lots of successful patches]

# newaliases
/etc/mail/aliases: 49 aliases, longest 15 bytes, 709 bytes total
# mtree -qdef /etc/mtree/4.4BSD.dist -p / -u

Merging locally changed files via sysmerge(8)

# sysmerge -as $RELEASEPATH/etc45.tgz -x $RELEASEPATH/xetc45.tgz
===> Creating and populating temporary root under
    /var/tmp/sysmerge.GWPAg/temproot
===> Starting comparison
[stuff happened]
===> Comparison complete
===> Making sure your directory hierarchy has correct perms, running mtree...
===> Automatically installed file(s) listed in
    /var/tmp/sysmerge.GWPAg/auto_installed_files
===> Backup of replaced file(s) can be found under
    /var/tmp/sysmerge.GWPAg/backups
===> When done, /var/tmp/sysmerge.GWPAg and its subdirectories should be removed

Upgrading packages

# export PKG_PATH=http://carroll.cac.psu.edu/pub/OpenBSD/4.5/packages/i386/
# pkg_add -ui -F update -F updatedepends
Candidates for updating gettext-0.17 -> gettext-0.17p0
Candidates for updating libiconv-1.12 -> libiconv-1.12
Candidates for updating vim-7.1.315-no_x11 -> vim-7.2.77-no_x11
Candidates for updating wget-1.11.3 -> wget-1.11.4
Looking for updates: complete
Running the equivalent of pkg_add -r gettext-0.17p0 libiconv-1.12 vim-7.2.77-no_x11 wget-1.11.4
libiconv-1.12 (extracting): complete
libiconv-1.12 (deleting): complete
libiconv-1.12 (installing): complete
gettext-0.17p0 (extracting): complete
gettext-0.17 (deleting): complete
gettext-0.17p0 (installing): complete
vim-7.2.77-no_x11 (extracting): complete
vim-7.1.315-no_x11 (deleting): complete
vim-7.2.77-no_x11 (installing): complete
wget-1.11.4 (extracting): complete
wget-1.11.3 (deleting): complete
wget-1.11.4 (installing): complete
Clean shared items: complete

At this point, you should be able to re-enable any disabled services, and reboot. The upgrade is finished!