Remote Upgrade of OpenBSD 4.1 to 4.2

Posted by face on November 04, 2007

The first assumption is that you have a remote OpenBSD server running 4.1 with a serial port console.

Before you start, read the OpenBSD 4.2 upgrade faq here . For the most part, you will be following that faq. This is simply a supplemental guide to get things rolling…

I’m upgrading a i386 system. bsd.rd is the install/upgrade kernel. If we already have a remote system running, we can upgrade bsd.rd first, then boot from it and upgrade the rest of the system.

sudo cp /bsd.rd /bsd.rd-4.1
sudo cp bsd.rd /bsd.rd
sudo shutdown -h now "Upgrading to 4.2"  # if you don't get a boot prompt, read the NOTE below

Now get on the serial console. You should see that the os is halted and Please press any key to reboot.. When you see the boot prompt type:

boot bsd.rd

NOTE: For some reason, my servers at have a messed up bios and I never see the boot prompt. The first thing I see is the booting kernel. To work around this, add set image boot.rd to /etc/boot.conf. Then do a reboot instead of a shutdown above…

You should see the familiar (I)nstall, (U)pgrade or (S)hell?. I am choosing Upgrade. You could choose install here if you want to wipe your system and start with a virgin 4.2 box.


...  # Usually accept defaults up to this point...
Proceed with upgrade? [no] yes
Cool! Let's get to it.
Available disks are: wd0.
Which one is the root disk? (or 'done') [wd0] 
Root filesystem? [wd0a] 
Checking root filesystem (fsck -fp /dev/wd0a) ... OK.
Mounting root filesystem...done.
Enable network using configuration stored on root filesystem? [yes] 
Resolver enabled.
Do you want to do any manual network configuration? [no]    # on

No for manual network will work for most people. However, I am hosted at and they require some manual network configuration. For I have to do this:

Do you want to do any manual network configuration? [no]    yes   #for or like ISP
And cut and past the following for a style ISP:
 # only
route add -llinfo -iface -net -ifp vr0
route add -net default
ping -c 1
And now we continue:

Edit fstab with ed? [no] 
Force checking of non-root filesystems? [yes] 
fsck -fp /dev/wd0e...OK.
Let's upgrade the sets!
Location of sets? (disk ftp http or 'done') [disk] ftp
HTTP/FTP proxy URL? (e.g. 'http://proxy:8080', or 'none') [none] 
Display the list of known ftp servers? [no] 
Server? (IP address, hostname or 'done')  # East coast -- Plase find a server near you
Does the server support passive mode ftp? [yes] 
Server directory? [pub/OpenBSD/4.2/i386] 
Login? [anonymous] 

Select sets by entering a set name, a file name pattern or 'all'. De-select
sets by prepending a '-' to the set name, file name pattern or 'all'. Selected
sets are labelled '[X]'.

        [X] bsd
        [X] bsd.rd
        [ ]
        [X] base42.tgz
        [X] misc42.tgz
        [X] comp42.tgz
        [X] man42.tgz
        [X] game42.tgz
        [ ] xbase42.tgz
        [ ] xshare42.tgz
        [ ] xfont42.tgz
        [ ] xserv42.tgz
Set name? (or 'done') [] all

        [X] bsd
        [X] bsd.rd
        [X] base42.tgz
        [X] misc42.tgz
        [X] comp42.tgz
        [X] man42.tgz
        [X] game42.tgz
        [X] xbase42.tgz
        [X] xshare42.tgz
        [X] xfont42.tgz
        [X] xserv42.tgz
Set name? (or 'done') [done] done
Ready to upgrade sets? [yes] yes
Getting bsd ...
100% |**************************************************|  6083 KB    00:02
Location of sets? (disk ftp http or 'done') [done] 
Making all device nodes...done.
Installing boot block...
boot: /mnt/boot
proto: /usr/mdec/biosboot
device: /dev/rwd0c
/usr/mdec/biosboot: entry point 0
proto bootblock size 512
/mnt/boot is 3 blocks x 16384 bytes
fs block shift 2; part offset 63; inode block 32, offset 5544
using MBR partition 3: type 166 (0xa6) offset 63 (0x3f)

CONGRATULATIONS! Your OpenBSD upgrade has been successfully completed!
To boot the new system, enter halt at the command prompt. Once the
system has halted, reset the machine and boot from the disk.

As I mentioned above, I can’t get to the boot prompt on the console and now have a system that only boots bsd.rd. Lets fix that with vi (or emacs):

/mnt/usr/sbin/chroot /mnt
export TERM=xterm  # This might be different for you
vi /etc/boot.conf   #  Now I change bsd.rd ->, but you may just want bsd
syncing disks... done
The operating system has halted.
Please press any key to reboot.

Now we upgrad etc. It is documented very well here in the faq so please upgrade /etc/ per the faq.

The following upgrade of /etc is for my system, your’s may be different so please be careful!!!.

cd /tmp
tar xpfz etc42.tgz
cp etc/magic etc/man.conf etc/netstart etc/rc etc/rc.conf etc/rpc etc/services etc/mail/helpfile etc/mail/ etc/mail/ etc/mail/ etc/mtree/4.4BSD.dist etc/mtree/BSD.local.dist etc/mtree/special /etc/.
cd /tmp/etc
cp magic man.conf netstart rc rc.conf rpc services /etc
cp mtree/* /etc/mtree/
cp mail/helpfile mail/ mail/ /etc/mail
cp mail/ /etc/mail
cd /tmp
cd /
patch -p0 < /tmp/upgrade42.patch
cp bgpd.conf ospfd.conf /etc/.
cp mail/spamd.conf /etc/mail/.
mtree -qdef /etc/mtree/4.4BSD.dist -p / -u
cd /tmp
tar -C / -xzphf xetc42.tgz

# At this point I merged some files by hand (find /etc -name '*.rej' -print)

# Packages, I like tcsh, but you may like: export PKG_PATH="" 
setenv PKG_PATH "" 
pkg_add -ui -F update -F updatedepends
pkg_delete expat

Ok, we are done with the upgrade. You should apply the errata. You can apply the patches by hand. However, I need to build a patched distribution, as I have many 4.1 boxes to upgrade to 4.2 and I want to upgrade them to the patched version. So building a new distribution with the patches applied will be my next article.

Note: If you use ruby, you may need to update some gems after you upgrade the OS. The following is an example and may vary on your system. Basically, every gem that has a native extension should be updated.
sudo su
gem update mongrel --include-dependencies
gem update mysql
gem update fcgi


Digg! Delicious! Technorati Blinklist Furl Reddit

Leave a response


Hint: Comments now accept textile.