Upgrading FreeBSD (using source method)

From time-to-time you will want to upgrade your FreeBSD system.  My preferred method is the source method.

To start, we need to create a file to define our source update.  Part of this requires you to choose a release engineering tag.  This is quite simple to generate.  It is the word RELENG followed by an underscore and the version number.  For example, if your system is running FreeBSD 8.1-RELEASE then your release engineering tag is RELENG_8_1.  If your system is FreeBSD 7.2-RELEASE, your tag is RELENG_7_2.

You can also, if you’re slightly braver, choose the ‘stable’ branch for your version of FreeBSD.  This is the tag with only the major number.  e.g. RELENG_8 for FreeBSD 8 stable.  This is my preferred version so I will use this in my examples.

Edit/create a file called /root/bsdsrc containing:

*default tag=RELENG_8
*default host=cvsup2.us.freebsd.org
*default prefix=/usr
*default release=cvs delete use-rel-suffix compress

src-all

You can change the host to be your local mirror.  See my post on updating the ports tree for a list of mirror sites.

Now, to update your source tree (the files in /usr/src), make sure you’re connected to the internet and run the following command:

csup /root/bsdsrc

This will take a while as it updates any files required based on your released engineering tag.  Once completed, your FreeBSD kernel/OS sources are up-to-date.

Now, we need to build a new kernel and recompile the entire OS.  This sounds far worse than it is 😉

To rebuild the OS, type the following:

cd /usr/src
make buildworld

If you have multiple CPUs/cores in your computer, you can speed this process up by using:

make -j5 buildworld

The number after the ‘j’ should be the number of cores plus one for optimal usage.

This will take a while depending on your system specification.  Once it is complete, you can build a new kernel.  If you are running a custom kernel, you would replace the kernel configuration name with your custom one below.  To compile a new kernel, type:

make buildkernel KERNCONF=GENERIC

Again, you can use the “-j5” notation from above to speed things up.

Ok, now you have both the OS and kernel recompiled and ready to install.  At this point, you have not installed any updates, merely compiled them ready to install.

To install, type:

make installkernel KERNCONF=GENERIC
make installworld

This will install the new kernel and install the OS files.  Now, there’s just one step remaining.  The files in /etc/ are never replaced by the install process – but they may have changed between versions.

FreeBSD includes a handy little utility that compares RCS/CVS ids on these files and allows you to see the difference and install them.

To do this, type the following while in the /usr/src folder:

mergemaster -iFU

This will automatically install any files that the user has not modified, or new files.  Follow any instructions on the screen to handle other files.

Be weary about changes to /etc/group and /etc/master.passwd files.  If you’re unsure, pressing enter will make no changes to the file.

Once this process is complete, you just need to restart your computer and it will boot with the latest kernel and OS.

2 thoughts on “Upgrading FreeBSD (using source method)

  1. bhagat

    I have been using an old FreeBSD-6.4 Desktop machine. I want to upgrade this to the next FreeBSD version and finally to the latest release.

    Would you suggest can I follow the same procedure you mentioned here work for me ?
    What I need to enter for the following RELENG line to upgrade to the next possible version. Is it RELENG_7_0 ?
    *default tag=RELENG_

    Reply
    1. dan Post author

      The best way would be to use freebsd-update (I don’t have a specific guide for that, sorry).
      Using the source method, i’d generally not go between major versions. freebsd-update does a binary update and it knows which files to delete from the older version also.

      Reply

Leave a Reply to dan Cancel reply

Your email address will not be published. Required fields are marked *