Sunday, March 1, 2015

Building Kernel Source

This article just briefs about downloading and installing Linux Kernel Source.
Of-course, there are many articles available in net. I would like to make this as simple as possible.

Steps to follow

1. Install Git
 sudo apt-get install git  

2. Download Linux Source (in here I am downloading 2.6 version) in to a directory
 $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git 
 $ git pull 

3.Configure your Kernel by executing
 $make defconfig  
 $make oldconfig  

Some times, we can use "$make  menuconfig" a graphic utility to configure Kernel. You may face fatal error problem while executing this command.

4.Now build your kernel
 $make  

This may take a while. So relax, we have done a lot till now :)

To improve Kernel build time you can use
 $make  -jn

Here, n is the number of jobs to spawn. Usual practice is to spawn one or two jobs per processor. For example, on a 16-core machine, you might do
$ make -j32 > /dev/null

Using utilities such as the excellent distcc or kernel build time. ccache
can also dramatically improve  Kernel build time.

5. Now once the build is done, we need to find for bzImage
 mrtechpathi@mrtechpathi:~/Study/linux-source/linux-2.6$ find . -name bzImage |xargs ls -l  
 lrwxrwxrwx 1 mrtechpathi mrtechpathi   22 Mar 1 23:16 ./arch/x86_64/boot/bzImage -> ../../x86/boot/bzImage  
 -rw-rw-r-- 1 mrtechpathi mrtechpathi 5970016 Mar 1 23:16 ./arch/x86/boot/bzImage  

6.Copy this image to /boot directory as vmlinuz-2.6
 mrtechpathi@mrtechpathi:~/Study/linux-source/linux-2.6$ sudo cp ./arch/x86/boot/bzImage /boot/vmlinuz-2.6  

7.Install modules
$ sudo make modules_install

8.Now update grub using
$ sudo update-grub

Sometimes,  your grub may disappear or may not appear. To solve this check this post "Grub menu is not displayed after installing Linux".

No comments:

Post a Comment