Compiling the Kernel

Compiling a kernel is just a sequence of simple make commands… But before that you gotta make sure of the following…

1. Move the kernel you want to compile to /usr/src

2. Change to the directory where your kernel is placed…

cd /usr/src/kernelx.x.x.x

3 .The next step is to execute a series of “make” commands…

make config /* here you’ll have to entertain a large number of

* kernel options though!



make oldconfig /* takes the default values of the previous compliation, be

* careful before using this, its much faster and easier, but

* you may not even want that configuration



make menuconfig


make xconfig

4. Now you have to make the dependencies… do that by using…

make dep

5. Next run

make /* this will make all the files that are present in the kernel */

6. After doing these basic steps, you need to make the bootable image of the kernel.

make bzImage

This image you create will be stored at /usr/src/linux/arch/i386/boot/bzImage. Copy this to the “boot” directory.

cp /usr/src/linux/arch/i386/boot/bzImage /boot/vmlinuz-x.x.x.x

7. Once you are done with this much, make the modules and install them by running the following commands.

make modules

Now make sure you are the root or else the modules wont install.

make modules_install

8. Now

mkinitrd /boot/initrd-x.x.x.x.img x.x.x.x

where x.x.x.x will be the directory of the modules for the new kernel. This directory can be seen when you do an ls like this:

ls /lib/modules

then: cp /boot/

then: ln -sf /boot/ /boot/

and then: cp bzImage /boot/bzImage

8. Lastly you have to edit the grub or lilo depending on what your boot-up uses.

edit /etc/grub.conf by adding your entry like this:

title mynewKernel

root (hd0,1)

kernel /boot/vmlinuz-x.x.x.x ro root=dev/hda2

edit /etc/lilo.conf by adding your entry like this:

image = /vmlinuz-x.x.x.x

label = mynewKernel

root = /dev/hda2

save and run lilo by running a simple command as below:



This entry was posted in kernel, linux, linux kernel, tutorials. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s