Sunday, 6 February 2011

How to compile a kernel from kernel.org in Ubuntu 10.04 LTS

This quick how-to is based on http://linuxtweaking.blogspot.com/2010/05/how-to-compile-kernel-on-ubuntu-1004.html

Open a terminal and work through the following set of commands.

Install these packages

sudo apt-get install fakeroot kernel-wedge build-essential makedumpfile kernel-package libncurses5 libncurses5-dev

Run this

sudo apt-get build-dep --no-install-recommends linux-image-$(uname -r)

Create your source directory

mkdir ~/src
cd ~/src

Download and extract your kernel


You can browse for kernels at http://www.kernel.org/pub/linux/kernel/v2.6/ This guide is using kernel 2.6.37.

wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.37.tar.gz
tar xvf linux-2.6.37.tar.gz
cd linux-2.6.37

Configure your Kernel

make menuconfig

Build your Kernel

export CONCURRENCY_LEVEL=3
make-kpkg clean
time fakeroot make-kpkg --initrd kernel-image kernel-headers

General rule, concurrency level = number of processor cores + 1


Install your kernel

cd ~/src

dir        
sudo dpkg -i linux-image-2.6.37_2.6.37-10.00.Custom_amd64.deb
sudo dpkg -i linux-headers-2.6.37_2.6.37-10.00.Custom_amd64.deb

Create the initramfs image

sudo update-initramfs -c -k 2.6.37

Update your grub.cfg

sudo update-grub

Reboot your system


Enjoy your new kernel.