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:
bzImage: this builds the kernel. Note that this target is only valid for x86 and x86_64 processors. This target also generates the System.map for this kernel. We will see later what this file is used for;
modules: this target will generate modules for the kernel you have just built. If you have chosen not to have modules, this target will do nothing;
all: this target will generate the preferred kernel type image for the given architecture and modules;
modules_install: this will install modules. By default, modules will be installed in the /lib/modules/<kernel-version> directory. This target also computes module dependencies;
install: this last target will finally copy the kernel and modules to the right places and modify the bootloader's configuration in order for the new kernel to be available at boot time. Do not use it if you prefer to perform a manual installation as described in the section called “Installing the New Kernel Manually”.
![]() | 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!