Debian-Kernel-Compile-Howto (Kernel 2.6)
By admin on May 13, 2010 with Comments 0
In
some cases you might want to compile your own kernel that suits
your needs better than the standard kernel that comes with your
distribution. I will describe how to do this on a Debian
Woody machine (a description for Debian Sarge can be
found here!). Please note that this tutorial is for
kernel 2.6 only! A tutorial for kernel 2.4 can be foundhere.
Debian-Kernel-Compile-Howto(Kernel 2.6)
Version 1.1
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 07/15/2005
In some cases youmight want to compile your own kernel that suits your needs better than thestandard kernel that comes with your distribution. I will describe how to dothis on a Debian Woody machine (a description for DebianSarge can be found here!). Please note that this tutorial is for kernel 2.6 only! Atutorial for kernel 2.4 can be found here.
Be aware that there is some risk in doing so! For example, it could happen that your machine does not boot properly after you have installed the new kernel so you might be forced to boot from a rescue CD to repair your system. You have been warned! This document comes without warranty of any kind!
Kernel-Compile-Howto
First login to your Debian machine on the command line as root. Install the prerequisites that we need to compile the new kernel:
apt-get install kernel-package ncurses-dev fakeroot wget bzip2
Then go to /usr/src:
cd /usr/src
Then get the latestLinux kernel source (or the kernel source you need) from http://www.kernel.org/pub/linux/kernel/v2.6/:
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.8.1.tar.bz2
Unpack the kernel sources:
tar xjf linux-2.6.8.1.tar.bz2
cd linux-2.6.8.1/
It is normallya good idea to take the configuration of your existing (working!) kernel 2.6as a starting point for the configuration of your new kernel. Usually the currentkernel configuration is saved in a file under /boot,e.g. /boot/config-2.6.3.We will load this configuration and then do the changes we desire. If you donot have the config file of a working kernel 2.6 thisone might help you.
make menuconfig
Select Loadan Alternate Configuration File and enter the location of the configurationfile of your current kernel (or upload mykernel configuration to your machine and enter its path):


The configuration of your current kernel will be loaded, and you can now browse through the menu and change the configuration to suit your needs. When you are finished, save your new kernel configuration:

Then run the followingcommands (please note that make depis not needed any more for kernel 2.6):
make-kpkg clean
fakeroot make-kpkg –revision=custom.1.0 kernel_image
If the compilation stops with an error, run
make clean
and then re-run the previous commands starting with
make menuconfig
Change the kernelconfiguration where the error occurs. If no error occurs you will find the newkernel as a Debian package called kernel-image-2.6.8.1_custom.1.0_i386.debunder /usr/src.
cd ../
Now you have toinstall some packages that are needed by kernel 2.6. Add the following lineto /etc/apt/sources.list:
deb http://www.backports.org/debian/woody module-init-tools initrd-tools procps
Then run:
apt-get update
apt-get install module-init-tools initrd-tools procps
If you are askedthe following question:
“If you really wantto remove modutils type ‘yes’:”
type yes.
It might also benecessary to update packages like bind9, quota, etc. – depending on your configuration.If you have problems with your existing packages try to get the appropriatepackage from www.backports.org.
Install your newkernel:
dpkg -i kernel-image-2.6.8.1_custom.1.0_i386.deb
Create a ramdiskof your new kernel (otherwise your system will most likely not boot):
cd /boot/
mkinitrd -o /boot/initrd.img-2.6.8.1 2.6.8.1
We are almost finishednow. Edit the image=/vmlinuzstanza of your /etc/lilo.confand add the line initrd=/boot/initrd.img-2.6.8.1:
# Boot up Linux by default. # default=Linuximage=/vmlinuz label=Linux read-only initrd=/boot/initrd.img-2.6.8.1 #restricted #alias=1
Run
lilo
to update yourboot loader and reboot your machine:
shutdown -r now
and if everything is ok your machine should come up with the new kernel. You can run
uname -a
to verify that.Good luck!
Update:
This is an excerptfrom an email that R (Chandra) Chandrasekhar(thanks a lot for this one!) sent to me regarding the kernel configuration incase you use flash drives and nVidia cards:
“1. If youintend to use flash drives, de-select the following during <makexconfig>:
BlockDevices -> Low Performance USB Block driver (BLK_DEV_UB)
There is a clearexplanation at http://linux.usc.edu/pipermail/usclug-chat/2004-December/000111.htmland at http://dev.gentoo.org/~dsd/gentoo-dev-sources/issues-current.htm#2.6.9-ubon why this is advisable until further development of the ub module.
I had to
apt-get install udev hotplug
to use the flashdrive, but it worked like a charm after that!
2. If you havean nVidia card, de-select the following during <makexconfig>:
GraphicsSupport -> nVidia Riva support (FB_RIVA)
Kernel Hacking ->Use 4Kb for kernel stacks instead of 8Kb (4KSTACKS)
Processor Type andFeatures -> Local APIC support on uniprocessors (X86_UP_APIC)
To install thenVidia drivers, I followed the HOWTO at http://home.comcast.net/~andrex/Debian-nVidia/index.htmland compiled the drivers from the Debian packages after applying the vmalloc_reserve.patchduring kernel build.”
Filed Under: Kernel













