Friday, November 04, 2005

Compiling the Linux kernel

I'm writing this post from FireFox running on Linux kernel 2.6.14 that I just compiled, installed and booted into. Feels real good!

The newbies article was a great one to help with this effort. The information on installing the kernel using grub was absent. I use RedHat with grub and I found how to get grub updated with the new kernel following this blog post.

However, there were a couple of things I did differently due to paronia. :) I basically didn't want to allow the possibility of the new install replacing my working Linux kernel so I manually changed grub.conf file. So the steps are as follows:

1. copy kernel src gz file to /usr/src/
2. uncompress the gz file to create /usr/src/linux
3. make menuconfig
4. make bzImage (I had to do this instead of - make zImage due to poor machine spec)
5. make modules
6. make modules_install (This is the step that installs the new modules to /lib/modules/ so it is better to install a version greater than what you have so that there will be no file clobbering)
7. copy the kernel image (/usr/src/linux/arch/i386/boot/bzImage) over to /boot/vmlinuz-2.6.14-0.0000
8. copy /usr/src/linux/System.map to /boot/System.map-2.6.14-0.0000
9. mkinitrd /boot/initrd-2.6.14-0.img 2.6.14 (this step creates the RAM disk image that the kernel uses at early boot time, the second parameter corresponds to the directory where libs were installed; ie lernel_version in /lib/modules/)
10. Now open /etc/grub.conf in your favorite editor and add a stanza similar to what you have for the primary kernel. Change the kernel and initrd parameters to point to the new kernel and the RAM disk image.

Here is my grub.conf relevant parts (before):

title Fedora Core (2.6.12-1.1447_FC4)
root (hd0,0)
kernel /vmlinuz-2.6.12-1.1447_FC4 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.12-1.1447_FC4.img

grub.conf relevant parts (after):

title Fedora Core (2.6.12-1.1447_FC4)
root (hd0,0)
kernel /vmlinuz-2.6.12-1.1447_FC4 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.12-1.1447_FC4.img

title Fedora Core (2.6.14)
root (hd0,0)
kernel /vmlinuz-2.6.14-0.0000 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.14-0.img

11. Turn on loud music and reboot, pick the new kernel and step into a new world ;-)