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
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:
Step # 6 : Reboot computer and boot into your new kernel
Enjoy working on newly builded kernel by yourself.