Compiling a Linux Kernel


The advantage of linux is that we can choose what our system needs and thereby improve its efficiency. Compiling the kernel has its own advantages though it is a time consuming process.A  new Linux user may find it difficult to compile Linux kernel. This tutorial contains the process to compile Linux kernel version 3.0.3 under Ubuntu. However, instructions remains the same for any other distribution except for apt-get command.

Step # 1

Get Latest Linux kernel code and download the latest source code. File name would be linux-x.y.z.tar.bz2, where x.y.z is actual version number.

Step # 2

Configure kernel Before you configure kernel make sure you have development tools (gcc compilers and related tools) are installed on your system. If gcc compiler and tools are not installed then use apt-get command under Debian Linux to install development tools.Also we need the libncurses5-dev for the menuconfig

# sudo apt-get install gcc
# sudo apt-get install libncurses5-dev

Step # 2

Extract tar (.tar.bz3) file Type the following command:

 # sudo tar -xjvf linux-3.0.3.tar.bz2 -C /usr/src
 # cd /usr/src
Now you can start kernel configuration by typing any one of the command:

$ make menuconfig – Text based color menus, radiolists & dialogs. This option also useful on remote server if you wanna compile kernel remotely.

$ make xconfig – X windows (Qt) based configuration tool, works best under KDE desktop

$ make gconfig – X windows (Gtk) based configuration tool, works best under Gnome Dekstop. For example make menuconfig command launches following screen:

$make config  – Textmode

You have to select different options as per your need. Each configuration option has HELP button associated with it so select help button to get help.

Step # 4

Enter:

$ sudo make

Start compiling to kernel modules:

$ sudo make modules

Install kernel modules:

$ sudo make modules_install

Step # 5

So far we have compiled kernel and installed kernel modules. It is time to install kernel itself.

# make install

It will install three files into /boot directory as well as modification to your kernel grub configuration file: System.map-2.6.25 config-2.6.25 vmlinuz-2.6.25

Step # 6:

Type the following command at a shell prompt:

#sudo update-grub

Step # 8 :

Reboot computer and boot into your new kernel Just issue reboot command:
#sudo shutdown -r now

Advertisements

About vineethkartha

Hi, I am Vineeth Kartha, I hold a Masters degree in Embedded Systems from BITS Pilani, Goa Campus. I currently work as a Software Developer. I am A free software promoter and electronics hobbyist. In my free time I do a little bit of birding and Wildlife photography. I love travelling, reading and blogging.

Posted on August 30, 2011, in Technical. Bookmark the permalink. Leave a comment.

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s

%d bloggers like this: