RSS

Build Linux Kernel in 10 steps

01 Mar

Linux Kernel In Action

Linux kernel In Action


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

  1. Download the Linux Kernel Source:
    Download Location: http://kernel.org
    View Kernel Source Online: http://lxr.linux.no/
    Acknowledgment: Above logo is from the same site!
    Here, am building Linux Kernel version 2.6.32.28.
  2.  

  3. Extract the source:
    tar xvf linux-2.6.32.28.tar.bz2
    You can choose your suitable location, I am doing it at $HOME. Extract the source and ‘cd’ to it.
  4.  

  5. Copy the config file:
    sudo cp /boot/config-2.6.31generic ~/linux-2.6.32.28/.config
    My existing Kernel version on the laptop is: 2.6.31.
  6.  

  7. Customize the kernel configuration as you want:
    make menuconfig
  8.  

  9. Build the Kernel:
    make
  10.  

  11. Build the Kernel modules:
    make modules
  12.  

  13. Ready the modules to be installed:
    sudo make modules_install

  14.  

  15. Install the Kernel Modules:
    sudo make install
  16.  

  17. Create the initramfs image for required kernel version
    The update-initramfs script manages your initramfs images on your local
    box. It keeps track of the existing initramfs archives in /boot.
    There are three modes of operation create, update or delete. You must
    at least specify one of those modes.
     
    The initramfs is a gzipped cpio archive. At boot time, the kernel
    unpacks that archive into RAM disk, mounts and uses it as initial root
    file system. All finding of the root device happens in this early
    userspace.
     
    sudo update-initramfs -k 2.6.32.28 -c
     
    OR you can ‘cd’ to /boot and use mkinitramfs command as below:
     
    sudo mkinitramfs -o initrd.img-2.6.32.28 2.6.32.28
  18.  

  19. Update the grub:
    sudo update-grub
  20.  

 


  • Once all 10 steps are executed successfully, you can ‘reboot’ the system to see the customized Linux kernel in action! You can confirm this change by following command:

    uname -a
    Before:
    Linux machine_name 2.6.31-14-generic #48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009 i686 GNU/Linux

    After:
    Linux machine_name 2.6.32.28 #1 SMP Tue Mar 1 20:53:55 IST 2011 i686 GNU/Linux

     
    Note: Message content may differ based on Linux kernel version, data, time, etc.
     

  • If there is an issue during any of these 10 steps, you can always comment here or google it out! 🙂


Note: If you are facing problems like: failed to mount root fs on /proc/mounts or similar, you can boot the machine using working Linux kernel version and run

sudo update-initramfs -u -k all

This will update the initrd images of all kernel versions.

Advertisements
 
Leave a comment

Posted by on March 1, 2011 in Linux, Technical

 

Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: