Home

Linux Kernel Compile

In every book or how-to I read about Linux it is recommended to re-compile the Kernel. There are many reasons for wanting to compile the kernel, but I have two that really motivate me. Firstly I want to see if there is a performance improvement when I compile the kernel for my processor instead of the generic processor support given in the pre-compiled kernel. Secondly I would like to be able to install and test any kernel I find, especially new ones. I have tried to several times with various levels of success but I never have actually managed to compile, install, boot and use a kernel. I would like to change this situation because frankly I am amazed at just how difficult this seemingly regular task has turned out to be. During my next attempt I'm going to do things very slowly documenting every step (see bulleted list below). I this way, I'll be able to trace my steps and tell people what I've done when asking for help. If I succeed (and I will eventually succeed) I will have a step-by-step document that may be useful to somebody else with the same problem.
1. Make a (reduced) clone of my system on another partition. I’ve got other projects going on my main system and I’d rather not screw them up. a. This part is done. There are a few differences between my main system and this test system. My system is based on Mandrake9.1 upgraded to mandrake 9.2 and resides on 4 partitions, the test does not have separate partitions (except swap) and has been made using a straight install of 9.2.
2. Make a list of all the relevant documents available, review them and decide which ones I'm going to follow;
a. The Linux Kernel HOWTO
b. Kernel Release notes
3. Try to recompile the same kernel as the one already running on the test system using the same config file only a few modifications such as processor type. These are the steps which I have taken. This is pretty much loyal to the How-to.
3.1. Decompress kernel source into /home directory. This is a 2.4.22 kernel that is the same as the kernel used on Mandrake 9.2. I have chosen this kernel because it is the same and not because it is the kernel of my dreams. The package I have used is not a source rpm from mandrake.
3.2 Soft link from /usr/src/linux to the source dir as is instructed in the How-to. This is not in agreement with the release note that says that this area has the header files. Actually this area is empty on my distribution.
3.3 cp /boot/config /usr/src/linux/.config . I want to use the same config file as the compiled kernel as I know that it already works.
3.4 make clean
3.5 make mrproper
3.6 make xconfig . Changed processor to my processor family.
3.7 make dep
3.8 Edit the extraversion parameter in the Makefile to give the dphversion name to the kernel.
3.9 make bzImage
3.10 cp /usr/src/linux/arch/i386/boot/bzImage /boot/bzImage.dphkernel.7.12.03
3.11 make modules – Actually both ‘make bzImage’ and ‘make modules’ had the output redirected to files as per the instructions in the how-to. Neither of the output files contained any errors.
3.12 make modules_install
3.13 Use mkinitrd to make a new initrd.img . Copy the initrd.img to /boot taking care with names and links not to overwrite the old one.
3.14 Write kernel entry in lilo.conf.
3.15 The new kernel does not boot. Blocks after lilo. The graphical lilo screen installed by default on Mandrake doesn’t exit. The only button the computer responds to is the reset. Possible solutions;
i. Remove all graphical boot splash stuff and graphical lilo interface to see what is happening.
ii. Try again starting from 3c without changing the processor family.
iii. Install gcc2.95.3 as recommended in the readme, I can’t believe this is the problem.
3.16 Well I just did the 1st item on the ‘Possible solutions’ list above and the kernel booted. I honestly didn’t expect that. I change lilo to graphical mode using the Mandrake control centre. This should probably be tested later to find out why it is like this.
4. Test the new kernel (I haven't decided how I'll test it yet, I'd like to compare it to the original).
a.There are two error messages during boot.
i.One is for the vfat file system, which has not been enabled. Why? I used the same config file as the pre-installed kernel and that supports the vfat system. The windows partition is in my fstab so the kernel tries to mount it during start up.
ii.The second is to do with the sound card driver that has a similar module problem. Frankly I don’t understand this much. Either I did compile the module, so it should work, or I left it out, so why is it looked for during boot?
b.The kernel seems a bit slow. I need to check my processor family and the hdparm parameters. I did get a bit of improvement using hdparm on my main system.
5. If all the above is successful then I will use exactly the same procedure to recompile the kernel of my working system.
6. Go back to the test system and recompile a more recent or interesting kernel or the same kernel with some of the options removed to reduce it size.