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.

ftp ftp://ftp2.usa.openbsd.org/pub/OpenBSD/4.2/i386/bsd.rd
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 1and1.com 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.

(U)pgrade…

...  # 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]    # Wait...read on

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

Do you want to do any manual network configuration? [no]    yes   #for 1and1.com or like ISP
And cut and past the following for a 1and1.com style ISP:
 # 1and1.com only
route add -llinfo -iface -net 10.255.0.0/16 10.255.255.1 -ifp vr0
route add -net default 10.255.255.1
ping -c 1 www.yahoo.com
exit
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') ftp2.usa.openbsd.com  # 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
        [ ] bsd.mp
        [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') [bsd.mp] all

        [X] bsd
        [X] bsd.rd
        [X] bsd.mp
        [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)
done.

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 -> bsd.mp, but you may just want bsd
...
halt
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
ftp ftp://ftp2.usa.openbsd.org/pub/OpenBSD/4.2/i386/etc42.tgz
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/localhost.cf etc/mail/sendmail.cf etc/mail/submit.cf 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/localhost.cf mail/submit.cf /etc/mail
cp mail/sendmail.cf /etc/mail
cd /tmp
wget http://www.openbsd.com/faq/upgrade42.patch
cd /
patch -p0 < /tmp/upgrade42.patch
cp bgpd.conf ospfd.conf /etc/.
cp mail/spamd.conf /etc/mail/.
newaliases
mtree -qdef /etc/mtree/4.4BSD.dist -p / -u
cd /tmp
ftp ftp://ftp2.usa.openbsd.org/pub/OpenBSD/4.2/i386/xetc42.tgz
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="ftp://ftp2.usa.openbsd.org/pub/OpenBSD/4.2/packages/i386" 
setenv PKG_PATH "ftp://ftp2.usa.openbsd.org/pub/OpenBSD/4.2/packages/i386" 
pkg_add -ui -F update -F updatedepends
pkg_delete expat
reboot

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

Reference: http://www.openbsd.com/faq/upgrade42.html


Digg! Delicious! Technorati Blinklist Furl Reddit
Comments

Leave a response

Comment

Hint: Comments now accept textile.