Please Note: You should atleast read Eric Hameleers’ Guide once if you are new to kernel compiling. I always refer this guide to people who just started kernel compiling since it’s very well-written and explained in details. Here is the link.

This is my second kernel compile guide [actually more like a report of my experience]. A few things I did differently than last time, so instead of updating the previous guide I thought of creating a new one. So, here goes.

Get root privilege by using su, then continue.

# cd /usr/src/

# rm -rf linux

# wget -c

# tar xvfj linux-2.6.32.tar.bz2

# ln -s /usr/src/linux-2.6.32 /usr/src/linux

Now your linux directory points to your newly extracted kernel tree source.

I am not going to link my kernel config here as many people previously asked me why their kernel config didn’t work, it’s not supposed to! Your hardware is different than mine and my .config will be different than yours. So you must understand what to enable or disable in your own kernel config. Or just use:

# cp /usr/src/linux- /usr/src/linux

Now run:

# make localmodconfig

Now you can strip off your kernel and fine tune your config. Remove support for what you don’t need and select accordingly. Read more about it here.

Now run :

# make menuconfig

Carefully check out each sections to see if localmodconfig stripped off something which you need.

WARNING: My USB Mass storage device support and Intel Sound card support was stripped off by localmodconfig and hence I had to recompile kernel again with those support re-enabled.

Now scroll all the way down and select load kernel configuration and press enter to select the .config.

# make

This will take a while, meanwhile open another tab and configure lilo.

# nano /etc/lilo.conf

Scroll all the way down and copy the existing linux entry. Just change the part which says /boot/vmlinuz to /boot/bzImage and then add another line just below it called initrd. Here’s my entry:

image = /boot/bzImage
initrd = /boot/initrd.gz
root= /dev/hda3
label = Linux

Remember to replace /dev/hda3 with your own root partition. Yes yes, I know we haven’t created an initrd image yet. Patience! Just save and exit for now.

Now that make is over run:

# make modules_install

# cp arch/x86_64/boot/bzImage /boot/bzImage

# cp /boot/

# rm /boot/

# ln -s /boot/ /boot/

You may copy over the config file to /boot but I see now use for that and hence I skipped it.

Anyways, now for the next step, you are own your own since it depends on what partition type you are using. I use ext3 throughout and have no separate partition for /boot and hence this is how I generated my initrd image. Please refer to /boot/README.initrd file for details!

# mkinitrd -c -k 2.6.32~pdg -m mbcache:jbd:ext3 -f ext3 -r /dev/hda3

# cd /etc/rc.d

# rm rc.modules

# cp rc.modules- rc.modules-2.6.32~pdg

# ln -s /etc/rc.d/rc.modules-2.6.32~pdg /etc/rc.d/rc.modules

# lilo

If you get a warning about LBA32 just add “lba32″ in your lilo.conf and re-run lilo. And now reboot into your new kernel!

Good Luck 😀