Building and installing the kernel under Debian

    Here we will talk not just about compiling the Linux kernel, but about compiling the kernel and compiling it into a deb package. Then this deb'om can be shared with friends, brag to your girlfriend / boyfriend or simply, if necessary, reused.

    To get started, install the packages fakeroot, kernel-package, libncurses5-dev:
    aptitude install fakeroot kernel-package libncurses5-dev

    All dependencies will be raised automatically ...
    Then we take the desired archive from kernel.org and merge and unpack it into / usr / src (we take the kernel 2.6.31.4 for example).
    $ cd / usr / src
    $ sudo -s
    # wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.31.4.tar.bz2
    # tar xjf linux-2.6.31.4.tar.bz2
    # if [-d linux]; then rm linux; fi ln -s linux-2.6.31.4 linux
    # cd linux

    There is one point. Since we already have a working kernel in the installed system, if we do not want to put all the checkmarks in the configuration of the new kernel from scratch, we take the ready-made config either from / boot or from / proc:
    # cp / boot / config - $ (uname -r) .config
    # zcat /proc/config.gz> .config

    As a result, we have a preliminary preparation for the configuration of our new core.

    Now we configure the kernel for specific purposes for us, or add options for new modules, or ... In a word - creativity:
    # make menuconfig

    It will be interesting to note here that if we immediately exit the menu, we can see something like this:
    .config: 903: warning: symbol value 'm' invalid for RFKILL_INPUT
    .config: 2920: warning: symbol value 'm' invalid for DRAGONRISE_FF
    .config: 2937: warning: symbol value 'm' invalid for GREENASIA_FF
    .config: 2939: warning: symbol value 'm' invalid for THRUSTMASTER_FF
    .config: 2940: warning: symbol value 'm' invalid for ZEROPLUS_FF

    it makes sense to find these options when configuring a new kernel and see what's what ...
    Or, as I was told , use:
    # make oldconfig

    to compile a new version, which will not touch all the matching options, and asks about the others that have changed, ask.
    By the way, if anyone is interested in configuring under Xs, then he can do this:
    # make xconfig

    Important! Do not forget to say “Kernel module loader” in “Loadable module support”, as options are possible.
    Well, that’s it. Pimpochki marked, buttons pushed, left the windows, saved a new config, now let's proceed to the assembly. To start, we’ll do:
    # make-kpkg clean

    We’ll see something like this:
    exec make kpkg_version = 12.021 -f /usr/share/kernel-package/ruleset/minimal.mk clean
    ====== making target minimal_clean [new prereqs:] ======
    This is kernel package version 12.021.
    test! -f .config || cp -pf .config config.precious
    test! -e stamp-building || rm -f stamp-building
    test! -f Makefile || \
               make ARCH = i386 distclean
    make [1]: Entering directory `/usr/src/linux-2.6.31.4 '
     CLEAN scripts / basic
     CLEAN scripts / kconfig
     CLEAN include / config
     CLEAN .config .config.old include / linux / autoconf.h
    make [1]: Leaving directory `/usr/src/linux-2.6.31.4 '
    test! -f config.precious || mv -f config.precious .config
    rm -f modules / modversions.h modules / ksyms.ver scripts / cramfs / cramfsck scripts / cramfs / mkcramfs

    Well, now, actually, we are building the kernel:
    # fakeroot make-kpkg --initrd --revision = og.091015.00 kernel_image

    og.091015.00 - it means only a revision of our assembly (fewer letters, but more numbers, otherwise you will get an error at the very end of the assembly and you will have to repeat everything from the very beginning), but otherwise there can be anyone - who has enough imagination :)
    After that As the previous command will execute normally, you can also give such a "gentleman's set":
    # fakeroot make-kpkg --initrd --revision = og.091015.00 kernel_headers
    # fakeroot make-kpkg --initrd --revision = og.091015.00 kernel_manual
    # fakeroot make-kpkg --initrd --revision = og.091015.00 kernel_doc
    # fakeroot make-kpkg --initrd --revision = og.091015.00 kernel_source

    After that we get a set of the following deb packages:
    • linux-image-2.6.31.4_og.091015.00_i386.deb
    • linux-headers-2.6.31.4_og.091015.00_i386.deb
    • linux-manual-2.6.31.4_og.091015.00_all.deb
    • linux-doc-2.6.31.4_og.091015.00_all.deb
    • linux-source-2.6.31.4_og.091015.00_all.deb

    they will be located in / usr / src.
    We can only install them through dpkg:
    # cd / usr / src
    # dpkg -i ./linux-image-2.6.31.4_og.091015.00_i386.deb

    etc.
    The configuration for GRUB will have to be done automatically, as well as the initrd build.
    The final step:
    # reboot

    Also popular now: