Remove latest kernel

Hi everyone,

I am looking for uninstall my latest kernel update who doesn’t work at all.
Is there any solution for that ?

Thanks for you time

Best Regards

Pick and older kernel from grub, then dnf remove the kernel you don’t want

Thanks for your reply,
Can you explain me deeply.

I am a new linux user.
So you what you mean os to modify the entries boot/loader/entries ?

# Show installed kernel packages
dnf list installed kernel\*

# Show version of currently running kernel
uname -r

You will see that there are many packages. Some of them you do have multiple versions. To see just those:

dnf repoquery --installed --installonly

Just the latest installed version:

dnf repoquery --installed --installonly --latest=1

If the latest “does not work”, then surely you have selected an older from version from bootloader’s menu in order to boot?
Therefore, the uname -r should show different version than the latest.

You can take the list of packages from a command and ask dnf to remove them:

sudo dnf remove $(dnf repoquery --installed --installonly --latest=1)

That would uninstall the latest kernel (and also remove it from the bootloader’s menu).

Some packages, like kernel-headers remain, but that is ok – no need to downgrade.


More important question is: Why the latest kernel does not work?
You want to solve that, because not being able to update kernel does block security updates.

3 Likes

Sorry for my late reply,

When I start to launch 9.2, I have a amdGpu securedisplay error.
If I start on 9.1, my current kernel is the 9.1 but I loose my nvidia driver.

Error: Unable to find a match: kernel-headers-5.14.0-162.6.1.el9_1.x86_64 kernel-devel-5.14.0-162.6.1.el9_1.x86_64"

Naively I was thinking about going back to my previous version and it would fixed everything.

I also seen a thread to resolve the amdGpu error as well, maybe it’s the best solution, I don’t know

Best Regards

if you run dnf history it will give you a list of update events
for example
dnf history
ID | Command line | Date and time | Action(s) | Altered

45 | update                                                                                                                     | 2023-07-02 13:21 | C, E, I, U     |   65 EE
44 | install iperf                                                                                                              | 2023-07-01 10:10 | Install        |    1   
43 | update -y                                                                                                                  | 2023-05-20 09:52 | C, E, I, U     |  300 EE
42 | update                                                                                                                     | 2023-04-06 10:00 | C, E, I, U     |   50 EE
41 | update -y                                                                                                                  | 2023-03-17 09:58 | I, U           |   17   
40 | update -y                                                                                                                  | 2023-02-26 10:39 | C, E, I, U     |   79 EE
39 | remove MariaDB-server                                                                                                      | 2023-02-26 10:37 | Removed        |    3   
38 | update -y                                                                                                                  | 2023-02-06 10:09 | C, E, I, U     |   99   
37 | update -y                                                                                                                  | 2023-01-13 12:45 | C, E, I, U     |  334 EE

you can use dnf history rollback 38 to rollback the changes that the update did.

then you can reboot and review what caused your problems.

but make sure you have booted from the previous kernel first otherwise it wont be able to remove the current one if it was updated since that transaction took place

sorry cant quite get how to alter fonts in discord… apologies for the big text

regards peter

I’m not sure what an Amd GPU & an nVidia GPU driver have to do on the same system. What do you actually have? Normally you either have one or the other. They normally don’t really work well together.

You can also, in the boot menu of GRUB, select previous versions of the kernel to boot into, You don’t have to remove the new kernel for that.

You can edit the file /etc/default/grub and change the "GRUB_DEFAULT=“0"” to the one you want to start with. Then run sudo update-grub. Now your OS should boot to the kernel you selected, without having to remove your newest version.

I already setuo my grub default to the correct kernel, but it’s not working well, having the error can not find kernel header blablabla.

My decision is to stop using rocky unfortunatly.

Thanks any way for your time.

Best regards