Compiling Kernel and Modules, Installing the Beast

A small point to begin with: if you are recompiling a kernel with exactly the same version as the one already present on your system, the old modules must be deleted first. For example, if you are recompiling 2.6.8, you must delete the /lib/modules/2.6.8 directory.

Compiling the kernel and modules, and then installing modules, is done with the following lines:

make clean 
make all
make modules_install install

A little vocabulary: Any argument like clean, all, etc., are called targets. Notice that, starting with kernel 2.6, a target called all exists. Executing this target is the same than executing (on the x86 architecture) the bzImage and modules targets. This new option will make the preferred targets for any given architecture. Before 2.6, each architecture had a different option name to compile the kernel. If you specify several targets to make as shown above, they will be executed in the order of appearance. But if one target fails, make will not go any further[35].

Let us look at the different targets and see what they do:

[Warning]Warning

It is important to respect the target order modules_install install so that modules actually get installed first. Otherwise initrd will be wrong and the kernel will not boot correctly.

At this point, everything is now compiled and correctly installed, ready to be tested! Just reboot your machine and choose the new kernel in the boot menu. Note that the old kernel remains available so that you can use it if you experience problems with the new one. However, you can choose to manually install the kernel and change the boot menus by hand. We will explain that in the next section.



[35] In this case, if the compilation fails, it means that there is a bug in the kernel... If this is the case, please report it!