10.1. Installing the Linux Kernel source

The following are brief instructions for obtaining and installing the Linux kernel sources. Full information can be obtained from The Linux Kernel HOWTO.

In order to install and compile the Linux kernel, you need to be logged in as root.

  1. Change directory to the /usr/src directory cd /usr/src.

  2. Check in /usr/src/linux to see if you already have the sources installed.

  3. If you don't have the sources, get them from Linux kernel source directory or your nearest mirror. Select the appropriate directory- v2.0 if you are running a 2.0.x kernel, or v2.2 if you are running a 2.2.x kernel. If you are looking for earlier versions of the kernel (such as 1.2.X), these are kept in Old Linux kernel source directory.

  4. Choose the appropriate kernel - usually the most recent one available is what you are looking for. Retrieve this and put the source tar file in /usr/src. Note: a 'tar' file is an archive - possibly compressed (as are the Linux kernel source tar files) containing many files in a number of directories. It is the Linux equivalent of a DOS multi-directory zip file.

  5. If you already have the Linux sources installed but are upgrading to a new kernel, you must remove the old sources. Use the command rm -rf /usr/src/linux.

  6. Now uncompress and extract the sources using the command tar xzf linux-X.X.XX.tar.gz where "X.X.XX" is the version of the kernel you downloaded.

  7. Now, cd /usr/src/linux and read the README file. This contains an excellent explanation of how to go about configuring and compiling a new kernel. Read this file, (it's a good idea to print it out and have a copy handy whilst you are compiling until you have done this enough times to know your way around).