12.16.2010

How to compile linux kernel?

A Kernel is an interface which lets device drivers talk to the underlying hardware. Why we need to compile kernel? - is an important discussion to understand. Whenever a new hardware arrives in the market,the available kernel module might not support and you need to re-compile the kernel to make device driver communicate with the hardware.

Compiling the new kernel requires few pre-software modules to exist before you start with. Make sure you have gcc compilers development tools and libraries available in your Linux machine.  I am assuming Fedora 14 installed on your virtualbox. Follow up with the steps further to get a new kernel 2.6.37-rc4 installed with the existing kernel.


1. Download the linux kernel 2.6.37-rc6 from http://kernel.org as shown:


2. Make sure you have pre-requisite packages like gcc and make installed on your Fedora machine.



3. Untar the downloaded linux kernel-2.6.37-rc6 to /usr/src directory as shown in the figure.



4. Once you start the above command it will take around 1-1.5 minutes to untar the package.


5.Change the directory to /usr/src and run the make menuconfig to open the manual driver inlcusion window.


6.Once the menuconfig window opens up, you have option to select particular modules which you want to compile. Few modules related to vmware are shown below:




7.Once you are done with selecting the particular module, type ESC key repeatedly unless it ask for saving a .config file.
Press "YES" and a file .config gets created.
8.Run this command to start compilation of the new kernel

#make

9.Next, run the command in the sequence:


#make modules
#make modules_install
#make install

10. Once you run make install it will add a new kernel to GRUB.

11.Edit /boot/grub/grub.conf and replace default=1 to default=0 to allow the new kernel to boot automatically whenever the reboot command is run.

12. Reboot the machine

13. Run the uname command to see if it has actually booted with new kernel.

14. Congrats !!!! You have just compiled a new linux kernel.

No comments:

Post a Comment