Tuesday, November 20, 2012

Compile Kernel on Ubuntu 12.04

1. Downloading latest stable source code from http://www.kernel.org/.

2. While downloading, we install necessary packages required to compile the kernel.
# apt-get install kernel-package libncurses5-dev fakeroot wget bzip2

3. Untar the source code.

# mv ~/Downloads/linux-3.6.7.tar.bz2  /usr/src/
# cd /usr/src
# tar -jxvf linux-3.6.7.tar.bz2
# ln -s linux-3.6.7 linux
# cd linux

4. Configure the kernel
# cp /boot/config-3.2.0-33-generic ./.config
# make menuconfig

Screen below should show up, pick 'Loan an Alternate Configuration File' as '.config', then pick 'OK' follow by 'EXIT'

5. Start building....
# make-kpkg clean
# fakeroot make-kpkg  --initrd --append-to-version=-mykernel kernel_image kernel_header  -j4

'mykernel' can change to anything you like, option -j4 is to tell make use up to 4 threads.
Now walk away from your PC go enjoy coffee.

Finally completed. 

6. Installing...
# cd ..
$ sudo dpkg -i linux-image-3.6.7-mykernel_3.6.7-mykernel-10.00.Custom_amd64.deb
$ sudo dpkg -i linux-headers-3.6.7-mykernel_3.6.7-mykernel-10.00.Custom_amd64.deb 

# sudo shutdown -r 0