Update FreeBSD

General Information

This guide will walk a user through updating his source to follow FreeBSD’s stable branch. Please make a full backup of the current system before following this guide.

Requirements

  1. A working install of FreeBSD 5.x (steps may work in other versions)
  2. Root access
  3. Internet access

Installation

Login as root (or login as a user and su to root). Install cvsup and fastest_cvsup with either of the following methods.

# cd /usr/ports/net/cvsup_without_gui
# make install distclean
# cd /usr/ports/sysutils/fastest_cvsup
# make install distclean

or

# pkg_add -r cvsup-without-gui
# pkg_add -r fastest_cvsup

Copy the sample supfile for Stable to the root directory

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

Run cvsup to download the latest stable source using the fastest cvsup server near you.

# cvsup -L 2 -h `(fastest_cvsup -q -c us )` /root/stable-supfile

When the cvsup has completed, change to the /usr/src directory

# cd /usr/src

Now take the time to read /usr/src/UPDATING. This file will contain information that may be needed to properly update the FreeBSD source.

Now it is time to compile this source. This is called building world.

# make -j4 buildworld

Note: The -j4 switch is used to spawn multiple processes and according the FreeBSD Handbook, testing shows that this speeds up building world even on a single CPU system.

Now build a new kernel. To rebuild the GENERIC kernel, simply run the following command:[/code]

# make buildkernel

To build a new kernel using a custom kernel configuration file, run the command as follows:

# make buildkernel KERNCONF=MYKERNEL

Note: To create a custom configuration file, go to /usr/src/sys/i386/conf and make a copy of the GENERIC file; name it something like MYKERNEL. Editing the kernel configuration file is beyond the scope of this walk-through.

Now boot to single-user mode. This is important because replacing system files while in use in a running system is not a good idea.

Note: Installing the kernel and world in single-user mode is not required. It is only the safest method. If you wish, you can do the entire process from multi-user mode.
# shutdown now

Once in single-user mode, run the following commands to get access to the file system and the swap.

# fsck -p
# mount -u /
# mount -a -t ufs
# swapon -a

Change to the /usr/src directory.

# cd /usr/src

Now install the new kernel. To install the rebuilt GENERIC kernel, simply run the following command:

# make installkernel

To install a newly built custom kernel, run the command as follows:

# make installkernel KERNCONF=MYKERNEL

Reboot

# reboot

On boot up, select option 4 to boot to single-user mode. Once in single-user mode, run the following commands to get access to the file system and the swap.

# fsck -p
# mount -u /
# mount -a -t ufs
# swapon -a

Change to the [code]/usr/src directory.

# cd /usr/src

Run mergemaster -p to compare only those files that are essential for the success of buildworld or installworld.

# mergemaster -p

Select No to when prompted to remove /var/tmp/temproot. Now install the new world.

# make installworld

Now run mergemaster to compare all the configuration files.

# mergemaster

Note: Unfortunately the mergemaster is the most complex and the least amount of help is provided. Understanding how mergemaster works will help. It compares the configuration files in use on the current system with the new configuration files from the newly compiles source. It uses diff to display both files at the same time. Lines that are new and will be added if the new configuration file is installed have a plus (+) sign by them. Lines that will be removed from the configuration file if you install the new one have a minus (-) sign by them. One tip is that if the changes are only to comment lines (comment lines begin with a pound (#) sign) it is usually safe to install the new configuration file. Another tip is that if there is a minus (-) sign next to something that needs to be kept, do not install the new file but either leave the file to be dealt with manually or merge the two files.
Note: It is common to run mergemaster multiple times.

Reboot the system.

# reboot

Once the reboot has completed, the system should boot the stable release. Login and verify that everything is working correctly.

Note: It is a good idea to update the ports tree after rebuilding from source. See the following guide for updating the ports tree.

http://www.bsdguides.org/guides/freebsd/misc/update_ports_tree.php

Speak Your Mind

*