Debian Kernel Compilation
This guide is written to help beginners compile Linux kernel on Debian based systems easily.
1) The current Linux source code is available from the official home of the Linux kernel, http://www.kernel.org.
2) Extract the kernel source to /usr/src/ directory. The kernel tarball is distributed in tar.xz extension. After downloading the source, uncompressing and untarring it is simple. Run
tar -xvjf linux-x.y.z.tar.bz2
If it is compressed with GNU zip (xz extension), run
tar xf linux-x.y.z.tar.xz
This uncompresses and untars the source to the directory linux-x.y.z.
3) Install the necessary packages for compilation
apt-get install fakeroot libncurses5-dev kernel-package
4) Configure the kernel
make menuconfig
The next step is the building step. You can utilize all of your processor cores. For this, first find out the number of processor cores and tell make to use them
Number of processor cores can be found with
nproc
or
grep -c processor /proc/cpuinfo
After that these cores can be used for compiling by setting
export CONCURRENCY_LEVEL=2
Here I have set two since I have 2 cores. After this you can run make-kpkg command to run faster compilation.
make-kpkg --rootcmd fakeroot --initrd kernel_image kernel_headers
5) Install the kernel by executing the following commands
dpkg -i ../*.deb
After installing the kernel, GRUB entries in (/boot/grub/menu.lst) are automatically updated and next time we log in we could see the new Kernel in GRUB.