Doug's Linux Notebook

Kernel Compiling

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.3.x, or 2.5.x are development or beta versions and may not be stable,it would be best to use only kernels with even minor numbers. 2.2.x, 2.4.x

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

# ls -l

If you see something like "linux -> linux-2.4.3" then "linux" is a symlink and needs to be removed, do

# rm linux

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

# mv linux linux-2.4.3

I used 2.4.3 as an example, enter

# uname -r

to find out the version of the curent kernel.

Now you are ready to unpack the new kernel source,

# bzip2 -cd /path-to-downloaded-file/linux-2.4.17.tar.bz2 | tar xf -

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

# tar xvzf /path-to-downloaded-file/linux-2.4.17.tar.gz

This is a large file so it will take a minute to unzip. Now there will be a new directory named "linux" rename it,

# mv linux linux-2.4.17

Then make a new symlink

# ln -s linux-2.4.17 linux

Compiling the new kernel:

# cd/usr/src/linux
# make mrproper
# make xconfig (or config, menuconfig, oldconfig )

Use "xconfig" if you are in graphical mode, or "menuconfig" if in text mode.Then chose the options and modules needed for your computer.Oldconfig will look for a file named ".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.

# make dep
# make clean
# make bzImage
# make modules
# make modules_install ( rename /lib/modules/"version" first if need to save it )

Installing the new kernel:

# cd /boot
# ls -l

if vmlinuz and System.map are symlinks remove them

# rm vmlinuz
# rm System.map

If they are not symlinks rename to save them

# mv  vmlinuz vmlinuz-2.4.3
# mv System.map System.map-2.4.3

Copy new files

# cp /usr/src/linux/arch/i386/boot/bzImage ./vmlinuz-2.4.17
# cp /usr/src/linux/System.map ./System.map-2.4.17

Creat new symlinks

# ln -s vmlinuz-2.4.17 vmlinuz
# ln -s System.map-2.4.17 System.map

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

Back to the Main Page