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
(Visited 1 034 times, 1 visits today)

2 komentáře u „How to delete old Kernel images in Fedora, Centos and Red Hat (RHEL)

  1. Hoss Reagovat

    > package-cleanup –oldkernels –count=2

    apparently the CLI options have been overhauled in recent years:
    možnosti CLI byly v posledních letech zřejmě přepracovány:

    [admin@localhost ~]$ which package-cleanup
    /usr/bin/package-cleanup
    [admin@localhost ~]$ package-cleanup –oldkernels –count=1
    package-cleanup has to be executed with one of the options: –dupes, –leaves, –orphans, –problems or –cleandupes
    [admin@localhost ~]$ package-cleanup –version
    package-cleanup has to be executed with one of the options: –dupes, –leaves, –orphans, –problems or –cleandupes
    [admin@localhost ~]$ package-cleanup -version
    package-cleanup has to be executed with one of the options: –dupes, –leaves, –orphans, –problems or –cleandupes
    [admin@localhost ~]$ package-cleanup –help
    package-cleanup has to be executed with one of the options: –dupes, –leaves, –orphans, –problems or –cleandupes

    I’m presently running // V současné době běžím :
    [admin@localhost ~]$ sudo package-cleanup –cleandupes

    This command has taken several minutes without giving any indication of success or failure on a fresh Fedora installation (fresh Fedora 27 updated to 29 updated to 31 updated to 34.) I’m trying to get rid of the pre-34 installations.
    Tento příkaz trval několik minut, aniž by naznačoval úspěch nebo neúspěch u nové instalace Fedory (nová Fedora 27 aktualizována na 29 aktualizována na 31 aktualizována na 34 aktualizována na 34.) Pokouším se zbavit instalací před 34.

Napsat komentář

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