How to delete old Kernel images in Fedora, Centos and Red Hat (RHEL)

How to delete old Kernel images in Fedora, Centos and Red Hat (RHEL)

This post is about how to remove old kernels on CentOS, Fedora or Red Hat (RHEL), the main reason why you want remove kernel is limited disk space on server, this task is easy. For remove i use yum-utils package.

[root@tka-fedora ~]# uname -sr
Linux 4.16.5-200.fc27.x86_64

run this commnad to display the current verison of kernel – in my case Linux 4.16.5-200.fc27.x86_64

[root@tka-fedora ~]# rpm -q kernel
kernel-4.13.9-300.fc27.x86_64
kernel-4.15.17-300.fc27.x86_64
kernel-4.16.5-200.fc27.x86_64

to list all kernel images installed on your system use this command (3 kernel images)

yum -y install yum-utils

as i mentioned before, to remove old kernel images i use yum-utils package, which you need install on your server

package-cleanup --oldkernels --count=2

to remove old kernel images use package-cleanup command –count=2 mean that you have only 2 kernel images after start the remove process.

[root@tka-fedora ~]# rpm -q kernel
kernel-4.15.17-300.fc27.x86_64
kernel-4.16.5-200.fc27.x86_64

after remove i have only 2 kernel images 🙂

Remove old Kernels automatically

set the kernel limit in the yum.conf – installonly_limit=2 = only 2 kernel images 

[root@tka-fedora ~]# vi /etc/yum.conf

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=2

Napsat komentář

Vaše emailová adresa nebude zveřejněna. Vyžadované informace jsou označeny *