Upgrading from 5.3-RELEASE to 5.4-RELEASE

In May 2005, FreeBSD 5.4-RELEASE became available. While the most obvious way to upgrade from 5.3 to 5.4 might be to download the 5.4 iso images (or to buy the official media from The FreeBSD Mall or BSD Mall), reformat your hard drive and install 5.4-RELEASE from scratch, you might want to keep your existing configuration, customizations, and applications. Fortunately, this is possible through the magic of a source upgrade.

Before you do anything, it is essential that you BACK UP YOUR DATA. While the upgrade from 5.3 to 5.4 seems to have been relatively painless in our case, that doesn't mean that it will be in your case. When doing something as drastic as what we're about to do, you should always back up your important data.

You might want to back up your home directory, as well as certain config files (/etc/rc.conf, /etc/hosts, /etc/ppp/ppp.conf, /etc/make.conf, etc.) before proceeding. 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 if you're like me (Kevin) and want quick and dirty, I'll give you a brief tutorial on command-line CD-burning.

If you don't care about command-line burning, or have already backed up your data in your own way, you can skip ahead.

First off, make sure you've completed our section on CD Burning, at least as far as configuring your FreeBSD system to use your CD-RW drive. If you did this, you shouldn't have a problem, but just to double-check you can always look in /usr/local/bin/ and make sure "cdrecord" exists.

First off, create a new directory. This is going to contain the files we want to burn onto our backup CD.

mkdir /big/backup

Where /big is our second hard drive. You can create this directory almost anywhere you want. Just make sure that you do NOT create it in your home directory (trust me), or in a directory off of /, because you will run out of room. You could even create a secondary user and create the directory in that user's home. For example, on my computer my home directory is /home/reinholz, so I created a "backup" folder in /home/mark.

Now that we have our backup directory, copy whatever files you want to include on your CD-R to backup.

cp -r /home/reinholz /big/backup

This will copy the entire contents of my home directory to the backup directory I created. Copy other files you want to backup as well.

cp /etc/rc.conf /big/backup

Once you've copied all of the files you want to backup to your backup directory, it is time to create an iso image that we can burn to a CD-R.

mkisofs -J -L -R -o freebsd_backup.raw /big/backup

This might take a little while (but you'll get a status indicator in your terminal window). When it's finished, check the size of your iso image. (mkisofs should display this when it finishes). If it's under 700MB, you're good to go if you're planning to burn to a CD-R and not a DVD-R. If it's too big, delete the image (freebsd_backup.raw), divide your backup into two directories, and redistribute the copies as necessary. Repeat the above "mkisofs" command and hopefully your images will be less than 700MB.

Now it is time to burn the CD. Insert a blank CD-R into your drive, or if you have an external USB CD-RW drive, plug it in and turn it on, then insert a blank CD-R into it. Since you probably don't know the device code for your CD-RW drive, issue the following command:

cdrecord -scanbus

This should generate a list of attached CD-ROM drives. Should be pretty easy to figure out which one is your burner. Note the device code. It should look something like "dev=2,0,0".

cdrecord -eject speed=52 dev=2,0,0 freebsd_backup.raw

That's it. You should see a timer count down in your terminal window, at which time your CD-RW drive should start burning the CD. When it is finished, it will automatically eject your CD-R.

That's it. All that's left to do is test the CD-R and see if when you mount it all of your files are there like they should be. For extra good measure you could even pop it into a different computer and see if it reads it okay. With the flags I set in my mkisofs, my backup CD was happily readable on my Mac OS X machine, and given the -J flag I set, should be happily readable on a Windoze computer as well (although permissions would be nonexistent).

Okay, it's time to upgrade from 5.3 to 5.4. I'll assume you are connected to the Internet (through DSL, cable, or if you're really in a hurry, fiber optic). Otherwise, you're not going to get very far. 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=/usr/share/examples/cvsup/standard-supfile
PORTSSUPFILE=/root/ports-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, edit /usr/share/examples/cvsup/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 from RELENG_5_3 to RELENG_5_4. It is also acceptable to specify RELENG_5_4_0_RELEASE. 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_5_4
*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 5.4 sources and downloads them to /usr/src, replacing your old 5.3 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 /usr/share/examples/cvsup/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.

make kernel

This combines the two commands "make buildkernel" and "make installkernel". This will do what it sounds like: it will build you a new kernel from source and install it. Because we specified our custom kernel in /etc/make.conf, the new kernel will retain all of our kernel customizations! (NOTE: this doesn't seem to be a problem when upgrading from 5.3-RELEASE to 5.4-RELEASE. For more dramatic upgrades, however, you'll want to make sure no drastic changes have taken place that will render your new kernel unbootable if it contains the customizations from the version of FreeBSD you're upgrading from. Just to be on the safe side you can always take out the line in /etc/make.conf specifying your custom kernel and have "make kernel" build and install a GENERIC kernel for you that you can later customize yourself).

After a while (a couple of hours on my old ThinkPad 1300), that will finish and you'll have a new kernel. Obviously you'll still be running your old kernel until you reboot. Before we do that, however, it's time to do one more thing:

make buildworld

This will build the world (your base, as in all of your system files) from the new 5.4-RELEASE source. This can also take a while if you're using an old computer like mine.

make installworld

This will replace your old world with the new. When this step has completed, you will want to run the following command:

mergemaster

mergemaster will clean up the configuration files between 5.3 and 5.4. It will present you with a filename, followed by the option to delete the old 5.3 file and keep the new 5.4 file, to keep the old old 5.3 file and delete the new 5.4 file, to merge the two files together (scary), or to do nothing (also scary).

Hit d to delete the old 5.3 file and keep the new 5.4 file. You'll probably want to do this with files you haven't customized. (Probably most of them).

Hit i to keep the old 5.3 file and delete the new 5.4 file. You'll probably want to do this with files you have customized (such as /etc/rc.conf, /etc/ppp/ppp.conf, etc.), unless you're worried about minor syntactical changes between 5.3 and 5.4 that might cause headaches. I kept my old, custom /etc/rc.conf file, and I believe this is the cause of a warning: $/swapoff not set properly error when I shutdown my computer. (The computer still shuts down fine). Obviously this can be manually corrected later.

Once mergemaster finishes, you can reboot your computer. Don't do anything at the boot prompt (except press 'Enter' for the default if you're impatient). You should boot happily into your new 5.4-RELEASE system.

That's it. Granted, this is not nearly as thorough as it could be, but for the relatively minor upgrade from 5.3 to 5.4, these steps were sufficient.

So why should you upgrade from 5.3-RELEASE to 5.4-RELEASE? Although it's always nice to track the current production release, for laptop users there are some added incentives. . .

On my IBM ThinkPad 1300 (type-model 1171-1VU), two wonderful things happened after my upgrade to 5.4-RELEASE. First and most important, pcmcia support seems to have been fixed. (It seems to have been broken in 5.x up through 5.3). This means that I can not only use my built-in wireless network card (wi0), which I used just fine in 5.3, but now I can also pop in a pccard ethernet card when I need to connect to a wired network.

Although not directly relevant to this section, for the sake of convenience I have my /etc/rc.conf set up to configure both my wired and wireless network cards at startup. If you're a laptop user and you want to configure both network cards using DHCP, add the following lines to rc.conf:

ifconfig_wi0="DHCP"
ifconfig_ep0="DHCP"

wi0 is my wireless network card, and ep0 is my old 3Com 589D ethernet card. Obviously change these accordingly. Running /stand/sysinstall, going to Configure, Networking, and Interfaces will list your detected interfaces. You can put those values into /etc/rc.conf in place of mine.

If my wired ethernet card isn't plugged in, it simply doesn't receive an IP address. If a wireless network is available, the wireless receives an IP address. If the wired ethernet card is plugged in, it is possible to receive two IP addresses: one for the wireless and one for the wired. Just a quick and dirty tip on DHCP configuration of multiple network cards for the lazy. . .

As an added bonus (besides pcmcia support), my CD-ROM drive, which didn't work in 5.3, now works in 5.4. :) So for laptops, especially my ThinkPad, 5.4 is a necessary upgrade.