Compile Linux kernel 2.6

Compiling custom kernel has its own advantages and disadvantages. However, new Linux user / admin find it difficult to compile Linux kernel. Compiling kernel needs to understand few things and then just type couple of commands. This step by step howto covers compiling Linux kernel version 2.6.xx under  Linux distro

Note: Before getting started with the process you need to install a gcc compiler to build the kernel

Step # 1 Get Latest Linux kernel code

Visit http://kernel.org/ and download the latest source code. File name would be linux-x.y.z.tar.bz2, where x.y.z is actual version number. For example file lnux-2.6.34.tar.bz2 represents 2.6.34 kernel version. Use wget command to download kernel source code:

# cd /opt
# wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-x.y.z.tar.bz2

Replace x.y.z with your version

Step # 2 Extract tar (tar.bz2) file

Type the following command:
# tar -xjvf linux-2.6.34.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 menuconfig

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.

Note: After selecting required options in this screen .config file will get generated. Edit the .config file by adding this option in it & save

CONFIG_SYSFS_DEPRECATED_V2=y

Step # 4 Compile kernel

Start compiling to create a compressed kernel image, enter

# make bzImage

Compile kernel modules

# make modules

Install kernel modules

# make modules_install

Step # 5 Install kernel

#  make install

It will install three files into /boot directory as well as modification to your kernel grub configuration file:

  • System.map-2.6.34
  • config-2.6.34
  • vmlinuz-2.6.34

Step # 6 : Reboot computer and boot into your new kernel

# reboot

 

Enjoy working on newly builded kernel by yourself.

 

Advertisements
By impavan

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