Whether it’s for educational purposes, tweaking or curiosity, compiling a Kernel in Ubuntu 12.04 LTS is generally a straight forward exercise. However, it can be a little more complex depending on what sources are used, for example GIT or a vanilla kernel from kernel.org.
This guide goes for the easiest method and demonstrates how to compile the Ubuntu 12.04 LTS Kernel using apt-get sources.
It is not intended to be a comprehensive guide to kernel compiling, just something to get you started and as a quick reference for Ubuntu 12.04 LTS users.
Before you attempt using this guide please make sure your Ubuntu installation is fully up to date. Use the ‘Update Manager’ program and if you need to reboot after the update please do.
The Kernel Compile Guide
Install required packages
sudo apt-get install libncurses5-dev kernel-package
Create a source directory
Download the kernel source into your source directory
apt-get source linux-image-$(uname -r)
Configure your Kernel
Speed up the build
General rule is CONCURRENCY_LEVEL = number of processor cores + 1
Compile the Kernel
time fakeroot make-kpkg –initrd –append-to-version=-tweak kernel-image kernel-headers
You can change -tweak to anything you wish
Install your compiled Kernel
sudo dpkg -i linux-image-3.2.24-tweak_3.2.24-tweak-10.00.Custom_amd64.deb
sudo dpkg -i linux-headers-3.2.24-tweak_3.2.24-tweak-10.00.Custom_amd64.deb
Ubuntu should boot with your new Kernel by default, if not you may have to edit Grub or enable the Grub menu to be displayed during boot.