How To: Compile Linux Kernel 2.6
How To: Compile Linux Kernel 2.6
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 y step howto covers compiling Linux kernel
version !.".xx under #eian $%& Linux. However, instructions remains the same for any other
distriution except for apt'get command.
Step # 1 Get Latest Linux kernel code
(isit http)//kernel.org/ and download the latest source code. *ile name would e linux'
x.y.+.tar.+!, where x.y.+ is actual version numer. *or example file inux'!.".!,.tar.+!
represents !.".!, kernel version. &se wget command to download kernel source code)
$ cd /tmp
$ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-x.y.z.tar.bz2
%ote) -eplace x.y.+ with actual version numer.
Step # 2 Extract tar (.tar.!"# $ile
Type the following command)
# tar -xv! linux-2.6.2".tar.bz2 -# /u$r/$rc
# cd /u$r/$rc
Step # " Con$i%ure kernel
.efore you configure kernel make sure you have development tools /gcc compilers and related
tools0 are installed on your system. 1f gcc compiler and tools are not installed then use apt'get
command under #eian Linux to install development tools.
# apt-get in$tall gcc
%ow you can start kernel configuration y typing any one of the command)
& make menucon$i% ' Text ased color menus, radiolists 2 dialogs. This option also
useful on remote server if you wanna compile kernel remotely.
& make xcon$i% ' 3 windows /4t0 ased configuration tool, works est under 5#6
desktop
& make %con$i% ' 3 windows /$tk0 ased configuration tool, works est under $nome
#ekstop.
*or example make menuconfig command launches following screen)
$ make menucon!ig
7ou have to select different options as per your need. 6ach configuration option has H6L8
utton associated with it so select help utton to get help.
Step # ' Compile kernel
9tart compiling to create a compressed kernel image, enter)
$ make
9tart compiling to kernel modules)
$ make module$
1nstall kernel modules /ecome a root user, use su command0)
$ $u -
# make module$%in$tall
Step # ( )nstall kernel
9o far we have compiled kernel and installed kernel modules. 1t is time to install kernel itself.
# make in$tall
1t will install three files into /oot directory as well as modification to your kernel gru
configuration file)
9ystem.map'!.".!,
config'!.".!,
vmlinu+'!.".!,
Step # 6: Create an initrd ima%e
Type the following command at a shell prompt)
# cd /boot
# mkinitrd -o initrd.img-2.6.2" 2.6.2"
initrd images contains device driver which needed to load rest of the operating system later on.
%ot all computer re:uires initrd, ut it is safe to create one.
Step # * +odi$, Gru con$i%uration $ile -
.oot.%ru.menu.lst
;pen file using vi)
# vi /boot/grub/menu.l$t
title &ebian '()/*inux+ kernel 2.6.2" &e!ault
root ,hd-+-.
kernel /boot/vmlinuz root//dev/hdb0 ro
initrd /boot/initrd.img-2.6.2"
$avede!ault
boot
-ememer to setup correct root</dev/hd33 device. 9ave and close the file. 1f you think editing
and writing all lines y hand is too much for you, try out update'gru command to update the
lines for each kernel in /oot/gru/menu.lst file. =ust type the command)
# update-grub
%eat. Huh>
Step # / : 0eoot computer and oot into ,our new kernel
=ust issue reoot command)
# reboot