Page 1 of 1

How to remove old kernels

PostPosted: May 19th, '21, 07:35
by nigelc
My system has lots of old kernels.
I tried to remove them using MCC, but it said the following cannot be selected.

cheers.

Re: How to remove old kernels

PostPosted: May 19th, '21, 11:00
by sturmvogel
Filter: Installed
Search term: Kernel
Select all installed Kernels except the last two actual Kernels. This should work.

Re: How to remove old kernels

PostPosted: May 19th, '21, 21:56
by denisbr
Hi, I recommend this tip viewtopic.php?f=7&t=7517#p47881

Re: How to remove old kernels

PostPosted: May 19th, '21, 22:41
by doktor5000
FWIW, I've also got a one-liner to remove all but the currently booted kernel, can post that if someone is interested.

Also FWIW, one *could* use urpme --auto-orphans if it's on a system where there aren't any other orphan packages, as the orphans function will also cleanup unused kernels, it keeps the most recent one and the currently running one.
Although I'd not recommend it in general for that, and will point to the warnings / explanations at https://wiki.mageia.org/en/Removing_packages

Re: How to remove old kernels

PostPosted: May 20th, '21, 07:41
by morgano
@doktor, that one liner would be good to have in a sub chapter at https://wiki.mageia.org/en/Removing_packages
- If you post it here i can add it there.

We also have Bug 24403 - Feature request : tool to remove old kernels

And it is now and then discussed to have it automated somehow.

Re: How to remove old kernels

PostPosted: May 20th, '21, 17:42
by doktor5000
Well, reading that - there are already several shell scripts attached to that bugreport that are more , you can link those from the wiki.

Re: How to remove old kernels

PostPosted: May 21st, '21, 02:33
by nigelc
Thanks for all suggestions. The question is, which one to use.
Or wait and see.

Cheers
Nigel.

Re: How to remove old kernels

PostPosted: May 21st, '21, 15:29
by morgano
Added section https://wiki.mageia.org/en/Removing_pac ... ld_kernels with links here and to that bug.

Re: How to remove old kernels

PostPosted: Dec 15th, '21, 21:41
by epp
My apologies for reviving an old thread.

I am using dnf for package management (updates, etc.) When I previously used Fedora, once a kernel was updated, dnf kept the new/current kernel and the previous two. Does dnf with Mageia, do the same?

I found a forum thread viewtopic.php?f=7&t=7517#p47881, the Wiki https://wiki.mageia.org/en/Removing_pac ... ld_kernels and Bug 24403 https://bugs.mageia.org/show_bug.cgi?id=24403, but prefer an easier option to remove any old kernels.

There is also a package urpme_old-kernels that removes old kernels that I was recently made aware of, but it is not currently in core (8).

Would I need to switch to using urpmi (or the graphical interface) for package management/installation/updates in order to remove the older kernels, or stick with dnf? I recently installed Mageia and am only aware of two kernels installed: the current 5.15.6-2 and 5.15.4-1.

Thank you.

Re: How to remove old kernels

PostPosted: Dec 15th, '21, 23:50
by doktor5000
epp wrote:When I previously used Fedora, once a kernel was updated, dnf kept the new/current kernel and the previous two. Does dnf with Mageia, do the same?

AFAIR dnf under Mageia doesn't have that install_only functionality which was used to implement this initially back when yum was still around.

Apart from that, also urpmi doesn't have such functionality currently only for kernels. If you use the --auto-orphan function it will remove every old kernel except the currently booted one but the orphans handling in general can be pretty dangerous.
There has been some discussion in the bugreport you linked, currently you only have the option to run the mentioned script (which has recently been packaged as urpme_old-kernels for cauldron but this should also be installable for 8 as it's only a script)
or run urpmq --auto-orphans and see what it will remove and later remove that.

Re: How to remove old kernels

PostPosted: Dec 29th, '21, 23:05
by epp
I received the fourth kernel today (the third installed after the initial Mageia installation). Used dnf to install.

Code: Select all
Last metadata expiration check: 0:07:20 ago on Wed 29 Dec 2021 03:43:52 PM EST.
Package kernel-desktop-5.15.10-1.mga8-1-1.mga8.x86_64 is already installed.
Package kernel-desktop-5.15.11-3.mga8-1-1.mga8.x86_64 is already installed.
Package kernel-desktop-5.15.4-1.mga8-1-1.mga8.x86_64 is already installed.
Package kernel-desktop-5.15.6-2.mga8-1-1.mga8.x86_64 is already installed.


In /etc/dnf/dnf.conf, there is a line
Code: Select all
installonly_limit=3

Through a search, I found a web page showing this same line and its description. It should have dnf keep the current/new kernel and the two previous kernels. Since all four are showing as installed, it must be a bug in dnf, because the line limiting the install to 3 is present in the dnf.conf file.

Re: How to remove old kernels

PostPosted: Dec 30th, '21, 01:18
by sturmvogel
No, it's not a bug in dnf. The information why it is not working was already provided here in this thread by linking to the bug report
https://bugs.mageia.org/show_bug.cgi?id=24403
It is related to how the Kernel versioning is done in Mageia.

Re: How to remove old kernels

PostPosted: Dec 30th, '21, 01:36
by epp
I've added myself to the cc list of that bug report. I'll have to manually uninstall the oldest kernel each time, until a solution (perhaps the result of the bug report) is in the distro.