Tips for Compiling and Installing a Linux 2.6 Kernel - Page 2

 By Carla Schroder
Page 2 of 2   |  Back to Page 1
Print Article
Continued From Page 1

Software Requirements
Kernel compilation is fussy about the tools used. Here's the major software requirements from the Documentation/Changes file, which you'll find in the kernel tarball.

Gnu C 2.95.3 # gcc --version
Gnu make 3.78 # make --version
binutils 2.12 # ld -v
util-linux 2.10 # fdformat --version
module-init-tools 0.9.10 # depmod -V
e2fsprogs 1.29 # tune2fs
jfsutils 1.1.3 # fsck.jfs -V
reiserfsprogs 3.6.3 # reiserfsck -V 2>&1|grep reiserfsprogs
xfsprogs 2.6.0 # xfs_db -V
pcmcia-cs 3.1.21 # cardmgr -V
quota-tools 3.09 # quota -V
PPP 2.4.0 # pppd --version
isdn4k-utils 3.1pre1 # isdnctrl 2>&1|grep version
nfs-utils 1.0.5 # showmount --version
procps 3.1.13 # ps --version
oprofile 0.5.3 # oprofiled --version

It's important to pay attention to these, especially gcc. If you compile your new kernel with any other version of gcc, you'll probably get errors. Most newer Linux distributions ship with gcc 3.x. You can have more than one version of gcc installed on your system. Install gcc 2.95.3, without overwriting your existing gcc installation, then invoke it with

# gcc -V 2.95.3

We'll go into compilation in-depth in Part 2.

Note that you can safely ignore anything that you don't need. For example, if you're not running quota, you won't need to update quota-tools, even if it's on your system. If you're not using the JFS filesystem you won't need jfsutils. And so forth. These items matter only if you're using them. The most important programs are gcc, Gnu make, binutils, util-linux, and module-init-tools, because these all relate directly to kernel-building.

Download and Unpack Your Shiny New Kernel Sources
Get the latest stable 2.6 kernel from The Linux Kernel Archives. Click on the "F" to get the complete kernel source. It's a 32MB download, and it unpacks to 172MB. Download and unpack it somewhere in your /home directory. The traditional way is create ~/src, and unpack it in there:

$ bzcat linux-2.6.3.tar.bz2 | tar -xvf -

Be sure to review the Documents directory. There are bales of good information in there. README gives installation instructions. Next, it's a good idea to make printouts of your hardware information, you will need it. Make a hard copy of /etc/fstab, and print out the output of lscpi:

$ lspci | lpr

and dmesg:

$ dmesg | lpr

If the margins are too small, use lpr -o page-left=72 -o page-right=72 to set them at one inch.

Check your /usr/src directory for a .config file. There won't be one if you've never compiled a kernel on the system. If it does exist, make a backup copy, because it's going to be overwritten. Then run

$ make mrproper

This resets the source directory to a pristine state, giving our new kernel a clean start.

The first thing we want to do is find ../linux-2.6.3/Makefile and edit it. At the very beginning are these lines:

NAME=Feisty Dunnart

Yes, the 2.6.3 kernel is named Feisty Dunnart (see Resources.) What we want to do here is give EXTRAVERSION a unique value, so that we can quickly identify this kernel. This can be anything, like -shiny-new-test-kernel, so after it's all built and installed, the kernel name will look like this:

$ uname -r

We're almost there. If you can't wait for Part 2 and want to leap ahead, keep in mind that almost all of the steps in building a kernel can, and should, be done as an ordinary, unprivileged user. Only two steps require root privileges: running make modules_install, and editing your boot loader.

2.6.2 aka "Feisty Dunnart" release announcement
The Kernel-HOWTO

» See All Articles by CrossNodes contributor Carla Schroder

This article was originally published on Mar 11, 2004
Get the Latest Scoop with Networking Update Newsletter