Q. We have 4 different versions of Linux kernel installed by yum command under CentOS Linux. Currently I'm using only latest version 2.6.18-53.1.4.el5. What is the proper and suggested method to remove old kernels from a CemtOS / Debian Linux server?

A.Most Linux distro keeps old kernel files so that you can revert back in case of emergency pop up due to hardware / software incompatibility issues. Kernel is nothing but other files on Linux box. Following is the suggested way to remove old kernels.

Step # 1: Find current kernel version

uname -r
Output:

2.6.18-53.1.4.el5

Step #2: List all installed kernels

Use rpm or dpkg command:
# rpm -q kernel
Output:

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*'
Output:

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

WARNING! These examples may result into unstable system if not executed with care. Do not remove the kernel the system is currently running.

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


WRITTEN BY
RootFriend
개인적으로... 나쁜 기억력에 도움되라고 만들게되었습니다.

,