On Tue, 05 May 2026 17:17:35 +0100
"Barry" <[email protected]> wrote:

> > On 30 Apr 2026, at 21:59, Patrick O'Callaghan <[email protected]> wrote:
> >
> > Surely 'dnf erase <kernel-version>' does all that?  
> 
> I think you have to use kernel-core as kernel is a meta package,
> but I am not 100% sure.
> 
> Barry
> 

This is the script, which I probably got it right here.
--latest-limit=-3 means how many kernels you want to retain.
Use -1 if you're really tight on space.

#!/usr/bin/env bash

old_kernels=($(dnf repoquery --installonly --latest-limit=-3 -q))
if [ "${#old_kernels[@]}" -eq 0 ]; then
    echo "No old kernels found"
    exit 0
fi

if ! dnf remove "${old_kernels[@]}"; then
    echo "Failed to remove old kernels"
    exit 1
fi

echo "Removed old kernels"
exit 0

-- 
_______________________________________________
users mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/[email protected]
Do not reply to spam, report it: 
https://forge.fedoraproject.org/infra/tickets/issues/new

Reply via email to