posted by Clinton De Young on Mon 3rd Mar 2003 03:07 UTC

"Step by Step Kernel building, requirements"

PREPARING THE 2.4.20 KERNEL'S SOURCE

In the last section, we downloaded the kernel source code. Currently it is contained in one compressed file (linux-2.4.20.tar.gz) in you home directory. In this section, we will move this source code to the correct location and uncompress it.

In order to compile the new kernel, we need to place it in the /usr/src directory. You may be asking yourself, "If I wanted the kernel source file in the /usr/src directory, why didn't I save it there in the first place?" The answer is that you didn't have rights to do so since you were logged in as a normal user (at least I hope you were logged in as a normal user and not as root).

I don't recommend surfing the web as the root user. Your computer is not going to explode or anything like that, but it is risky if you do everything as root. Therefore, I suggest downloading files off the internet as a regular user and saving them to your home directory. Once your download is complete, you can use the "su" command to log in as root and move the files into more secure locations if necessary.

If you are familiar with Linux (don't worry if you are not, I'll help you more in a minute), login as root and move the "linux-2.4.20.tar.gz" file from your home directory, where you saved it, to the "/usr/src" directory.

Next, uncompress the file by entering "tar xvzf linux-2.4.20.tar.gz" at the command line. This will create a directory called "linux-2.4.20" inside the "/usr/src" directory.

Next, create a symbolic link named "linux", which points to the "linux-2.4.20" directory by entering "ln -s linux-2.4.20 linux" at the command line. If this symbolic link already exists, delete it and create it again as described above.

You may now skip over the rest of this section and go to the "APT FILES NECESSARY TO CONFIGURE AND COMPILE YOUR KERNEL" section.

If the above four paragraphs were confusing to you, here are the same steps in almost mind numbing detail.

In order to move the "linux-2.4.20.tar.gz" file to the correct location, follow these steps:

Step 1: (Open a terminal window)
If you followed my installation document, you will be running the WindowMaker window manager. If you are, then right click on the desktop to bring up the menu, click on XShells, and then click on XTerm to bring up a terminal window. If you are running a different window manager, use whatever method your window manager requires in order to launch a terminal window.

Step 2: (Go to the directory where you downloaded the "linux-2.4.20.tar.gz" kernel file)
Make sure you are in your "/home/" directory (or wherever you saved the linux-2.4.20.tar.gz file). To do this, Enter "pwd" at the command line. pwd will tell you which directory you are in. If pwd returns something other than your home directory, enter "cd /home/" at the command line to get to your home directory.

Step 3: (Log in as root using "su")
Now you need to log in as root by entering "su" at the command line if you haven't already. Enter the root user's password when prompted.

Step 4: (Move the "linux-2.4.20.tar.gz" file to the "/usr/src" directory)
Now enter "mv linux-2.4.20.tar.gz /usr/src" at the command line. This will move the "linux-2.4.20.tar.gz" file from your home directory to the "/usr/src" directory. If you get a "Íno such file or directory" error, you either did not download the kernel file, or you are not in the directory you downloaded the file to. Go to the directory you downloaded the kernel source in to and try this step again.

Step 5: (Check the /usr/src directory)
Change to the "/usr/src" directory by entering "cd /usr/src" at the command line. At the command prompt, enter the "ls -l" command. As you probably know, the "ls" command shows you a list of all the files in the current directory. The "-l" switch after "ls" shows you more information than when you only type "ls" by itself. It shows you the "long" format; hence the '-l'. You should see the "linux-2.4.20.tar.gz" file we just copied into this directory. It should be the only file there. If this is the case, skip the rest of this section and go to Step 6.

It is possible that the directory has other files other than the "linux-2.4.20.tar.gz" file we just copied here. If you have the source code for an old kernel on your machine, it will be in this directory as well. Also, you may have a symbolic link pointing to these old kernel sources.

Before I go on, let me explain what a symbolic link is. A symbolic link is a link or alias that points to another file or directory. If you are familiar with Windows, a symbolic link is similar to a Shortcut. We will create a symbolic link in Step 6, so if they still aren't clear, hopefully they will be after you make one.

