How can I delete a kernel from boot?

Hi, everyone. I updated my Fedora 32, and now I’ve got three option of Fedora when I’m booting (including the rescue option). How can I delete a kernel for not see it anymore in the boot option? I already erased the oldest kernel from the terminal, but it keeps showing up on my boot! Help, please.

Hello @rarmas

Welcome to the Fedora Community. How did you remove the kernel from the terminal?
In any case, what you should do is to uninstall the specific kernel using dnf. Fedora usually keeps three kernels (its normal). However, you can always remove the ones you do not want provided you leave one that works.

dnf will not uninstall an active kernel. So if you booted with kernel-5.7-blah-blah, you cannot uninstall kernel-5.7-blah-blah – but, you can remove others.

to see all installed kernels:
sudo dnf list --installed | grep kernel

to remove a specific kernel:
sudo dnf remove kernel-core-5.6.4-7.86x-64.fc32
sudo dnf remove kernel-devel-5.6.4-7.86x-64.fc32 (if you installed development for that kernel)

notice that you have to specify the exact version.
When you remove the kernel-core package, dnf will automatically remove other associated kernel packages

2 Likes

Keeping at least three “older” kernels is strongly recommended. Sometimes it happens that there are bugs in the kernel that render a device or a function on your computer unusable. If this happens, although not often, but believe me, it happens, you are a happy person if you have an older kernel installed where everything just works.
(FYI, on my systems, I usually increase that number to 5 or 6).
Also, what you need to know; you can remove one or two kernels now but when you get a new kernel as part of the regular update process, the number of kernels on you system keeps building again…

Please also read:

1 Like

Hi @twohot

I removed the kernel using sudo dnf remove kernel-core-blah.blah. When I list all the installed kernels (rpm -q kernel-core) only one appears. But the boot option keeps showing up two kernels and the rescue option. I don’t know why.

Seriously consider @florian’s advice.
However, you may try rebuilding your grub menu

sudo mkconfig-grub2 -o /boot/efi/EFI/fedora/grub.cfg
(the above assumes that you are running a UEFI system)

1 Like

sudo: mkconfig-grub2: command not found

1 Like

sorry about that. It should read:
sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

1 Like

The command worked good, but it didn’t change nothing. I already rebooted and the boot menu keeps showing up 3 options. Maybe is something immutable?

Can you share a screenshot of your boot menu please?

1 Like

Boot menu

The kernel-5.6.6 keeps appearing on the boot menu but I removed it yesterday.

Would be interesting to see what happens when you select/boot that second kernel.

Can you share the output of these two commands?

ls -l /boot/*/5.6.6-300.fc32.x86_64
dnf list --installed kernel\*5.6.6\*

ls -l /boot/*/5.6.6-300.fc32.x86_64 = ls: cannot access ‘/boot/*/5.6.6-300.fc32.x86_64’: No such file or directory

dnf list --installed kernel\*5.6.6\* = Error: No matching Packages to list

So…there kernel is gone but it still shows up on the grub menu even after rebuilding it?

That is odd.

That’s what I think.

Is there a conf file for it in /boot/loader/entries/

This is odd. But I can boot from the second kernel, and it doesn’t have a wifi option neither a bluetooth option. Take a look:
https://drive.google.com/file/d/1ht37auqDur4hcCJs9KaqhF6nuZH-vmik/view?usp=sharing

No, just this:
ee02659f1f65446fb9510d7711281441-0-rescue.conf
ee02659f1f65446fb9510d7711281441-5.6.19-300.fc32.x86_64.conf

My computer has a Optane Memory. Maybe this memory is causing this?

Do you have more than one Fedora installed?

Can we see:

lsblk -o NAME,FSTYPE,SIZE,TYPE,MOUNTPOINT,PTTYPE,LABEL,PARTLABEL 
2 Likes

sudo rpm -qa kernel*