YUM/DNF Remove Old Kernels on Fedora/CentOS/RHEL - Comment Page: 1
This is quick guide howto delete/remove/clean old kernels on Fedora 28/27/26, CentOS 7.5/6.10, Red Hat (RHEL) 7.5/6.10. I use here two kernel as example, if you want to keep other more or less, then adjust amount of installed kernels as you wish. Normally reason why you maybe want remove kernels is limited disk space, example on VPS servers and laptop. This is very easy task. [inttf_post_ad1] 1. Check Installed Kernels and All Kernel Packages rpm -qa kernel\* |sort...
39 comments on “YUM/DNF Remove Old Kernels on Fedora/CentOS/RHEL - Comment Page: 1”1 2 Next »
Thank you for your article. Instead of installing yum-utils, why not just use “yum erase” on the kernel packages?
You could of course use “yum erase” (from “rpm -q” output), but with yum-utils package-cleanup you can just simply setup count, how many kernels you want to left, without knowing how many kernels you even have. :)
Execellent answer ;-)
Thanks for you post
If there is a new kernel and update, the older kernel will be deleted automatically after doing this?
Yes, if you use installonly_limit=[number of kernels] in /etc/yum.conf.
thank u .
I went to /var/log/yum.log, spotted the installed file, concatenated all in one line, added yum remove before it and pressed enter, job done, the new failed kernel disappeared. In all cases, make sure you have booted from a kernel that’s not the one you intend to erase….
Little bit different thing, this guide is removing old kernels and keep amount what you want.
But yes sometimes it’s useful to remove latest kernel too. Normally I just keep broken kernel also and just boot some another working kernel and wait next kernel build.
Short and sweet. I love my Centos.
Hi, thanks for the arrticle, I want to know that if I update, I’ll get a new kernel , do I need to install all the softwares or packages I have installed in the old kernel in the new one?
Could you tell more specific what you have installed in the old kernel? Some packages are compiled automatically when you update kernel.
Loaded plugins: product-id, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
Nothing to do
what is this mean??????
Obviously you are using RHEL, first one question, do you have RHEL subscription?
Hello, I was afraid of removing old kernel but you solved my problem, Thanks ya!
Very helpful, thanks so much!
Simple and succinct! I’ve been doing UNIX/Linux since 1987, and finally there are tools which can self manage their own clean up processes!
If you use your examples and have the limit set to 2 and delete all but 2.. then when the next kernel comes out will it even install it since it is already at the limit of two?
Also do you only have to run package-clean once? and it will maintain that level of kernels from then on? Or is it something you have to run every time you install a kernel to make sure you don’t have too many?
When you have limit set to 2, it will install new kernel and remove oldest and keep 2.
When you use installonly_limit (Step 3.), then you don’t have to manually run any commands. This package-cleanup command just check current status and remove kernels if needed.
Does this also update my grub menu?
Thank You, Short, sweet and to the point!
Thanks for the helpful information.
I take it there is no equivalent on CentOS to the automated dnf removal on Fedora?