While it would always be a possibility to reformat and install FreeBSD 6.0, there's no reason not to take advantage of FreeBSD's upgrade capabilities. Before we even begin, BACK UP YOUR DATA. There's no way to stress this enough. Whatever time you lose in being cautious is more than saved for that one time when you do need the backup. I would at least backup your home directory, and all of /etc before continuing. This is pretty easy to do if you have a CD-RW or DVD-RW drive. You'll probably want to use a graphical CD-burning program such as K3B, featured in our section on CD Burning, but you could also give command-line burning a whirl.
Now that you've backed up your relevant data, we can continue. As always, su to root. The first thing you want to do is edit /etc/make.conf and add the following lines:
SUP_UPDATE=yes
SUP=/usr/local/bin/cvsup
SUPFLAGS=-g -L 2
SUPHOST= cvsup4.FreeBSD.org
SUPFILE=/root/standard-supfile
KERNCONF=NEWKER
In the last line, NEWKER refers to the name I gave my custom kernel. See our section on building a custom kernel for more details. If you're running a GENERIC kernel (i.e. you didn't bother to build a custom kernel), delete this last line. Obviously, if you created a custom kernel and labeled it something other than NEWKER, you'll want to refer to the name you gave your kernel. (For example, KERNCONF=CUSTOM).
SUPHOST (4th line from the bottom) refers to the cvsup mirror you wish to target. It can be cvsup.FreeBSD.org through cvsup9.FreeBSD.org. Choose whichever one you like (probably whichever is the fastest for you).
Now that you've done that, we'll setup our supfile.
cp /usr/share/examples/cvsup/standard-supfile /root/
vi /root/standard-supfile
You only need to edit two lines, *default host, which you'll want to make refer to one of the aforementioned cvsup mirrors, and *default release, which you'll want to change to RELENG_6_0. The relevant section of my standard-supfile looks like this:
# Defaults that apply to all the collections
#
# IMPORTANT: Change the next line to use one of the CVSup mirror sites
# listed at http://www.freebsd.org/doc/handbook/mirrors.html.
*default host=cvsup5.FreeBSD.org
*default base=/var/db
*default prefix=/usr
*default release=cvs tag=RELENG_6_0
*default delete use-rel-suffix
This is a read-only file, so to save your changes, type:
:w!
This will write your changes anyway. This is a very useful vi command. Now you can :q! to exit.
Now that we've updated the necessary config files, let's get this show on the road.
cd /usr/src
make update
One of two things will happen. 1) You'll see a lot of scrolling text as cvsup checks out the 6.0 sources and downloads them to /usr/src, replacing your old sources. 2) You'll receive an error message along the lines of "don't know how to make update". If you receive this error, it means that you don't have source installed on your system. To install source. . .
cvsup -h cvsup5.freebsd.org /root/standard-supfile
This will produce several minutes (on a high-speed Internet connection) of scrolling text as your system downloads the source to everything.
Either way, we're now ready to continue.
vi /usr/src/UPDATING
It is imperative that you read through this file before continuing (at least entries with recent dates). Otherwise you may miss essential notes and end up scratching your head as to why your build failed. At the time of writing, there was a very important note about needing to rebuild kernel modules. If you try and load your old 5.X kernel modules with a 6.X kernel, you will end up in a world of trouble. Now that we've finished reading through UPDATING, we'll take the precautions it recommends.
vi /boot/loader.conf
Now comment out all kernel modules that you have built from ports.
#nvidia_load="YES"
The nvidia driver was the only one in my case, but if you have others, comment them out as well. Once we're into 6.0, we'll have to rebuild them. As long as we're in this file we'll add an additional line.
loader_logo="beastie"
This is possibly the most important part of the upgrade, so make sure you do it. Now we can continue along.
make cleanworld
This will clean out all old build files. Unnecessary if you've never done an update before, but it won't hurt as an extra step.
make buildworld
Now we're building world. This will take awhile so you'll probably want to leave and come back.
make buildkernel
Now we're building the new kernel. This shouldn't take as long. If you have problems here, you might want to try taking out the line specifying the kernel config from /etc/make.conf, and building a generic kernel.
make installkernel
Now we're installing the new kernel. If the kernel install finishes successfully, we're ready to reboot. When we reboot we'll want to go into single user mode. That means hit "4" when you get to the loader with beastie. If all goes well you'll be asked for your shell, and you can hit enter to get the default shell which will work fine. If you had no problems here, skip ahead.
On the other hand, you may get an error trying to boot off of the new kernel. If you do, hit "6" at the loader promt, to drop into a shell.
boot /boot/kernel.old
This will boot off of your old kernel. Once you are booted up, you should copy your old kernel over the new kernel that doesn't work.
cd /boot
cp -r kernel.old kernel
Now take the time to figure out what went wrong. When you've got it figured out, reboot back into single user mode, and continue on.
Now that we're in single user mode, on a bootable 6.0 kernel, we can finish the install.
fsck -p
First we're checking for any filesystem inconsistencies, just to make sure all is okay.
mount -u /
mount -a
Now we're manually mounting our filesystems.
mergemaster -p
mergemaster will compare new configuration files with our old files. It gives us a chance to update to new 6.0 configuration files, while keeping our old configurations as necessary. This is the reason it was so important to backup /etc. It is easy enough to make a mistake with mergemaster. In this case we are running it in prebuild mode.
As you can see from the instructions, i installs the new config file. Do this for files which you haven't modified. d will delete the new config file, so do this with files where you want to keep your configuration. m will merge the two files. It gives you options of which pieces to keep from each file. This is the most thorough way to keep old configurations, and you can do it if you are feeling ambitious. If you're lazy though, you should get by with the first two options. Just to note, files like groups, rc.conf, and passwd are ones you will most certainly want to keep your previous customizations.
Since we ran in prebuild mode, there were probably only one or two files you got prompted about. Now we can continue.
cd /usr/src
make installworld
After this we will have a complete 6.0 system. After installing the new world, you'll want to run mergemaster again, this time not in prebuild mode.
mergemaster
This time you'll be prompted for many more files. The commands are exactly the same. To quickly scroll through files you know you haven't modified, just hit 'End'. After mergemaster is done, reboot as normal, and we'll do the finishing steps.
As you remember, we had to disable our kernel modules built from ports. If you use the nvidia driver like me, this will render you unable to startx. So we'll force our system to rebuild all ports that gave us kernel modules.
portupgrade -f nvidia-driver
Now you can try starting X and hopefully all is well. Once you've successfully gotten into X, you can uncomment the line to load your nvidia driver. Enjoy 6.0!