Jul 282009

Sponsored Link

This tutorial will explain Howto compile kernel in Debian 5.0.The default kernel that comes with Debian is better suited for servers. It's optimized for high thoughput and low interactivity. When you compile your own, you can among other things optimize it for the processor(s) you have.

Preparing Your system

First you need to install the following packages

#apt-get install kernel-package ncurses-dev bzip2 module-init-tools initramfs-tools procps fakeroot

If you plan on using the graphical configuration tools, gconfig or xconfig, you'll need additional packages, respectively libgtk2.0-dev libglib2.0-dev libglade2-dev for gconfig or libqt3-mt-dev for xconfig.

Check your kernel version using the following command

uname -r

Download source using the following command

#apt-get install linux-source-2.6.26

Make directory for compiling

#mkdir ~/newkernel/

Copy source to newly created folder

#cp /usr/src/linux-source-2.6.26.tar.bz2 ~/newkernel/

#cd /newkernel/

Extract the source using the following command

#tar xjf linux-source-2.6.26.tar.bz2

#cd linux-source-2.6.26

Optional Step

You might optionally want to copy a working template for the kernel .config to this directory, you can find some in /boot/.

#cp /boot/config-$(uname -r) ./.config

Check your processor details using the following command

#cat /proc/cpuinfo

Configure kernel options

#make config


#make menuconfig


If you are using GNOME use the following command

#make gconfig

If you are using gconfig you should see similar to the following screen


In the above scree you have to click on the Y/M/N letter in the very last column of your choice to enable or disable some options

Now Clean the slate for kernel compiling

#make-kpkg clean

If you have a multiprocessor machine, you'll want to make all processors work


Perform the actual compile, this will take anywhere from 10 minutes to 5 hours depending on your hardware and configuration choices (the more you selected, the longer it will take). You need to include kernel_headers if you want to compile some other modules against your kernel, e.g. ati or nvidia drivers.

#make-kpkg --rootcmd fakeroot --initrd --revision=custom.001 kernel_image kernel_headers

It then will give you all kind of chatter, warnings and notices during, it's quite normal.

Sponsored Link

Once it's done, goto the lower directory where the .deb we just created is

#cd ..

Install .deb package using the following command

#dpkg -i *.deb

Reboot and select from the list the new kernel with your initials or what ever ID you gave it at config time.

Source from here

 Posted by at 2:34 pm
  • Rich Hartley

    great info, but where do we get gconfig or xconfig because it’s not in the repos.

  • anon debianite

    @Rich Hartley: They’re not separate programs but features of make.

  • pflamellas

    well I follow this howto and give a error:
    make[1]: Entrando no diretório `/usr/src/linux-’
    cc -m32 -Wall -Wmissing-declarations -Wmissing-prototypes -O3 -I../../include -I../../arch/x86/include -U_FORTIFY_SOURCE lguest.c -o lguest
    lguest.c:21:25: error: sys/eventfd.h: Arquivo ou diretório não encontrado
    lguest.c: In function ‘create_thread’:
    lguest.c:1021: warning: implicit declaration of function ‘eventfd’
    make[1]: ** [lguest] Erro 1
    make[1]: Saindo do diretório `/usr/src/linux-’
    make: ** [debian/stamp/build/kernel] Erro 2

  • Harry Andersen

    make[1]: Leaving directory `/home/roy/newkernel/linux-source-2.6.26′
    /usr/bin/make ARCH=i386 \
    -C Documentation/lguest
    make[1]: Entering directory `/home/roy/newkernel/linux-source-2.6.26/Documentation/lguest’
    cc -Wall -Wmissing-declarations -Wmissing-prototypes -O3 -I../../include lguest.c -lz -o lguest
    lguest.c:34:18: error: zlib.h: No such file or directory
    make[1]: *** [lguest] Error 1
    make[1]: Leaving directory `/home/roy/newkernel/linux-source-2.6.26/Documentation/lguest’
    make: *** [debian/stamp/build/kernel] Error 2

  • zgfrd

    ….”error: zlib.h: No such file or directory”….

    install zlib1g-dev package and make-kpkg again


  • Zsolt

    the lguest sys/eventfd.h problem solved when I turned off

    “Processor type and features”:
    “Paravirtualized guest support” = N

    lenny still have older libc6 which omits sys/eventfd.h

  • Cosme

    Files are in /home/user/linux-

    Where must be created *.deb after finish????

  • http://www.debian.org Tom Stwart

    For those of you having problems with lguest as stated bellow:

    cc -m32 -Wall -Wmissing-declarations -Wmissing-prototypes -O3 -I../../include -I../../arch/x86/include -U_FORTIFY_SOURCE lguest.c -o lguest
    lguest.c:21:25: error: sys/eventfd.h: No such file or directory
    lguest.c: In function ‘create_thread’:
    lguest.c:1021: warning: implicit declaration of function ‘eventfd’
    make: *** [lguest] Error 1

    This is apparenty due to the old libc-dev package that Lenny comes with. Since libc isn’t exactly a good candidate for a selective upgrade I helped myself with simply editing Documentation/lguest/Makefile and changing:

    all: lguest



  • vanz

    Please help me…..
    My OS is Debian lenny I686 kernel
    when i compile the kernel linux- have error this:

    make[1]: Leaving directory `/usr/src/linux-′
    test ! -e scripts/package/builddeb || mv -f scripts/package/builddeb scripts/package/builddeb.kpkg-dist
    test ! -e scripts/package/Makefile || test -f scripts/package/Makefile.kpkg-dist || (mv -f scripts/package/Makefile scripts/package/Makefile.kpkg-dist && (echo “# Dummy file “; echo “help:”) > scripts/package/Makefile)
    COLUMNS=150 dpkg -l ‘gcc*’ perl dpkg ‘libc6*’ binutils make dpkg-dev |\
    awk ‘$1 ~ /[hi]i/ { printf(“%s-%s\n”, $2, $3) }’> debian/buildinfo
    uname -a >> debian/buildinfo
    echo using the compiler: >> debian/buildinfo
    grep LINUX_COMPILER include/linux/compile.h | \
    sed -e ‘s/.*LINUX_COMPILER “//’ -e ‘s/”$//’ >> debian/buildinfo
    grep: include/linux/compile.h: No such file or directory
    echo applied kernel patches: >> debian/buildinfo
    echo done > debian/stamp/build/kernel
    /usr/bin/make -f ./debian/rules debian/stamp/binary/pre-linux-image-
    make[1]: Entering directory `/usr/src/linux-′
    ====== making target debian/stamp/install/linux-image- [new prereqs: ]======
    This is kernel package version 11.015.
    echo “The UTS Release version in include/linux/version.h”; echo ” \”\” “; echo “does not match current version:”; echo ” \”\” “; echo “Please correct this.”; exit 2
    The UTS Release version in include/linux/version.h
    does not match current version:
    Please correct this.
    make[1]: *** [debian/stamp/install/linux-image-] Error 2
    make[1]: Leaving directory `/usr/src/linux-′
    make: *** [kernel_image] Error 2

    so what should i do..???

  • http://anttribe.org ??

    ? vanz?
    echo include/linux/version.h -> echo include/generated/version.h
    echo include/linux/utsrelease.h -> echo include/generated/utsrelease.h

    #:make-kpkg –rootcmd fakeroot –initrd –revision=kernel.001 kernel_image kernel_headers

  • http://anttribe.org ant tribe

    wget http://*/kernel-package_12.032_all.deb
    dpki -i kernel-package_12.032_all.deb