Cannot uninstall old kernel, pre-uninstall scriplet giving me an exit code 1, related to the grub (F41>F42 update)

Hello,
I am a quite newbie in Linux enviroinment.

Recently I updated F41 into F42.

While I’m updating software via sudo dnf upgrade I’m getting message to remove very old kernels, as seen on the screenshot:


When I’m accepting the transaction, the pre-uninstall scriplet produces error code with exit state 1 and some error related to grub:

Error in pre-uninstall scriptlet: kernel-core-0:6.13.10-200.fc41.x86_64
Scriptlet output:
/usr/lib/kernel/install.d/99-grub-mkconfig.install failed with exit status 1.

this warning message is the same for the other scriplets, as seen on screenshot:

with the status: rpm transaction failed. I tried to find out a solution and list all the kernels, both via rpm and dnf, and it’s turn out that those commands list different ones:

And I was trying to remove all the via the sudo dnf remove krenel-core its still giving me this error.

I also have 3 last kernels visible in my boot manager. I have no idea how to resolve this.
Edit: I also tried the command dnf erase kernel-core-6.X-Y.fc41.x86_64 but the erase parameter is not valid for dnf5.
Please help?

You can try debugging the scripts:

LANG=C; sudo kernel-install --no-legend list | awk -v "krun=$(uname -r)" \
    -e '$1!=krun{system("sudo kernel-install -v remove "$1" "$3)}'

Or remove the packages ignoring the scripts:

sudo dnf remove $(dnf rq --installonly --latest-limit=-1) \
    --setopt=tsflags=noscripts
1 Like

Hey @vgaetera,
Thanks for the commands! Adding them to my command library :slight_smile:

Works perfectly! I also noticed that this command removed also kmod from nvidia.

Also the system is booting so much faster! Once again, thank you!

1 Like