How to compile the Linux kernel
When I joined C-DAC(Formerly NCST) Bangalore, as a
technical associate(TA) , beside learning about the project,
which I'm part of, the task assigned to me was to write a
loadable kernel module(LKM). As a part of that task, I
wanted to upgrade the kernel on my machine to the latest
one. I started to look around for the material and books for
help. In all these efforts Google(http://www.google.com)
played an important role; also our library always proves to
be one of the best for that matter. After some early work I
could find out following steps to compile the linux kernel
1 Download the Linux kernel from http://www.kernel.org
2 Untar the tarball using either "tar -xzf" for ".tgz"
file or "tar -xjf" command for ".tar.bz2" file.
3 Go the kernel directory
4 make [config/menuconfig/defconfig/xconfig] This will
invoke either an editor to let you configure kernel
parameters or may ask questions in an interactive mode
in case of "make config". At the end of configuration
you'll have ".config" file written in the same direc-
tory. It's not reccomended you to edit this file.
5 make bzImage: This will start the actual compilation
process and at the end of this step you'll have
"vmlinuz" file ready, which is your kernel image.
6 make modules: This will compile the loadable kernel
modules source files to generate the kernel object(.ko)
files in case of Linux kernel-2.6.x and object(.o)
files for the kernels prior to kernel-2.6.x
7 make modules_install: This command needs the root priv-
ileges, so you gotta do the root login before executing
this command. As this command will create the directory
"linux-" under "/lib/modules" and copy
all the object files and dirvers generated so far in
8 make install: This command will make the necessary
changes in the boot loader configuration file so that,
when you reboot the system you'll see the option to
boot into this freshly compiled Linux kernel.
. Always keep a running kernel image untouched, so in
case if new kernel image is unable to boot, you can
always boot with the old kernel and do the nessary
. Also do not forget to read the kernel documentation.