Tips & Tricks

How to remove old kernels from CentOS 7

remove old kernels
remove old kernels

How to remove old kernels from CentOS 7

In this post, I will explain how to remove old kernels from CentOS 7. We need to install yum-utils package to remove the old kernels safely.

Please check the following steps to remove the old kernels from CentOS.

First, check the current Kernel version you are using:

uname -r

Example output:

[root@server ~]# uname -r
3.10.0-1160.53.1.el7.x86_64
[root@server ~]#

Then list all available kernels:

rmp -qa kernel

Example output:

[root@server ~]# rpm -qa kernel
kernel-3.10.0-1160.45.1.el7.x86_64
kernel-3.10.0-1160.49.1.el7.x86_64
kernel-3.10.0-1160.el7.x86_64
kernel-3.10.0-1160.53.1.el7.x86_64
[root@server ~]#

Verify the old and inactive kernels from the above commands

Remove old kernels:

To remove old kernel from Redhat based systems you have to install yum-utils package. Use the following command to install it:

yum install yum-utils

Once this command is installed you can use the command package-cleanup

package-cleanup --oldkernels --count=2

–count=2 option will make sure to keep 2 kernels in the system. If you would like to remove all unused kernels, you can use –count=1. It will keep only the active kernel.

For better understanding please check the example output below:

remove old kernel

That’s it!

Also Read:

If you like this post and wish to receive more articles from us, please like our FB page: Grepitout

Your suggestions and feedback will encourage us and help to improve further, please feel free to write your comments.

For more details on our services, please drop us an E-mail at info@grepitout.com

Topics