Remove old kernels

If you are like me, you like to download the greatest and newest
kernel whenever it comes out and install it.  It's easy if you download
the rpm for the kernel when you want to remove it. 

1. First, to see what kernels you have installed on your computer using
rpm, type, as root, the following, "rpm -qa | grep kernel":

 
[root@blueox]# rpm -qa | grep kernel
kernel-utils-2.4-13.1.39
kernel-smp-2.6.9-1.681_FC3
kernel-smp-2.6.9-1.724_FC3

This will list all the rpm's you have installed that contain the word
'kernel'

2. Next, to delete, simply type at a shell:

 
[root@blueox]# rpm -e <kernel_you_want_to_delete>

And thats all you have to do if the kernel was installed as an rpm.

If you downloaded the source and compiled as shown here you should
do the following to delete an old kernel.

1. First, go to where you installed the source.  For me, I install
in /usr/src

2. Now say I installed kernel version 2.6.10.  Go to /usr/src and as
root type:

[root@blueox]# rm -rf linux-2.6.10

This will delete the folder 'linux-2.6.10'

3.  Now delete the following folders and files:
   
rm -rf /lib/modules/2.6.10
rm -f /boot/vmlinuz-2.6.10
rm -f /boot/initrd-2.6.10
rm -f /boot/System.map-2.6.10
rm -f /boot/config-2.6.10

4. Next, open up as root /boot/grub/grub.conf and delete the lines that
read:

title Fedora Core (2.6.10)
root (hd0,2)
kernel /boot/vmlinuz-2.6.10 ro root=LABEL=/ rhgb quiet apm=off acpi=on
initrd /boot/initrd-2.6.10.img

5.  And finally, specify the kernel you want to have boot by default. 

1. First, open up /boot/grub/grub.conf as root. 

[root@blueox]# vim /boot/grub/grub.conf

2. Next, change the number in the line:

default=0

Where 0 is the first kernel listed under grub.conf, 1 is the second kernel listed, and so on
to the kernel which you would like to boot by default.

Below is an example how a kernel is listed and options specified:

title Fedora Core (2.6.9-1.681_FC3smp)
root (hd0,2)
kernel /boot/vmlinuz-2.6.9-1.681_FC3smp ro root=LABEL=/ rhgb quiet apm=off acpi=on
initrd /boot/initrd-2.6.9-1.681_FC3smp.img


And that's it.......