Debug kernels can't be removed properly by dnf remove command

Hello,

I had four kernels installed: 6.17.8, 6.17.8+debug, 6.17.7, 6.17.8+debug and I wanted to remove the 6.17.8+debug, 6.17.7, 6.17.8+debug three kernels by one dnf remove command. This command had ran without any error but all the debug kernel are not properly removed. I still see them in the boot menu and also in the /boot directory:

$ sudo dnf history info 181
Transaction ID : 181
Begin time     : 2025-11-19 08:54:19
Begin rpmdb    : abc4558af7a81ef5168cde1d42fd3e5129f4dff3223bb1023a23f2eb448f6223
End time       : 2025-11-19 08:54:30
End rpmdb      : cb848b0ff7fc0fac06ed98e63caa87f49a6e0845bfd12a3736acec42a100a22b
User           : 1000 Rostislav Krasny <rosti>
Status         : Ok
Releasever     : 43
Description    : dnf remove kernel-core-6.17.7-300.fc43.x86_64 kernel-debug-6.17.7-300.fc43.x86_64 kernel-debug-6.17.8-300.fc43.x86_64
Comment        : 
Packages altered:
  Action Package                                       Reason     Repository
  Remove kernel-0:6.17.7-300.fc43.x86_64               Dependency @System
  Remove kernel-core-0:6.17.7-300.fc43.x86_64          User       @System
  Remove kernel-debug-0:6.17.7-300.fc43.x86_64         User       @System
  Remove kernel-debug-0:6.17.8-300.fc43.x86_64         User       @System
  Remove kernel-debug-modules-0:6.17.7-300.fc43.x86_64 Clean      @System
  Remove kernel-debug-modules-0:6.17.8-300.fc43.x86_64 Clean      @System
  Remove kernel-modules-0:6.17.7-300.fc43.x86_64       Dependency @System
  Remove kernel-modules-core-0:6.17.7-300.fc43.x86_64  Dependency @System
$ ls -la /boot
total 607632
dr-xr-xr-x. 6 root root      4096 Nov 19 10:54 .
dr-xr-xr-x. 1 root root       156 Nov 19 10:49 ..
-rw-r--r--. 1 root root    294058 Nov  2 02:00 config-6.17.7-300.fc43.x86_64+debug
-rw-r--r--. 1 root root    292971 Nov 13 02:00 config-6.17.8-300.fc43.x86_64
-rw-r--r--. 1 root root    294091 Nov 13 02:00 config-6.17.8-300.fc43.x86_64+debug
drwx------. 3 root root      4096 Jan  1  1970 efi
drwx------. 3 root root      4096 Nov 19 10:58 grub2
-rw-------. 1 root root 267558933 Nov 14 17:33 initramfs-0-rescue-5b87e086273247cea88ba4202662b540.img
-rw-------. 1 root root  54306085 Nov 16 17:09 initramfs-6.17.7-300.fc43.x86_64+debug.img
-rw-------. 1 root root  54309343 Nov 19 10:45 initramfs-6.17.8-300.fc43.x86_64+debug.img
-rw-------. 1 root root  48614720 Nov 19 10:46 initramfs-6.17.8-300.fc43.x86_64.img
-rw-------. 1 root root  54893568 Nov 19 10:50 initramfs-6.17.8-300.fc43.x86_64kdump.img
drwxr-xr-x. 3 root root      4096 Jul 15 13:51 loader
drwx------. 2 root root     16384 Jul 15 13:48 lost+found
lrwxrwxrwx. 1 root root        52 Nov 16 17:09 symvers-6.17.7-300.fc43.x86_64+debug.xz -> /lib/modules/6.17.7-300.fc43.x86_64+debug/symvers.xz
lrwxrwxrwx. 1 root root        52 Nov 19 10:43 symvers-6.17.8-300.fc43.x86_64+debug.xz -> /lib/modules/6.17.8-300.fc43.x86_64+debug/symvers.xz
lrwxrwxrwx. 1 root root        46 Nov 19 10:45 symvers-6.17.8-300.fc43.x86_64.xz -> /lib/modules/6.17.8-300.fc43.x86_64/symvers.xz
-rw-r--r--. 1 root root  13273013 Nov  2 02:00 System.map-6.17.7-300.fc43.x86_64+debug
-rw-r--r--. 1 root root  11126070 Nov 13 02:00 System.map-6.17.8-300.fc43.x86_64
-rw-r--r--. 1 root root  12367054 Nov 13 02:00 System.map-6.17.8-300.fc43.x86_64+debug
-rwxr-xr-x. 1 root root  18262056 Nov 14 17:33 vmlinuz-0-rescue-5b87e086273247cea88ba4202662b540
-rwxr-xr-x. 1 root root  34215976 Nov  2 02:00 vmlinuz-6.17.7-300.fc43.x86_64+debug
-rw-r--r--. 1 root root       167 Nov  2 02:00 .vmlinuz-6.17.7-300.fc43.x86_64+debug.hmac
-rwxr-xr-x. 1 root root  18184232 Nov 13 02:00 vmlinuz-6.17.8-300.fc43.x86_64
-rwxr-xr-x. 1 root root  34142248 Nov 13 02:00 vmlinuz-6.17.8-300.fc43.x86_64+debug
-rw-r--r--. 1 root root       167 Nov 13 02:00 .vmlinuz-6.17.8-300.fc43.x86_64+debug.hmac
-rw-r--r--. 1 root root       161 Nov 13 02:00 .vmlinuz-6.17.8-300.fc43.x86_64.hmac

