Upgrade Guide: 3.9 to 4.0

Note: Upgrades are only supported from one release to the release
immediately following it.
Do not skip releases.

It is highly recommended that you read through and fully understand
this process before attempting it.
If you are doing it on a critical or physically remote machine, it is
recommended that you test this process on an identical, local system to
verify its success before attempting on a critical or remote computer.

Upgrading is a convenient way to bring your OpenBSD system up to the most
recent version.
However, the results are not intended to precisely match the results of
a wipe-and-reload installation.
Old library files in particular are not removed in the upgrade process,
as they may be required by older applications that may or may not be
upgraded at this time.
If you REALLY wish to get rid of all these old files, you are probably
better off reinstalling from scratch.

Before upgrading

Check whether you have made any modifications to your kernel.
For example, you might have modified your network device to use a non-default
setting using config(8).
Note your changes, so you can repeat them for the new 4.0 kernel.

The upgrade process

Upgrading by install media

The easiest and safest way to upgrade is to boot from install media and
follow the upgrade steps, which are very similar to the
install process.
Afterwards, complete the upgrade by following the
final steps as detailed below.

Upgrading without install media

This is NOT the recommended process. Use the install media method
if at all possible!

Sometimes, one needs to do an upgrade of a machine when one can't easily
use the normal upgrade process.
One can usually do this by carefully following a process similar to
building the system from source:

Place install files in a "good" location.
Make sure you have sufficient space!

Stop any "insecure" applications from starting at boot:
There will be a time when PF will be unlikely to be running during this
upgrade process, but your applications may still start and run properly.
Any application dependent upon PF for security should be disabled
before this happens, and should not be re-enabled until proper PF
operation is verified after upgrade.
There may be other applications which you wish to keep from running
during the upgrade, stop and disable them as well.

Check the kernel:
Although most people can skip this step, if you had a modified kernel
in 3.9, it is likely you will need to modify the stock kernel of 4.0.
Especially when you are performing the upgrade process remotely, now is
the time to make sure the new kernel will work upon rebooting the machine.
If any changes must be made to the kernel, the safest thing to do is to
make those changes on a local 4.0 system.
This can be as simple as modifying a specific device using config(8),
or it can involve a recompilation if the option you need is not included
in the GENERIC kernel.
Please consult FAQ 5 - Building the system from source
before considering to recompile your kernel.

Note the extra steps for copying over the primary kernel: those are done
to ensure that there is always a valid copy of the kernel on the disk
that the system can boot from should there be a really badly timed power
outage or system crash.

Install new /etc/firmware files:
Due to the fact that some uploaded "firmware" files may have been updated,
you may need to update the files in the /etc/firmware directory.
This will impact users of only a few devices, though all users can use
this step without harm.
To extract the firmware files from base40.tgz, use the
following as root:

Reboot on the new kernel:
This might be a tempting step to skip, but it should be done now, as
usually, the new kernel will run old userland apps (such as the soon to
be important reboot!), but often a new userland will NOT
work on the old kernel.

Install new userland applications.Do NOT install etc40.tgz and xetc40.tgz now, because
that will overwrite your current configuration files!

Note that it IS possible to locally modify these files, if this has been
done, manual merging will be needed.
Pay special attention to mail/sendmail.cf if you are using something
other than the default Sendmail(8) configuration.
Here are copy/paste lines for copying these files, assuming you unpacked
etc40.tgz in the above recommended place:

The changes to these files are in this
patch file.
You can attempt to use this by executing the following as root:

cd /patch -C -p0 < upgrade40.patch

This will test the patch to see how well it will apply to YOUR system,
to actually apply it, leave off the "-C" option.
Note that it is likely that if you have customized files or not kept
them closely updated, or are upgrading from a snapshot of 3.9, they may
not accept the patch cleanly.
In those cases, you will need to manually apply the changes.
Please test this process before relying on it for a machine you can not
easily get to.

The following files have had changes which should be looked at, but it
is unlikely they should be directly copied or merged (i.e., if you are
using pf.conf, look at the suggested change of strategy, and decide if
it is appropriate for your use).

2. Checking the kernel

Note: most people can skip this step!

If you followed the instructions for the upgrade process without install
media, you have already completed this step.
However, if you used the install media, and if you had a modified kernel
in 3.9, it is likely you will need to modify the stock kernel of 4.0.
This can be as simple as modifying a specific device using config(8),
or it can involve a recompilation if the option you need is not included
in the GENERIC kernel.
Please consult FAQ 5 - Building the system from source
before considering to recompile your kernel.

3. Upgrading packages

If you installed any packages on your system, you may want to upgrade them
after completing the upgrade of the base system.
The package tools support in-place updating using pkg_add -u.
For instance, to update all your packages, make sure PKG_PATH is
pointing to the 4.0 packages directory on your CD or nearest FTP mirror,
and use something like

# pkg_add -ui -F update -F updatedepends

where the -u indicates update mode, and -i specifies
interactive mode, so pkg_add will prompt you for input when it encounters
some ambiguity. Read the
pkg_add(1)
manual page and the package management
chapter of the FAQ for more information.