How to Remove Old Linux Kernels

Linux distributions that use binary packages usually install kernel updates in separate directories from previous kernel versions. Therefore, it is possible to have several instances of Linux installed within the same system. This is a precaution that prevents you from overwriting your kernel with one that may not function the way you want, or at all.

On CentOS, it is a good idea to install new kernels and test them to make sure they work before doing anything to the old kernels. After you have confirmed that your current kernel is the one you want to keep, you can then take steps to remove the old ones. Follow these steps to remove old kernels.

  1. Before proceeding, find out your current kernel version:
    uname -r
    The output will look like this
    2.6.18-53.1.4.el5
  2. Find out the names of all kernels currently installed:
    rpm -q kernel
    The output will look like this:
    kernel-2.6.12-1.el5
    kernel-2.6.18-17.el5
    kernel-2.6.18-53.el5
    kernel-2.6.18-53.1.4.el5
  3. Remove the old kernels
    rpm -e kernel-2.6.12-1.el5

Perform #3 for all old kernels until they are all gone. Warning: Be extra careful and make sure you do not remove the current kernel. That is why you ran “uname”, to see which kernel is the current default. If you run into any trouble, you should always have at least one kernel remaining that will allow your system to still boot. If you are unsure about this process, just leave it alone. Your system will still function just fine, even with old kernels still installed.

 











Comments: