Category Archives: 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!

*/

OR

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

*/

OR

make menuconfig

OR

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 System.map /boot/System.map-x.x.x.x

then: ln -sf /boot/System.map-x.x.x.x /boot/System.map

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:

/sbin/lilo

Reboot.

All kernel hackers will need to compile kernels sometime for sure… However before compiling a kernel there may be some issues you need to take care of. If you are compiling older kernels, like kernel versions before 2.4.x you’ll need to first prepare your system for it.

the following issues need to be taken care of:

* Older version of gcc

If you compile your old kernel with any other version of gcc, you’ll probably get errors. Most newer Linux distributions ship with gcc 3.x. You can have more than one version of gcc installed on your system. Install gcc 2.95.3, without overwriting your existing gcc installation. You can download an older version here:

http://gcc.gnu.org/mirrors.html

you will find several sites hosting gcc installations. Remember you are not overwriting the current installation, you are just installing multiple versions of gcc. Here’s a tutorial to help you out with that:

http://www.tellurian.com.au/whitepapers/multiplegcc.php

* as86 and ld86

Once you have an older gcc installed, compiling the kernel may give you errors like “as86:command not found” or “ld 86: command not found”. To put it briefly, as86 is the 80*86 assembler and ld86 is the linux loader. You’ll need to make sure these are installed on your system. You’ll get as86 and ld86 here:

http://homepage.ntlworld.com/robert.debath/dev86/

You can just download bin86 from here. That package will suffice to all your requirements.

* Modifying your makefile

Now that you have the older gcc, you will have to alter the makefiles to use the new compiler. Suppose you have installed the additional compiler in /usr/bin/gccold/bin/gcc, then, in your makefile replace all the “gcc”s with the new path, ie, “/usr/bin/gccold/bin/gcc”. Like this:

Once you have taken care of the above three steps, your system is ready to compile older kernels .

I am doing a project and it deals with kernel programming. In the course of this project i’ve realized how little documentation about the kernel source code is available, however the kernel is changing everyday and it would be impractical to expect a decent documentation that will clear all our doubts about the kernel.

The linux kernel is so huge that by the time one makes a document describing a certain version of the kernel, newer versions will be already be in use. But some parts of the kernel never change and through this blog i would just like to present some facts about the kernel that i hope will help everybody…

As a starter, we all know that even though linux is open source, the distributions do not give out the complete code, instead makefiles are present in the respective directories. Anyone programming with the kernel will be much happier with a code to refer.

Here are some links…

You can download the linux kernel code from http://www.kernel.org/pub/linux/kernel/ .You can find all versions of the source code here.

For an online reference to the kernel use this link…. http://lxr.linux.no/source/

Well i guess that ends the first post!