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. You can also remove any and all unneeded bloat, there's plenty of it to make the default kernel work on maximum number of system configurations out of the box. Compiling your own is fun, profitable and easy.
Basically it's a 4 step process
* Get the source
* Configure it
* Compile it
* Install it
So, here we go, install needed packages
- Code: Select all
sudo 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. There might be other dependencies too and if they're not satisfied you'll be notified once you try to invoke the graphical configurator.
To see what kernel you're now on, input
- Code: Select all
uname -r
Acquire a source, e.g.
- Code: Select all
sudo apt-get install linux-source-2.6.26
Make a directory to avoid having to compile as root
- Code: Select all
mkdir ~/kernel_compiling/
Copy the source to that folder
- Code: Select all
cp /usr/src/linux-source-2.6.26.tar.bz2 ~/kernel_compiling/
Goto the directory
- Code: Select all
cd ~/kernel_compiling/
Extract the source
- Code: Select all
tar xjf linux-source-2.6.26.tar.bz2
Enter the extracted directory
- Code: Select all
cd linux-source-2.6.26/
(You might optionally want to copy a working template for the kernel .config to this directory, you can find some in /boot/.)
(If you're unsure whether you should do it, I recommend you do.)
- Code: Select all
cp /boot/config-$(uname -r) ./.config
To see what kind of a processor you have, input
- Code: Select all
cat /proc/cpuinfo
Configure the kernel options, there's more than one way to skin a cat, pick one
- Code: Select all
make config
- Code: Select all
make menuconfig
- Code: Select all
make xconfig
- Code: Select all
make gconfig
I use GNOME so it felt natural for me to choose gconfig. Here's a screenshot.

gconfig is pretty clumsy and unintuitive, for example clicking on the actual tick box doesn't do anything, instead you'll have to click on the Y/M/N letter in the very last column... Also, there seem to be undocumented features? Anyway, you can use Ctrl+F to search, Ctrl+G to find next occurrence and Shift+Ctrl+G to find previous occurrence. Quite handy after hitting the expand button.
One thing you should do is give it a distinctive name, e.g. your initials in general > local version (It MUST be lower case and rather short.), I used the letters me for this example. Start with changing only the obvious things, the ones you're 300% sure of. You will repeat this process many times and will get to know the more esoteric ones... If this is your first time, don't be too bold! Once you're done, save changes and exit.
Clean the slate for kernel compiling
- Code: Select all
make-kpkg clean
If you have a multiprocessor machine, you'll want to make all processors work, do
- Code: Select all
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.
- Code: Select all
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. If you get an error about missing zlib.h, see the very end of this post for the solution.
Once it's done through with no errors, goto the lower directory where the .deb we just created is
- Code: Select all
cd ..
Install the .deb package(s)
- Code: Select all
sudo dpkg -i *.deb
Then it's the moment of truth, the smoke test! Reboot and select from the list the new kernel with your initials or what ever ID you gave it at config time.
If it boots, nice, you made it, congrats!
Checklist
* network
* audio
* usb sticks
* cddvdrwcombo
* any queer peripherals
If not, reboot and select another kernel for the menu. Back to the drawing board...
You'll want to polish the kernel more, go back to the directory you extracted the source into. If everything worked out pretty nicely, make a backup of your .config. If it failed spectacularly, you might want to load a working .config and start working from it again.
Then do some more configuring, and cleanup, recompile... repeat until!
Troubleshooting:
If you get an error about missing zlib.h, make sure you have these packages installed
------------------------------------------------------------------------------

------------------------------------------------------------------------------