Saturday, November 12, 2005

Linux tips: Compiling & installing the linux kernel

In as many years as I've fiddle with the linux os, I've shun the ordeal of compiling my own kernel. I mean it's like rocket science to me more than anything else. I'm a hardware guy. I would rather overclock my cpu & if it failed, atleast I would know immediately. Rather than compiling codes for hours & only to find that it won't work cos I missed out something, hours later.

Today, however, I have finally taken that big step for once, to compile my own kernel. Not that I have suddenly amassed enough courage or what, but rather, I have no choice, cause I can't get linux work with my new hardwares.

Just so that I can remember what I did. I shall blog this down, as suggested by my friend yewfai.

Background:

To start it off. My hardwares are AMD64 3000+(Venice core) on a AsRock 939S56M mATX motherboard. So the first problem I encountered with linux is that the SIS 190 lan chip won't work with any existing version of kernel. I mean I've tried doing live update of kernel in Fedora Core 3 or 4, todate, they are only at 2.6.12 & 2.6.13 respectively & it looks as if I'm not going to get the chip working for a long while. From this thread. I learnt that I could actually get it working with a manual install of the 2.6.14 kernel .

Starting off: Resources & HowTo

After googling around, I found the Digital Hermit's guide to be comprehensive & so I used that. Kernel source was downloaded from www.kernel.org's mirror.

Working on it:


I supposed the procedure of installing kernel is documented in many sites & so I shall be brief. First go to /usr/src & do

tar xfvj /where/you/store/linux-2.6.14.1.tar.bz2

The tar command above will unzip the kernel source file into /usr/src/linux-2.6.14.1 After which, change directory to /usr/src/linux-2.6.14.1 & before we start, we do a

make mrproper

That will wipeout all previous configuration & resetting the source directory to a pristine state. The main reason for doing this is that some files do not automatically get rebuilt & resulting in buggy kernel. After which, we start by configuration what should be included into the kernel by doing

make menuconfig

That select the hardwares suitable for my system. Few things to note is to selecting the correct cpu type, like Opteron/AMD64 cpu & enabling the PREMPTIVE mode to speed up desktop response. And of course I made sure that the option of sis 190 lan chip is there. Just to make it even more idiot proof. I choose to built it into the kernel instead of as a loadable module. That is changing the option from 'M' to '*' in make menuconfig.

After that, I do the following to compile the kernel, make the modules, install the modules & generating initial ram disk, that pretty much concluded the work on 'compiling the kernel' . One thing to note that, I was confused with the need of ram disk & missed out the mkinitrd step. Ended up, I couldn't boot the the new kernel due to missing initrd-2.6.14.1.img file.


make clean
make bzImage
make modules
make modules_install
mkinitrd /boot/initrd-2.6.14.1.img 2.6.14.1

Installing the kernel.

The new compiled kernel is named bzImage & stored at arch/i386/boot/. The following steps are necessary to move it to the appropriate directory.

cp arch/i386/boot/bzImage /boot/bzImage-2.6.14.1
cp System.map /boot/System.map-2.6.14.1
ln -s /boot/System.map-2.6.14.1 /boot/System.map

Configuring grub bootloader


To start off grub.conf is at /etc directory. Edit it to include option to point to my newly install kernel at /boot/bzImage-2.6.14.1. You can see my grub.conf below. Note the locations of the root (hd0,6) & root=/dev/VolGroup00/LogVol00 rhgb quiet locations. It may vary depending on where you put the /boot partitions & which file system one uses. I just copied the same from the existing FC3 entried in grub.conf.

default=0
timeout=5
splashimage=(hd0,6)/grub/splash.xpm.gz
hiddenmenu
title Fedora Core (2.6.12-1.1381_FC3)
root (hd0,6)
kernel /vmlinuz-2.6.12-1.1381_FC3 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.12-1.1381_FC3.img
title Fedora Core (2.6.9-1.667)
root (hd0,6)
kernel /vmlinuz-2.6.9-1.667 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.9-1.667.img
title Test Kernel (2.6.14.1)
root (hd0,6)
kernel /bzImage-2.6.14.1 ro root=/dev/VolGroup00/LogVol00 rhgb quiet enforcing=0
initrd /initrd-2.6.14.1.img
title Other
rootnoverify (hd0,0)
chainloader +1

Rebooting:

On rebooting, I encountered 3 problems.

1, kernel file not found. That is resolved by changing

kernel /boot/bzImage-2.6.14.1 ro root=/dev/VolGroup00/LogVol00 rhgb quiet to
kernel /bzImage-2.6.14.1 ro root=/dev/VolGroup00/LogVol00 rhgb quiet

As grub assumed to read from /boot directory.

2, initrd-2.6.14.1.image file not found. That is resolved by running this

mkinitrd /boot/initrd-2.6.14.1.img 2.6.14.1

As mentioned above, that is what I missed ealier. It simply generates the ramdisk file for the new kernel.

3, kernel panic with 'Enforcing mode request but no policy loaded'. That is resolved by adding 'enforcing=0' in grub.conf.

kernel /bzImage-2.6.14.1 ro root=/dev/VolGroup00/LogVol00 rhgb quiet enforcing=0

Final words

There it goes. Now I have my SIS190 lan chip recognised & blogging it from the very same mahchine.

One may wonder, if my lan chip isn't working. How do I get all those resources from the net? Oh well, that's where a S$1 SMC network card came to the rescue. After the install, I just take out the SMC card & plug the cable into the SIS190 & viola.

Job done. Boy, all that trouble for a network card??? One wonders.

0 Comments:

Post a Comment

<< Home