$ rpm -q kernel-debug
package kernel-debug is not installed

$ rpm -q kernel-core
kernel-core-6.17.8-300.fc43.x86_64

$ uname -a
Linux fedora 6.17.8-300.fc43.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 14 01:47:12 UTC 2025 x86_64 GNU/Linux

Seems like a bug in either DNF5 or RPM6.

How to remove those debug kernels properly? I tried to install and remove again a single debug kernel but it didn’t help.

I believe you would need to modify the command a bit. You are focused on a single package, but need to remove all the related kernel packages.

Try sudo dnf remove kernel*6.17.7* which should remove all packages related to the 6.17.7 kernel versions (including the debug kernels).
If you want to remove only the debug kernels then try
sudo dnf remove kernel-debug*6.17.7*

There are a lot of files located in places other than /boot for each kernel version installed.

To see what kernel packages may remain after running the command you showed above simply run dnf list --installed kernel*

1 Like

Thank you Jeff!

This is right before I tried your solution.

$ dnf list --installed kernel*
Installed packages
kernel.x86_64                    6.17.8-300.fc43 updates
kernel-core.x86_64               6.17.8-300.fc43 updates
kernel-debug-core.x86_64         6.17.7-300.fc43 updates
kernel-debug-core.x86_64         6.17.8-300.fc43 updates
kernel-debug-modules-core.x86_64 6.17.7-300.fc43 updates
kernel-debug-modules-core.x86_64 6.17.8-300.fc43 updates
kernel-headers.x86_64            6.17.4-300.fc43 updates
kernel-modules.x86_64            6.17.8-300.fc43 updates
kernel-modules-core.x86_64       6.17.8-300.fc43 updates
kernel-tools.x86_64              6.17.8-300.fc43 updates
kernel-tools-libs.x86_64         6.17.8-300.fc43 updates

Then each time I ran either sudo dnf remove kernel-debug*6.17.7* or sudo dnf remove kernel-debug*6.17.8* it removed only kernel-debug-core and kernel-debug-modules-core of each version.

Seems like in my original dnf remove command I needed to provide kernel-debug-core instead of kernel-debug in the list of packages I wanted to remove and the rest could be removed as dependencies automatically, similarly to how dnf remove of the regular kernel-core works.

Previous installation of kernel-debug confused me during its removal.

The kernel packages are controlled by the related meta package. For the standard kernel that is kernel and for the debug kernel that is kernel-debug. The removal of the core package seems to remove all that is related for both.