Now, please look at the other files in the "/usr/src" directory. Is there one named "linux"? If not, you may skip the rest of this section and go to Step 6. If there is an item in this directory named "linux", check to see whether it is a symbolic link or a regular directory. You can determine this by using the "ls -l" command and looking at the output. Enter "ls -l" at the command line. The output may be something like this (only formatted better).

lrwxrwxrwx    1 root     src            12 Oct 31 13:03 linux -> linux-2.4.18
drwxr-xr-x   14 573      573          4096 Aug  2 18:39 linux-2.4.18
-rw-------    1 clinton  clinton  32219641 Oct 30 14:40 linux-2.4.20.tar.gz
Let me use the first file listed as an example to explain where you need to look. The first part "lrwxrwxrwx" shows the file type and permissions of this file.

The first character, 'l' indicates that this file is a symbolic link. Directories, on the other hand, are indicated by a 'd' in this position instead of an 'l'. Regular files are indicated by a '-' in the first position (there are some other characters that can appear here as well, but they are beyond the scope of this document). The other characters are referring to file permissions for the user, group, and other users respectively. I am going to ignore these for now.

I am also going to skip by the entire middle section of the directory listing and move to the end, which is the name of the file. If you look at the three files listed above, you will notice that the top one shows the name of the file "linux", followed by an "->" and then "linux-2.4.18. This means that the file "linux" is a symbolic link that points (hence the nice arrow ["->"] motif) to "linux-2.4.18". If you look at linux-2.4.18, you will see that it is a directory (notice the very first character of the "linux-2.4.18" line is a 'd' signifying a directory).

Once you have determined that you have a "linux" file in the "/usr/src" directory, do one of the following.

If the "linux" file is a symbolic link, delete it by entering "rm linux" at the command line.

If the "linux" file is a directory, rename it by entering "mv linux linux.old.one" at the command line.

You should now be ready to continue.

Step 6: (Uncompress the "linux-2.4.20.tar.gz" file)
Now we need to uncompress the linux-2.4.20.tar.gz file so we can access the kernel source. To do this, enter "tar xvzf linux-2.4.20.tar.gz" at the command prompt. It will take a while to uncompress the "linux-2.4.20.tar.gz" file. When it is done, you should be back at the command prompt ('#') again.

Step 7: (Creating a symbolic link called "linux", which points to "linux-2.4.20")
Finally, we can create a symbolic link called "linux" that will point to our new kernel source code, which is located in the "linux-2.4.20" directory. Enter "ln -s linux-2.4.20 linux" at the command line to create this symbolic link. If you type "ls -l" at the prompt, you should now see a symbolic link called "linux" that is pointing to the "linux-2.4.20" directory (or the directory for whichever version of the kernel you decided to download).

APT FILES NECESSARY TO CONFIGURE AND COMPILE YOUR KERNEL

In order to configure and compile our kernel, we are going to need to use apt (or Synaptic if you prefer) to download a few things.

Enter the following command, while logged in as root, to download what we need (or select each of the items in this list from within Synaptic and install them that way):

"apt-get install tk8.2 make gcc bin86 libc6-dev kernel-package"

In this tutorial, I will be using the graphical kernel configuration tool from within X. If you would rather use the command line configuration tool, you will need to replace "tk8.2" with "libncurses5-dev" in the command above (or you can install both of them and do it either way you want to; depending on your mood).

After everything is downloaded and installed, a screen titled "Configuring Binutils" will be displayed. It is warning saying that this version of binutils will not work with some kernels. Since we are using the latest stable kernel, we will not have any problems. Just press enter to continue.

Table of contents
  1. "Intro, Downloading the kernel"
  2. "Step by Step Kernel building, requirements"
  3. "Configuring the kernel"
  4. "Configuring for sound, ext3 and burners"
  5. "Compilation, Installing the kernel"
  6. "ext3 journaling, troubleshooting, conclusion"
e p (0)    59 Comment(s)

Technology White Papers

See More