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.10
, you must delete the
/lib/modules/2.6.10
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[39].
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 Section 7, “Installing the New Kernel
Manually”.
![]() | Warning |
---|---|
It is
important to respect the target order |
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.
[39] 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!