3. Making sure you have everything you need

3.1. Adding user to group src

Now we need to look at the kernel sources to ensure we have all the programs we need installed. The kernel sources are by default installed into the /usr/src directory. Normally you need to be the root user to do the things we need to do here. Since you should always try to avoid being the root user whenever possible, we are going to do something, which will allow us to do everything we need to do, as a regular user. Open a terminal and issue this command (you will need to become the root user for this):

bash# addgroup your_username src
Adding user your_username to group src...
Done.

Making sure to substitute your user name for your_username. This should add your_username to the src group. In order for this to actually take place, you need to logout and re-login. There are three ways you may need to do this:

  1. If you're in a terminal window inside X you must log out of X, then logout of the console and then log back in.

  2. If you're using a graphical login manager like xdm, gdm, or kdm, you should only have to log out of X and back in again.

  3. If you're at the console just log out real quick and log back in.

To make sure it actually took, you should issue this command (once you've done the login/logout dance):

bash$ groups
your_username src

You should see the src group as shown in the above example. Next, we need to set up the source tree.

3.2. Setting up the source tree

The source tree is just another name for the directory which contains all the source code you will be compiling. Change to the directory /usr/src where all the source files are kept so we can check to see if we have everything we need. Do this:

bash$ cd /usr/src

In that directory you'll see the bzipped tar file which you installed using apt-get (or gzipped, depending on whether you used apt-get or not):

bash:/usr/src$  ls
kernel-source-2.2.19.tar.bz2

Warning

If you downloaded kernel sources from anywhere other than the Debian site you need to make sure you do not have a symlink called linux in your /usr/src directory. If you do you should remove that symlink before unzipping any sources. If you do not remove it before unzipping there is a good chance you will overwrite old source files and you will probably get a mess which may or may not compile correctly. Jump ahead to the section called Setting up the symlink. If you downloaded the sources using the apt-get command from the "What to install" section, you can ignore this warning.

To unzip the tar file using bzip do (this should be done as a regular user!):

bash:/usr/src$  tar -xIf kernel-source-2.2.19.tar.bz2

Note

The version of tar in stable (aka Potato) uses the -I option for bzip2 compression. If you're using a newer version of tar there's a chance it uses the -j option for bzip2 compression.

To unzip the tar file using gzip do (this should be done as a regular user!):

bash:/usr/src$  tar -xzf kernel-source-2.2.19.tar.gz

This should create a directory called kernel-source-2.2.19. Inside that directory you should find another called Documentation. Change into that directory and look for a file called Changes. Open that file with your favorite text editor and look for the section called Current Minimal Requirements. Here's what mine looked like:

The changes document above lists the program in the first column, the required version in the 2nd, and the way to check for the version in the 3rd. Note that you may not need all the packages listed if you aren't currently using them in your system (i.e. you won't need pcmcia-cs if you're not using any pcmcia cards).

Note

This documentation was written by a kernel developer based on the distribution of Linux he/she was working on. What that means is some of these commands may not work for determining versions installed on your Debian system. If that's the case, try finding the version command to use by following the example below.

bash:/usr/src$ man program_name

Substituting program_name for the program you're wondering about.

3.3. Setting up the symlink

Once you have everything you need installed (cross your fingers) you need to set up a symlink to the source tree.

bash:/usr/src$  cd /usr/src

Before you make a symlink called linux check to make sure you don't already have one in that directory by following Example 2. If you already have one there, it's probably because you have installed or compiled kernel source before. Make sure you remove the old link and make a new one which points to the source tree you wish to compile.

In that same directory (/usr/srcyou need to create a "soft link" or symlink to the source tree. You do that like this:

bash:/usr/src$  ln -s kernel-source-2.2.19 linux

The format for this is ln -s name_of_kernel_source_tree linux.

The directory that was created when you unzipped your kernel source is what is substituted for name_of_kernel_source_tree.

To make sure you did it correctly it's a good idea to do an ls -l. It should look like the example below.

Example 2. Symlink

bash:/usr/src# ls -l
total 66908
-rw-r--r--    1 root     root     15433132 Apr  7 21:38 kernel-source-2.2.19.tar.bz2
drwxr-sr-x   15 jesse  (1)src          4096 May 23 16:30 kernel-source-2.2.19
lrwxrwxrwx    1 jesse    src            20 May 23 19:16 linux -> kernel-source-2.2.19
                                                               (2)
(1)
Notice that the group for the kernel source tree and the link are both src. This will allow you to compile the source without being the root user. You should be in the src group because of what you did in the "Adding user to group src" section.
(2)
Notice the little arrow which shows the link is pointing to the kernel source tree.

Now that you have the symlink set up we can move on to configuring the kernel.