The various BSD systems have a very clear separation into "base system" and "3rd party software (ports/packages)". You upgrade the two separately.
This assumes that you have an installation of OpenBSD 6.5 or later (see further down for old answer):
The base system is upgraded with sysupgrade(8)
:
doas sysupgrade
This will download and upgrade the base system to the next "stable" version of OpenBSD if you are following the stable or release branch, or to the latest "snapshot" if you are using snapshots. Note that you should not use sysupgrade
if you have a customised installation without all the base system sets.
After upgrading the base system, you may want to run syspatch(8)
(only to get your system up from "release" to "stable", snapshot systems don't use syspatch
).
Ports are updated with pkg_add(1)
:
doas pkg_add -u
On a snapshot system, you may want to add -D snap
to that (see the manual).
You will also want to check the relevant section of the OpenBSD FAQ before upgrading, e.g. the section on "Following -current and using snapshots" or the section relating to upgrading to the latest stable release.
There is also a port/package called sysclean
(in sysutils/sysclean
) that will help you with pointing out base system libraries and other files that are no longer part of the default installation. It will also tell you what ports are using outdated libraries.
Old answer, relevant to OpenBSD releases before 6.5:
In the case of OpenBSD, assuming you want to move from one stable release to the next stable release (jumping releases is not supported unless you make a fresh install), you start off by reading the specific FAQ for the upgrade you're performing. In the case of upgrading from 5.9 to 6.0, you read the "Upgrade Guide: 5.9 to 6.0".
In general, the gist of it involves booting the installation media for the release you'd like to upgrade to and selecting "(U)pgrade" from the menu. Once the base system is upgraded, you boot it and, as root, upgrade any installed packages with pkg_add -u
.
It is unusual for packages belonging to a stable OpenBSD release to update very often. Usually that only happens when critical bugs are fixed. So running pkg_add -u
several times a week will probably not do very much (but do keep doing it as it may pull in critical fixes).
If you follow "current", things are very different. Then you'd be building your packages from the ports tree checked out with CVS under /usr/ports
, and you would probably be rebuilding the base system manually too (see "Building the System from Source"). Installed ports may be updated with dpb
(in /usr/ports/infrastructure/bin
) if given the correct options and a list of manually installed packages.
I'm using
#!/bin/sh -x
pkg_info -P -q -m | sort -o "$HOME/packages"
/usr/ports/infrastructure/bin/dpb -scuR -P "$HOME/packages"
Followed by
$ doas pkg_add -u -D unsigned
$ doas pkg_delete -a
This is not encouraged for new users.
pkg_add
ispkg_add -uvi
, right?