Doug's Linux Notebook

Compiling the 2.6.x Kernel

Preraring to compile a new kernel:


The latest kernels are available at www.kernel.org. The kernel version is in three parts, major#. minor#. patch level. Kernels with an odd minor numbers such as 2.5.x, or 2.7.x are development or beta versions and may not be stable,it would be best to use only kernels with even minor numbers. 2.4.x, 2.6.x

For this example I will use kernel 2.6.11. Download linux-2.6.11.tar.bz2 cd to /usr/src and su to root, check to see if /usr/src/linux is a directory or a symlink.

[root@linux]$ cd /usr/src
[root@linux]$ ls -l

If you see something like "linux -> linux-2.6.6" then "linux" is a symlink and needs to be removed.

[root@linux]$ rm linux

If "linux" is a directory then rename it using the kernel version numbers

[root@linux]$ mv linux linux-2.6.6

I used 2.6.6 as an example.

[root@linux]$ uname -r

to find out the version of the curent kernel.

Now you are ready to unpack the new kernel source,

[root@linux]$ tar -jxvf /path-to-downloaded-file/linux-2.6.11.tar.bz2

or if you downloaded the .tar.gz insted of the .tar.bz2

[root@linux]$ tar -xvzf /path-to-downloaded-file/linux-2.6.11.tar.gz

This is a large file so it will take a minute to unzip, then there will be a new directory named linux-2.6.11

Now make a new symlink

[root@linux]$ ln -s linux-2.6.11 linux

Compiling the new kernel:


[root@linux]$ cd/usr/src/linux
[root@linux]$ make mrproper
[root@linux]$ make gconfig - (or xconfig, menuconfig, oldconfig )

Use "make gconfig" or "make xconfig" if you are in graphical mode, or make menuconfig if in text mode.Then chose the options and modules needed for your computer. "make oldconfig" will look for a file name ".config" and use that to set the options, you can copy ".config" from the old kernel source directory to the new one to use the same setup.

[root@linux]$ make - Build the kernel bzimage.
[root@linux]$ make modules_install - Build and install the modules.

Installing the new kernel:


[root@linux]$ cd /boot
[root@linux]$ ls -l

if vmlinuz and System.map are symlinks remove them

[root@linux]$ rm vmlinuz
[root@linux]$ rm System.map

If they are not symlinks rename to save them

[root@linux]$ mv vmlinuz vmlinuz-2.6.6
[root@linux]$ mv System.map System.map-2.6.6

Copy new files

[root@linux]$ cp /usr/src/linux/arch/i386/boot/bzImage ./vmlinuz-2.6.11
[root@linux]$ cp /usr/src/linux/System.map ./System.map-2.6.11

Creat new symlinks

[root@linux]$ ln -s vmlinuz-2.6.11 vmlinuz
[root@linux]$ ln -s System.map-2.6.11 System.map

update lilo or grub or whatever boot loader you use, so it boots the new kernel.

Back to the Main Page