How to Compile A Kernel – The Mandriva Way

Each distribution contains some particular tools that help in creating a custom kernel from the sources. This step by step guide explains how to compile a kernel on Mandriva systems. It describes the procedure of creating a custom kernel with the help of the most recent unmodified kernel sources from (vanilla kernel). By doing this, you become free from the kernels supplied by your distribution. Moreover, it explains the technique of patching the kernel sources if you want some features that do not exist there.

This article also helps in creating a kernel rpm package which can be installed on the system, and you can share with others. In addition, you can install it on other Mandriva systems which is certainly a big plus point, whereas in a “traditional” way you don’t end up with an rpm package.


  • 1

    Download the Kernel Sources

    First of all, you need to download the required kernel to /usr/src. Visit and decide the kernel you want to install. For example linux-

    cd /usr/src

    After that, you need to unpack the kernel sources and develop a symlink linux to the kernel sources directory:

    tar xjf linux-
    ln -s linux- linux
    cd /usr/src/linux

  • 2

    Apply patches to the Kernel Sources (Optional)

    At times, you want drivers for hardware that aren’t supported by the new kernel by default, or you require support for virtualization methods or some other latest technology that hasn’t introduced in the kernel yet.

    Now let’s suppose you have downloaded the required patch (it is named as patch.bz2 in this example) to /usr/src. Given below is the procedure of applying it your kernel sources.

    bzip2 -dc /usr/src/patch.bz2 | patch -p1 --dry-run
    bzip2 -dc /usr/src/patch.bz2 | patch -p1

    The command written on the first line is just a test, it has nothing to do with your sources. If it is free from any type of errors, run the second command which is used in applying the patch. Make sure if the first command show errors then don’t proceed further.

    In case your patches are compressed with gzip (.gz) in its place of bzip2(.bz2), then you patch your kernel according to this method:

    gunzip -c /usr/src/patch.gz | patch -p1 --dry-run
    gunzip -c /usr/src/patch.gz | patch -p1

    There is also an option of applying kernel perpatches to your kernel sources. For example, there is something which is only available in kernel 2.6.19-rc6 and you need it urgently, but the full sources haven’t been launched yet for this kernel. There is a patch -2.6.19-rc6.bz2 is available, and there is an option of applying that patch to the 2.6.18 kernel sources, but not to kernel or or, etc. You can get further details about it on

    So in order to compile a 2.6.19-rc6 patch to kernel 2.6.18, follow this procedure;

    cd /usr/src
    cd /usr/src/linux
    bzip2 -dc /usr/src/patch-2.6.19-rc6.bz2 | patch -p1 --dry-run
    bzip2 -dc /usr/src/patch-2.6.19-rc6.bz2 | patch -p1

  • 3

    Configure The Kernel

    It is better to apply the configuration of your present working kernel as a basis of your new kernel.  So, you have to copy the current configuration to /usr/src/linux;

    make clean && make mrproper
    cp /boot/config-`uname -r` ./.config

    Then we run

    make menuconfig

    This will open kernel configuration menu. Go to Load an Alternate Configuration File and select .config(which has the configuration of your present working kernel) as the configuration file:

  • 4

  • 5

    After that browse through the configuration menu and select the options. Make sure to mention a kernel version identification string under General Setup ---> () Local version - append to kernel release. In this tutorial, we have used –default so the kernel rpm package is identified as kernel- String can also be left blank or you can mention a different one in order to specify the kernel such as –custom.

  • 6

  • 7

  • 8

  • 9

    Once you are done and select Exit, you need to answer the following question (Do you wish to save your new kernel configuration?) with Yes:

Leave a Reply

Your email address will not be published. Required fields are marked *

7 × = fourteen