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
or
#make menuconfig
or
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
#export CONCURRENCY_LEVEL=2
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.
great info, but where do we get gconfig or xconfig because it’s not in the repos.
@Rich Hartley: They’re not separate programs but features of make.
well I follow this howto and give a error:
make[1]: Entrando no diretório `/usr/src/linux-2.6.31.6/Documentation/lguest’
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-2.6.31.6/Documentation/lguest’
make: ** [debian/stamp/build/kernel] Erro 2
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
where:
….”error: zlib.h: No such file or directory”….
install zlib1g-dev package and make-kpkg again
regards,
zgfrd
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