How to upgrade FreeBSD to the next -STABLE Version

Attention: open in a new window. PDFPrintE-mail

 

 

The very first thing we want to do is find out what version we are using. Run the following command:

# uname -a

And it should print out something on the next line. I am going to use this example to upgrade FreeBSD from 9.3 to 10.1

FreeBSD mail.domain.xxx 9.3-STABLE FreeBSD Fri Jul 13 25 00:53:24 CDT 2015 [email protected] :/usr/obj/usr/src/sys/GENERIC i386

There are a few things to note. The date after that indicates when the last build took place. Rather old system so we need to update it to 10.1 so lets get started!

We need to tell FreeBSD to download the latest sources for FreeBSD 10.1. Lets get rid of the current sources:

#

pkg install ca_root_nss


# cd /usr/src
# rm -dfr *

Now we will want to install subversion. If you have already installed subversion please skip this step.


# cd /usr/ports/devel/subversion
# make install clean

Wait until it downloads a few things and then the install will be completed. At this time there are a few subversion sites to fetch sources and ports from. Please note that if you have extracted sources and ports via sysinstall or cvsup BEFORE going through this walk through then they will need to be deleted first and then checked out by subversion. Updating is easy after that.

We need to first sync ports and sources so lets get rid of the current /usr/ports and /usr/src:


# rm -dfr /usr/ports
# rm -dfr /usr/src
# mkdir /usr/ports /usr/src

A list of the current subversion sites are below.

https://www.freebsd.org/doc/handbook/svn.html#svn-mirrors

Now we need to checkout both ports and sources using the following commands. Replace HOST with the closest mirror to you (See link above). Also on the 2nd line if you are using FreeBSD 9 then the command shown will work fine.


# cd /usr/ports
# svn checkout https://svn0.us-east.FreeBSD.org/ports/head /usr/ports
# cd /usr/src
# svn checkout https://svn0.us-east.FreeBSD.org/base/stable/10 /usr/src

Please DO NOT continue until sources and ports and have synched.

Lets backup etc first:


# rm -dfr /backup/ (If this directory does not exist then please ignore this step)
# mkdir /backup/etc
# cp -Rp /etc/* /backup/etc

You will now need to tell your stable-supfile to use the RELENG_10 tree. The stable-file example file is located at:


# /usr/share/examples/cvsup/stable-supfile

It may be a good idea to look through /usr/ports/UPDATING so take a look:


# vi /usr/ports/UPDATING

Now to remove the old obj files.


# chflags -R noschg /usr/obj/*
# rm -fr /usr/obj/*

Now to build the world.This guide is meant to help you streamline the process of building and installing world. You can find a more direct resource located at

http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html

If you have a multi-core processor, or multi-processor system, you can do:


# cd /usr/src
# make -jX buildworld

Otherwise run the following command:


# cd /usr/src
# make buildworld

And then build and install the kernel


# cd /usr/src
# make buildkernel KERNCONF=GENERIC
# cd /usr/src
# make installkernel KERNCONF=GENERIC

Booting into single-user mode
Reboot with your new kernel into single-user mode


# reboot

When your computer reboots, It will bring you to a menu of options. Choose Single-User mode and hit Enter.
Hit [Enter] to boot immediately, or any other key for command prompt.

Booting [kernel] in 9 seconds...

Hit any other key other than [ENTER] to enter single-user mode.

It asks for the location of the shell to be used

choose /bin/sh (just press Enter or Return as this is the default)

Now we need to mount the filesystems


# adjkerntz -i
# mount -a -t ufs

Now to Install world


# cd /usr/src
# mergemaster -p

This does some initial configuration file updates in preparation for the new world. For instance it may add new user groups to the system, or new user names to the password database. This is often necessary when new groups or special system-user accounts have been added since the last update, so that the installworld step will be able to use the newly installed system user or system group names without problems.

At the end you will get prompted Do you wish to delete what is left of /var/tmp/temproot? [no]. Hit Enter for No. It will spit out an output. Continue on.


# make installworld

Now to update /etc


# /usr/sbin/mergemaster

Update /stand


# cd /usr/src/release
# make all install

Reboot and enjoy your new -STABLE system


# fastboot

To summarize, the currently recommended way of upgrading FreeBSD from sources is:

# cd /usr/src
# make buildworld
# make buildkernel
# make installkernel
# shutdown -r now

Note: There are a few rare cases when an extra run of mergemaster -p is needed before the buildworld step. These are described in UPDATING. In general, though, you can safely omit this step if you are not updating across one or more major FreeBSD versions.

After installkernel finishes successfully, you should boot in single user mode (i.e. using boot -s from the loader prompt). Then run:

# adjkerntz -i
# mount -a -t ufs
# mergemaster -p
# cd /usr/src
# make installworld
# mergemaster
# reboot

Read Further Explanations: The sequence described above is only a short resume to help you getting started. You should however read the following sections to clearly understand each step, especially if you want to use a custom kernel configuration.