Each distribution has some specific tools to build a custom kernel from the sources. This article is about compiling a kernel on a Debian Etch system. It describes how to build a custom kernel using the latest unmodified kernel sources from www.kernel.org (vanilla kernel) so that you are independent from the kernels supplied by your distribution. It also shows how to patch the kernel sources if you need features that are not in there.
1 Preliminary Note
I will describe two ways of compiling a new kernel. Using the first method, you will end up with a kernel .deb package that can be installed on the system, and that you can share with others and install on other Debian Etch systems.
The second method is to compile a kernel the "traditional" way. This way works on any Linux distribution, but of course you don't end up with a kernel .deb package.
2 Building A Kernel .deb Package
This chapter shows how to build a kernel and end up with a .deb package that you can install and share with others.
2.1 Install Required Packages For Kernel Compilation
First we update our package database:
sudo apt-get update
Then we install all needed packages like this:
sudo apt-get install kernel-package libncurses5-dev fakeroot wget bzip2 build-essential
2.2 Download The Kernel Sources
Next we download our desired kernel to /usr/src. Go to www.kernel.org and select the kernel you want to install, e.g. linux-3.8.tar.bz2 (you can find all 2.6 kernels here: https://www.kernel.org/pub/linux/kernel/v3.x/). Then you can download it to /usr/src like this:
Then we unpack the kernel sources and create a symlink linux to the kernel sources directory: