FreeBSD cvsup: Update The FreeBSD From Previous Releases Using Source Code

by on June 24, 2008 · 4 comments· LAST UPDATED January 16, 2009

in , ,

Q. How do I update my system using cvsup mirror? How do I upgrade from previous releases using FreeBSD 6.x or 7.x? How do I upgrade everything including kernel, userland utilities, and installed applications?

A. FreeBSD can be upgrades from a local / remote cvsup mirror. csup is a software package for updating collections of files across a network. It is a general-purpose network file updating package. It is extremely fast, even for collections of files.

Upgrading FreeBSD

You need to upgrade FreeBSD using two steps as follows:

  1. First, upgrade the base system
  2. Update all installed application programs or ports.

Naturally, the base system must be upgraded before the applications.

WARNING! These examples only works with FreeBSD 6.2 or above version only. Make a backup of your system / data / config files before you use following commands. The system will be offline for about 10-30 minutes due to reboot and single user mode upgrade operations, so update system during off-peak hours.

Step # 1: Upgrading the FreeBSD base system

First, copy csup configuration file to /etc or /root directory:
# cp /usr/share/examples/cvsup/standard-supfile /root/supfile
Open /root/supfile using vi text editor, enter:
# vi /root/supfile
You need to make one change. Find the line that read as follows:
host=CHANGE_THIS.FreeBSD.org
Change to:
host=cvsup4.us.FreeBSD.org
host directive specifies the server host which will supply the file updates. You must change it to one of the CVSup mirror sites listed in the FreeBSD Handbook. Another option is to override this setting on the command line with cvsup's "-h host" option. Save and close the file. Now update source tree, enter:
# cd /usr/src
# csup /root/supfile

Build the base system

Once you have synchronized your local source tree, you can then use the source tree to rebuild the base system. It is important that you always read /usr/src/UPDATING file to save time. This file carries important information regarding upgrade procedure including known issues, bugs and workaround.
# vi /usr/src/UPDATING
Type the following command to build base system:
# cd /usr/src
# make buildworld

This procedure going to take sometime as everything is going to compiled from scratch. Powerful system with tons of memory can build everything within 10-15 minutes time. Once done build the FreeBSD kernel:using following syntax:
# make buildkernel
# make installkernel

OR
# make buildkernel KERNCONF={NAME}
For example, build and install GENERIC kernel, enter:
# make buildkernel KERNCONF=GENERIC
# make installkernel KERNCONF=GENERIC

Again depending on the capabilities of your machine and kernel configuration, it will take anywhere from 5-30 minutes to build kernel. Finally, you need to reboot system and boot into a single user mode using boot -s from the loader prompt:
# reboot

Install the base system

Now you need to use the mergemaster bourne shell script, which is designed to aid you in updating the various configuration and other files associated with FreeBSD. It is HIGHLY recommended that you back up your /etc directory. Mount the system:
# mount -a -t ufs
To install some system configuration files that are required by the new base system, enter:
# mergemaster -p
Accept the changes as promoted as per your configuration. Finally, install the base system:
# cd /usr/src
# make installworld

Finally, merge your configuration files, enter:
# mergemaster -i
You are now done with first stage, just reboot the system:
# reboot

Step # 2: Update FreeBSD Applications

Now you are running new FreeBSD environment. All you have to do is upgrade installed applications using portsnap, enter:
# portsnap fetch extract
To upgrade all installed FreeBSD ports / apps, enter:
# portversion
# portupgrade -a

You are now done with upgrading system. Now you have up to date patched kernel, base system and applications.

Further readings:

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 4 comments… read them below or add one }

1 Doug November 28, 2008 at 11:14 am

I got a data check error when I csup’ed on a standard fbsd7 system. As per manual advice I changed the supfile’s line

*default release=cvs …etc to
*default release=cvs delete …etc

Then csup worked returning finished succesfully.

I had installed the kernel source from an iso cd previously which may have been the problem.
It may help someone trying this out first time.

Doug.

Reply

2 Brent February 27, 2009 at 10:58 pm

Hi,
I went through the steps and all seemed to go well until the very last item.

portversion: not found
portupgrade -a : not found

Now, when I try a pkg_add packagename, it still looks for the 6.2 version and when I issue uname -a, it stills says 6.2.

Any hints to point a BSD newb in the right direction (a little different than the RedHat/Fedora world)?

Thx

Reply

3 Brent February 28, 2009 at 3:10 pm

Oh, got it. I had to change the OS version in the supfile, first time I just rebuilt the same tree I already had. When I changed the OS version from 6.2 to 7.1, I had an error with sendmail after running “make buildworld” on an old 600 mHz machine.

Reply

4 Dictator September 25, 2009 at 5:39 am

Thank you sir for your post. Finally someone in the unix world that can write at a level a human can understand without either a butt load of useless crap, or not enough notes as to what is what… You should write a book. :)

Reply

Leave a Comment

Tagged as: , , , , , , , , , ,

Previous Faq:

Next Faq: