Installing the source code
FreeBSD has lots of functionality awaiting you but not all functionality is enabled by default. This is true for the traffic shaping framework ALTQ that you will rely upon. To enable ALTQ you will have to recompile part of FreeBSD and for that you need its source code. A small tutorial of the terminology used in FreeBSD is in place.
The kernel is the central part of an operating system that contains all hardware drivers. It's responsible for managing CPU, memory and all I/O resources. You'll need to recompile the kernel to add support for ALTQ.
The userland is simply put the rest of the operating system that doesn't belong to the kernel. All the command line utilities you use to communicate with the operating system belong to the userland as do all the shared libraries that contain useful programming code that can be used by applications. In FreeBSD and other BSD versions, kernel and userland are developed together. If you upgrade one of them you have to upgrade the other. This is a fundamental difference compared to Linux where the kernel is developed separately by Linus Torvalds and kernel.org and the userland is developed and maintained by each Linux distribution.
At some point you'll need to install some applications, like the webserver Apache for example. These applications are not part of the operating system but source code can be freely downloaded from each application's developer website and compiled and installed on your system. Many programs may have to be patched and altered to be able to compile at all. For this you need programming skills and a deep knowledge of the application which the average user doesn't have. To avoid this dilemma, FreeBSD has a software repository where source code for thousands of popular applications are kept, maintained and patched for you so it will compile easily. This repository also provides a way of installing the software automatically or semi-automatically, either through the source code directly or through pre-compiled binaries. In FreeBSD this repository is called Ports but similar functionality can be found in many Unix and Unix-like operating systems but with other names.
Branches and releases
The FreeBSD source code is undergoing continuous development. Now and then the code is frozen and a release is made. The code is then branched and development continues in that branch. Development is actually ongoing in two separate branches:
There's one called CURRENT where all the latest stuff and functionality is added. It's highly experimental and will fail to compile from time to time. It's probably a very bad idea to follow this branch in your case.
The other development branch is called STABLE. The name is a bit misleading because this branch can break sometimes too but not nearly as often as CURRENT. STABLE receives its updates from CURRENT when they've been tested there for a while. It's the STABLE branch that gets frozen from time to time and where new releases are issued from. The development going on there right now will in time become the next version of FreeBSD. This branch could be more interesting to follow when you get a bit more experienced.
There is however a third alternative called RELEASE. This is the frozen source code for the current version of FreeBSD. The only changes made here are security updates and bug fixes. In this tutorial, this is the branch you will focus on.
To get the source code you can use a program called csup which comes with FreeBSD. If you're alert you'll notice that there are several references to cvsup below. cvsup is a similar program but it's not part of the base system and has to be installed separately - that's why you should use csup instead.
csup needs a configuration file so it knows what code to get and where to get it from. The configuration file is referred to as a supfile and there are several commented examples located in /usr/share/examples/cvsup that you can study. You'll have to create a supfile that will receive the RELEASE branch and all ports. Well, the ports' source code is several gigabytes so what actually will be downloaded is only metadata that tells the system how to get the real source code when requested. This will only occupy a few hundred megabytes.
The supfile can be called anything and it's up to you where you store it. I prefer to call it supfile and store it where the source code usually resides - in the /usr folder.
# ee /usr/supfile
Copy and paste the following lines into the file:
*default host=cvsup.FreeBSD.org *default base=/var/db *default prefix=/usr *default release=cvs tag=RELENG_7_0 *default delete use-rel-suffix src-all ports-all tag=.
The *default host defines the mirror you will get the source code from and you're expected to change it to a mirror close to you. Local mirrors are listed in this document on FreeBSD's web site.
The various code branches are represented by tags. All available tags are described in this document. Note that updates have stopped a long time ago in most of the older branches. RELENG_7_0 is the tag for Freebsd 7.0-RELEASE and will provide what you need.
When you're satisfied with the content of your supfile, exit the editor and save the changes. Then perform the commands below to download the initial copy of all the source code.
# cd /usr # csup supfile
It will take a little while to finish this, I counted 43 minutes on my router but it will depend on the mirror you choose, the speed of your Internet connection and also the speed of your computer. Updating the source tree from now on will be much faster and to do that you only have to execute the last two commands - simple as that. Remember that it's considered rude to update the sources too often. Abuse may result in you being banned from the mirrors, their bandwidth is limited after all and you're not the only FreeBSD user out there.
- csup is the command to get the source code. It needs a configuration file to tell it what to do. Examples can be found in /usr/share/examples/cvsup.
- Synchronizing Your Source in the FreeBSD handbook.