LinkedIn Sourceforge Twitter

Vincent's Blog

Pleasure in the job puts perfection in the work (Aristote)

A non standard method to update OpenBSD

Posted on 2019-02-11 22:16:00 from Vincent in Open Bsd

In this blog I'll share the method I'm using to upgrade my OpenBSD machines without using the console.


Motivation

As everyone using OpenBSD, we have to upgrade our systems at least every 6 months. It could be more if you follow "-current".

On some of my machines I do not have access to the console or, when I have access to the console, the keyboard mapping is incorrect.

I've not used lot of different VM vendors, but the few I've used, it was a nightmare to type non ascii characters like minus "-", an asterisk "*", the at "@", ...

Imagine you want to not install the xenorca sets. You should simply type "-x*". Those 3 characters is a misery when you do not have a querty keyboard, or when the console interface try to help you by guessing your keyboard mapping.

I'm sharing it because it works well in my case and because it remains a very simple script (easy to adapt).

The solution

Based on the documentation we can find on the OpenBSD FAQ, there is an unsupported alternative.

My proposed script is just an extension of what OpenBSD proposes.

I'm using this solution to update "-current", or to upgrade my releases every 6 months.
Up to now, I've never had problems.

BUT

Read the documentation before doing it !!!!!

In some cases, preliminary actions are required.

The script

Feel free to copy & paste this script, adapt the few parameters.

Normaly only the "VERSION" parameter must be adapted. The other could remains as they are (with some warning).

In case you want to follow "-current", just put "snapshot" in VERSION.

#!/bin/sh

# Parameters to adapt to your need
# ============
VERSION="64"  # The version you want to install
SYS="amd64" # the target machine type
SRC="https://cdn.openbsd.org" 
# remove the sets you don't wnat. Please keep the sequence
set -A SETS xbase xfont xserv xshare man game comp base #base should always be the last  
DEST="/tmp/upgrd"
# ============

#
# Copyright (c) 2018 Vincent Delft <vincent_delft@google.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
# OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#




# Download OpenBSD kernel files and sets
MAJ=${VERSION%?}
MIN=${VERSION#${VERSION%?}}
if [ $MAJ -gt 0 ] && [ $MIN -gt 0 ]; then
    DWNLD="$SRC/pub/OpenBSD/$MAJ.$MIN/$SYS/"
else
    DWNLD="$SRC/pub/OpenBSD/snapshots/$SYS/"
fi

[ -d "$DEST" ] || mkdir -p "$DEST"
cd "$DEST"
echo == Temporary folder $DEST ==
[ -f SHA256.sig ] || ftp ${DWNLD}SHA256.sig
VER=$(cat SHA256.sig | awk  '/man/ {print substr($2,5,2)}')
for COMPO in bsd.rd bsd bsd.mp;
do
    echo == Treating $COMPO ==
    [ -f $COMPO ] || ftp $DWNLD$COMPO
    signify -C -p /etc/signify/openbsd-$VER-base.pub -x SHA256.sig $COMPO || exit 1
done
for COMPO in ${SETS[@]};
do
    echo == Treating $COMPO$VER.tgz ==
    [ -f $COMPO$VER.tgz ] || ftp $DWNLD$COMPO$VER.tgz
    signify -C -p /etc/signify/openbsd-$VER-base.pub -x SHA256.sig $COMPO$VER.tgz || exit 1
done

# install kernel files
# this is the procedure for multiprocessor machines
ln -f /bsd /obsd && cp bsd.mp /nbsd && mv /nbsd /bsd
cp bsd.rd /
cp bsd /bsd.sp
sha256 -h /var/db/kernel.SHA256 /bsd
echo mp kernel installed

# install the selected sets
[ -f /sbin/oreboot ] || cp /sbin/reboot /sbin/oreboot || exit 1
for _f in ${SETS[@]};
do 
    echo "tar -C / -xzphf $_f"  
    tar -C / -xzphf "$_f" || exit 1 
done
echo "== DONE =="
echo "After reboot, please follow the remaining tasks list on: "
if [ $MAJ -gt 0 ] && [ $MIN -gt 0 ]; then
    echo "https://www.openbsd.org/faq/upgrade$MAJ$MIN.html#NoInstKern"
else
    echo "https://www.openbsd.org/faq/current.html" 
fi
echo "When ready, perform: /sbin/oreboot"

Warning

The script does not verify that you have enough space left on your DEST. In case you have not enough either the ftp will exit with error and the "signify" will fail , which will stop the script.

This script is installing a multi-processor kernel. If this is not what you want, please adapt it



0, 0
displayed: 401



How much does 6 plus 2 ?