You are on page 1of 13

Why Compile a New Kernel?

• You may be thinking "But why recompile it? It works fine as it is." There are three reasons for a recompile. Firstly, you may have some hardware that is so new that there's no kernel module for it in on your distribution CD. Secondly, you may have come across some kind of bug which is fixed in a revision of the operating system. Lastly, you may have some new software which requires a newer version of the operating system.

bz2 represents 2.z is actual version Compilation • Step # 1 Get Latest Linux kernel code • Visit http://kernel.25.tar.y.6.25 kernel version. File name would be and download the latest source code. • 2-Major version • 6-Minor version • 25-Sub version The most recent releases of the kernel sources are available on ftp.bz2. For example file inux-2.y.6. . where x.tar.

Kernel Compilation • Step # 2 Extract tar (.tar.6.bz3) file • Type the following command: # tar -xjvf linux-2.bz2 -C /usr/src # cd /usr/src .tar.25.

This option also useful on remote server if you want compile kernel remotely. • For example make menuconfig command launches following screen: $ make menuconfig • You have to select different options as per your need.Kernel Compilation • Step # 3 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 Linux to install development tools.X windows based configuration tool. works best under Gnome Dekstop. # apt-get install gcc • Now you can start kernel configuration by typing any one of the command: • $ make menuconfig .X windows based configuration tool. works best under KDE desktop • $ make gconfig . Each configuration option has HELP button associated with it so select help button to get help. • $ make xconfig . radiolists & dialogs.Text based color menus. .

35. allows the user to choose the features of the Linux kernel (and other options) that will be compiled. with a convenient menu userinterface. a necessary early step needed to compile the source code.• make menuconfig is one of three tools (actually four starting with kernel 2. .6. make menuconfig. there is a new option: make nconfig that is similar to menuconfig) that can configure the Linux kernel source. It is normally invoked using the command make menuconfig. menuconfig is a target in the Linux kernel Makefile.

make menuconfig .

enter: $ make .Kernel Compilation • Step # 4 Compile kernel • Start compiling to create a compressed kernel image.

Kernel Compilation • Step # 5 Compile kernel Modules • Start compiling to kernel modules: $ make modules .

Kernel Compilation • Step # 6 Install kernel Modules • Install kernel modules (become a root user. use su command): $ su # make modules_install .

It is time to install kernel itself.25 • # make install • It will install three files into /boot directory as well as modification to your kernel grub configuration file: • System.25 • vmlinuz-2.25 .Kernel Compilation • Step # 7 Install kernel • So far we have compiled kernel and installed kernel modules.

Not all computer requires initrd. . but it is safe to create one.Kernel Compilation • Step # 8: Create an initrd image • Type the following command at a shell prompt: # cd /boot # mkinitrd -o initrd.6.25 • initrd images contains device driver which needed to load rest of the operating system later on.6.img-2.25 2.

Kernel Compilation • Step # 9 Modify Grub configuration file .25 Default root (hd0.0) kernel /boot/vmlinuz root=/dev/hdb1 ro initrd /boot/initrd.img-2.lst • Open file using vi: # vi /boot/grub/menu.lst title Debian GNU/Linux. kernel 2. Save and close the file. Just type the command: # update-grub .6.6. try out update-grub command to update the lines for each kernel in /boot/grub/menu. If you think editing and writing all lines by hand is too much for you./boot/grub/menu.25 Savedefault boot Remember to setup correct root=/dev/hdXX device.lst file.

Kernel Compilation • Step # 8 : Reboot computer and boot into your new kernel • Just issue reboot command: # reboot .