Friday, 29 April 2011

How to recompile your Ubuntu 11.04 Kernel

This quick how to guide will show you how to recompile your Ubuntu 11.04 (2.6.38.2) Kernel using the terminal.

1. Install these packages

sudo apt-get install kernel-wedge kernel-package libncurses5-dev

2. Run this command

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

3. Create your source directory

mkdir ~/src

cd ~/src

4. Download the Kernel source

apt-get source linux-image-$(uname -r)

5. Configure your Kernel

cd linux-2.6.38

make menuconfig

6. Speed up the build

export CONCURRENCY_LEVEL=3

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


7. Clean up temp files from a previous compile attempt (skip if necessary)

make-kpkg clean

8. Compile your Kernel

time fakeroot make-kpkg --initrd --append-to-version=-tweak kernel-image kernel-headers

You can change -tweak to anything you wish


9. Install your Kernel

cd ~/src

sudo dpkg -i linux-image-2.6.38.2-tweak_2.6.38.2-tweak-10.00.Custom_amd64.deb

sudo dpkg -i linux-headers-2.6.38.2-tweak_2.6.38.2-tweak-10.00.Custom_amd64.deb

10. Reboot