We have four different versions of Linux kernel installed by the yum command under CentOS Linux. Currently, I am using only latest version 2.6.18-53.1.4.el5. What is proper and suggested method to remove old kernels from a CemtOS / Debian Linux server?
Most Linux distro keeps old kernel files so that you can revert in case of emergency pop up due to hardware or software incompatibility issues. A kernel is nothing but a set of files on Linux box. Following is the suggested way to remove old kernels safely on Linux based system.
Step # 1: Find the current kernel version
uname -r
Sample outputs:
2.6.18-53.1.4.el5
Step #2: List all installed kernels
Use the rpm command or dpkg command on Linux:
# rpm -q kernel
Sample outputs (from RPM based distro such as CentOS/RHEL):
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
Debian / Ubuntu Linux user, enter:
$ dpkg --list 'linux-image*'
Sample outputs:
Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Installed/Config-f/Unpacked/Failed-cfg/Half-inst/t-aWait/T-pend |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad) ||/ Name Version Description +++-=============================-=============================-========================================================================== ii linux-image 2.6.22.14.21 Generic Linux kernel image. un linux-image-2.6 (no description available) rc linux-image-2.6.20-15-generic 2.6.20-15.27 Linux kernel image for version 2.6.20 on x86/x86_64 ii linux-image-2.6.20-16-generic 2.6.20-16.32 Linux kernel image for version 2.6.20 on x86/x86_64 ii linux-image-2.6.22-14-generic 2.6.22-14.47 Linux kernel image for version 2.6.22 on x86/x86_64 ii linux-image-generic 2.6.22.14.21 Generic Linux kernel image
Step #3: Remove all old kernels
Choose which kernel you want to uninstall from the list of those installed. Type the following command to remove the kernel package under RHEL / CentOS / Fedora Linux:
# rpm -e kernel-2.6.12-1.el5
Type the following command to remove the kernel package under Debian / Ubuntu Linux:
$ sudo apt-get remove linux-image-2.6.22-14-generic
Please note that on newer system all obsolete kernels and headers should automatically be flagged as no more needed, and thus can be purged with the following single command:
$ sudo apt-get --purge autoremove
Sample outputs:

(adsbygoogle = window.adsbygoogle || []).push({});