Compiling Kernel (For newbies)

Actually u can find many tutorials regarding this,But i dint find a appropriate one suiting me when i compiled the kernel for the first tym a year back…So thought of to give a detailed procedure

–>Compiling and setting up a kernel for the first time can be a daunting task even for users who are comfortable in everyday Linux use so I hope this guide will make the process a little easier and help get your new kernel up and running as fast as possible. I assume a level of competency with basic Linux commands and the environment.
–>Getting the kernel source
The kernel source can be downloaded from Once you have the source move it into /usr/src.

–>Configuring your new kernel

First you need to determine what type of hardware you have. This can be done using the command ‘lspci’
You’ll particularly need to know the IDE Chipset, Audio Controller, and the Ethernet Controller. You won’t normally need to know your VGA Controller type when compiling the kernel. There are several methods of configuring the kernel with version 2.6

* make config
* make oldconfig make menuconfig
* make xconfig make gconfig

We will be using make menuconfig. Its relatively simple to use and doesn’t have many requirements. All you need are the ncurses dev files. In my opinion the QT and GTK installers just add unnecessary fluff. On debian a simple apt-get install libncurses5-dev should take care of that.

Now its really just a matter of going through the options an various menus and picking what suits your hardware and set up. If your unsure on anything you can highlight the option your unsure of and press ?. You can chose to compile things directly into the kernel (fill the box beside them with a * by pressing the space bar) or compile them as a module and insert them into the kernel as needed (by filling the box with an M). Certain things that are required to boot the kernel are best to be built in (such as IDE drivers etc) but for other non-critical stuff then its just as good, if not better, to build them as modules. At a later stage if you need to upgrade a driver thats compiled as a module you can just plug it out and insert the new one into the kernel but if its compiled in then a recompile of the kernel will be required.

–>Building the new kernel

1. sudo make bzImage
2. sudo make modules
3. sudo make modules_install
The modules will be copied into /lib/modules/KERNELVERSION

–>Installing the new kernel

Now its just a matter of copying the newly compiled kernel and into /boot.
For me it looked like this

kranny@Desktop:/usr/src/kernel-source-2.6.23$ pwd
kranny@Desktop:/usr/src/kernel-source-2.6.23$ sudo mv arch/i386/boot/bzImage /boot/bzImage-2.6.23
kranny@Desktop:/usr/src/kernel-source-2.6.23$ sudo mv /boot/

–>Getting ready to boot

Now that the kernel is in place we just have to edit our boot loaders config file and add the new kernel.

If you are using the grub boot loader (and you probably are) this file is normally in /boot/grub and is called menu.lst. As I’m using Debian I can only guarantee it is there for my particular install. If you’re using a different OS then check out its documentation for the correct location. Look at the other entries and copy their structure to add your new kernel to the list. You must be root. Ignore the initrd option as we haven’t created one and they aren’t normally necessary.

Hope this tutorial be of some help to u

One Reply to “Compiling Kernel (For newbies)”

Leave a Reply

Your email address will not be published. Required fields are marked *