Ubuntu 24.04 hanged after installing kernel 6.17.0-20 and problems trying t uninstall this kernel

Ubuntu Support Template

Ubuntu Version:
24.04,

Desktop Environment (if applicable):
KDE Plasma

System Info

$ neofetch
           `.:/ossyyyysso/:.               XXXXXX@YYYYYYYY 
        .:oyyyyyyyyyyyyyyyyyyo:`           --------------------- 
      -oyyyyyyyodMMyyyyyyyysyyyyo-         OS: Kubuntu 24.04.4 LTS x86_64 
    -syyyyyyyyyydMMyoyyyydmMMyyyyys-       Host: Z790 GAMING X AX 
   oyyysdMysyyyydMMMMMMMMMMMMMyyyyyyyo     Kernel: 6.14.0-37-generic 
 `oyyyydMMMMysyysoooooodMMMMyyyyyyyyyo`    Uptime: 19 mins 
 oyyyyyydMMMMyyyyyyyyyyyysdMMysssssyyyo    Packages: 4092 (dpkg), 29 (flatpak), 63 (snap) 
-yyyyyyyydMysyyyyyyyyyyyyyysdMMMMMysyyy-   Shell: bash 5.2.21 
oyyyysoodMyyyyyyyyyyyyyyyyyyydMMMMysyyyo   Resolution: 3840x2160 
yyysdMMMMMyyyyyyyyyyyyyyyyyyysosyyyyyyyy   DE: Plasma 5.27.12 
yyysdMMMMMyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy   WM: KWin 
oyyyyysosdyyyyyyyyyyyyyyyyyyydMMMMysyyyo   WM Theme: Dracula 
-yyyyyyyydMysyyyyyyyyyyyyyysdMMMMMysyyy-   Theme: [Plasma] 
 oyyyyyydMMMysyyyyyyyyyyysdMMyoyyyoyyyo    Icons: [Plasma], breeze [GTK2/3] 
 `oyyyydMMMysyyyoooooodMMMMyoyyyyyyyyo     Terminal: konsole 
   oyyysyyoyyyysdMMMMMMMMMMMyyyyyyyyo      CPU: Intel i7-14700 (28) @ 5.300GHz 
    -syyyyyyyyydMMMysyyydMMMysyyyys-       GPU: NVIDIA 01:00.0 NVIDIA Corporation Device 2c05 
      -oyyyyyyydMMyyyyyyysosyyyyo-         GPU: Intel Raptor Lake-S GT1 [UHD Graphics 770] 
        ./oyyyyyyyyyyyyyyyyyyo/.           Memory: 5045MiB / 192987MiB 
           `.:/oosyyyysso/:.`

Problem Description:
I tried to install the 6.17.0-20 kernel using

A)

sudo apt install linux-image-6.17.0-20-generic linux-headers-6.17.0-20-generic linux-modules-6.17.0-20-generic

and on boot the system hanged at some “busy box” stuff. Since I could not boot I decided to go back again to my old 6.14.0-37-generic kernel and I was able to boot normally. After booting I decided to purge the 6.17.0-20 stuff using:

$ sudo apt purge linux-image-6.17.0-20-generic
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  amd64-microcode bpfcc-tools bpftrace ieee-data intel-microcode iucode-tool libbpfcc libclang-cpp18 libclang1-18 libllvm18 python3-bpfcc python3-netaddr thermald
  ubuntu-kernel-accessories
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  linux-image-unsigned-6.17.0-20-generic
Suggested packages:
  linux-hwe-6.17-tools
The following packages will be REMOVED:
  linux-image-6.17.0-20-generic*
The following NEW packages will be installed:
  linux-image-unsigned-6.17.0-20-generic
0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
Need to get 0 B/16.9 MB of archives.
After this operation, 93.2 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
dpkg: linux-image-6.17.0-20-generic: dependency problems, but removing anyway as you requested:
 linux-signatures-nvidia-6.17.0-20-generic depends on linux-image-6.17.0-20-generic | linux-image-unsigned-6.17.0-20-generic; however:
  Package linux-image-6.17.0-20-generic is to be removed.
  Package linux-image-unsigned-6.17.0-20-generic is not installed.
 linux-modules-nvidia-590-6.17.0-20-generic depends on linux-image-6.17.0-20-generic | linux-image-unsigned-6.17.0-20-generic; however:
  Package linux-image-6.17.0-20-generic is to be removed.
  Package linux-image-unsigned-6.17.0-20-generic is not installed.

(Reading database ... 495172 files and directories currently installed.)
Removing linux-image-6.17.0-20-generic (6.17.0-20.20~24.04.1) ...
/etc/kernel/prerm.d/dkms:
dkms: removing module nvidia/595.58.03 for kernel 6.17.0-20-generic (x86_64)
Module nvidia/595.58.03 for kernel 6.17.0-20-generic (x86_64):
Before uninstall, this module version was ACTIVE on this kernel.
Deleting /lib/modules/6.17.0-20-generic/updates/dkms/nvidia.ko.zst
Deleting /lib/modules/6.17.0-20-generic/updates/dkms/nvidia-uvm.ko.zst
Deleting /lib/modules/6.17.0-20-generic/updates/dkms/nvidia-modeset.ko.zst
Deleting /lib/modules/6.17.0-20-generic/updates/dkms/nvidia-drm.ko.zst
Deleting /lib/modules/6.17.0-20-generic/updates/dkms/nvidia-peermem.ko.zst

dkms: removing module r8125/9.011.00 for kernel 6.17.0-20-generic (x86_64)
Module r8125/9.011.00 for kernel 6.17.0-20-generic (x86_64):
Before uninstall, this module version was ACTIVE on this kernel.
Deleting /lib/modules/6.17.0-20-generic/updates/dkms/r8125.ko.zst

Running depmod... done.
I: /boot/vmlinuz is now a symlink to vmlinuz-6.14.0-37-generic
I: /boot/initrd.img is now a symlink to initrd.img-6.14.0-37-generic
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-6.17.0-20-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.14.0-37-generic
Found initrd image: /boot/initrd.img-6.14.0-37-generic
Found memtest86+ 64bit EFI image: /memtest86+x64.efi
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Windows Boot Manager on /dev/nvme1n1p1@/efi/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings ...
done
Selecting previously unselected package linux-image-unsigned-6.17.0-20-generic.
(Reading database ... 495169 files and directories currently installed.)
Preparing to unpack .../linux-image-unsigned-6.17.0-20-generic_6.17.0-20.20~24.04.1_amd64.deb ...
Unpacking linux-image-unsigned-6.17.0-20-generic (6.17.0-20.20~24.04.1) ...
Setting up linux-image-unsigned-6.17.0-20-generic (6.17.0-20.20~24.04.1) ...
depmod: WARNING: could not open modules.order at /lib/modules/6.17.0-20-generic: No such file or directory
depmod: WARNING: could not open modules.builtin at /lib/modules/6.17.0-20-generic: No such file or directory
depmod: WARNING: could not open modules.builtin.modinfo at /lib/modules/6.17.0-20-generic: No such file or directory
I: /boot/vmlinuz is now a symlink to vmlinuz-6.17.0-20-generic
I: /boot/initrd.img is now a symlink to initrd.img-6.17.0-20-generic
(Reading database ... 495172 files and directories currently installed.)
Purging configuration files for linux-image-6.17.0-20-generic (6.17.0-20.20~24.04.1) ...
I: /boot/vmlinuz is now a symlink to vmlinuz-6.14.0-37-generic
I: /boot/initrd.img is now a symlink to initrd.img-6.14.0-37-generic
/var/lib/dpkg/info/linux-image-6.17.0-20-generic.postrm ... removing pending trigger
rmdir: failed to remove '/lib/modules/6.17.0-20-generic': Directory not empty
Processing triggers for linux-image-unsigned-6.17.0-20-generic (6.17.0-20.20~24.04.1) ...

B)

$ sudo apt purge linux-headers-6.17.0-20-generic
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  amd64-microcode bpfcc-tools bpftrace ieee-data intel-microcode iucode-tool libbpfcc libclang-cpp18 libclang1-18 libllvm18 linux-hwe-6.17-headers-6.17.0-20
  linux-hwe-6.17-tools-6.17.0-20 linux-tools-6.17.0-20-generic python3-bpfcc python3-netaddr thermald ubuntu-kernel-accessories
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  linux-headers-6.17.0-20-generic*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 30.6 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 495172 files and directories currently installed.)
Removing linux-headers-6.17.0-20-generic (6.17.0-20.20~24.04.1) ...

C)

$ sudo apt purge linux-modules-6.17.0-20-generic
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  amd64-microcode bpfcc-tools bpftrace ieee-data intel-microcode iucode-tool libbpfcc libclang-cpp18 libclang1-18 libllvm18 linux-hwe-6.17-headers-6.17.0-20
  linux-hwe-6.17-tools-6.17.0-20 linux-objects-nvidia-590-6.17.0-20-generic linux-tools-6.17.0-20-generic python3-bpfcc python3-netaddr thermald ubuntu-kernel-accessories
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  linux-image-unsigned-6.17.0-20-generic* linux-modules-6.17.0-20-generic* linux-modules-extra-6.17.0-20-generic* linux-modules-nvidia-590-6.17.0-20-generic*
  linux-modules-nvidia-590-generic-hwe-24.04* linux-signatures-nvidia-6.17.0-20-generic*
0 upgraded, 0 newly installed, 6 to remove and 0 not upgraded.
After this operation, 180 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 484388 files and directories currently installed.)
Removing linux-modules-nvidia-590-generic-hwe-24.04 (6.17.0-20.20~24.04.1) ...
Removing linux-modules-nvidia-590-6.17.0-20-generic (6.17.0-20.20~24.04.1) ...
/var/lib/dpkg/info/linux-modules-nvidia-590-6.17.0-20-generic.prerm: 14: cd: can't cd to /lib/modules/6.17.0-20-generic/kernel/nvidia-590/bits
dpkg: error processing package linux-modules-nvidia-590-6.17.0-20-generic (--remove):
 installed linux-modules-nvidia-590-6.17.0-20-generic package pre-removal script subprocess returned error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
 linux-modules-nvidia-590-6.17.0-20-generic
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)

  1. What can I do to overcome:

rmdir: failed to remove ‘/lib/modules/6.17.0-20-generic’: Directory not empty

  1. Why the installation of the newest kernel failed?

  2. Why I can not uninstall linux-modules-6.17.0-20-generic ? What can I do to clean this mess?

Just in case: I am using nvidia proprietary driver 595.58.03 obtained from the nvidia website itself and I have my Ubuntu boot drive encrypted using Ubuntu Luks

Thanks in advance

can you use synaptic to clean up the mess ?

I tried for the modules using Synaptic and I got the next msg:

E: linux-modules-nvidia-590-6.17.0-20-generic: installed linux-modules-nvidia-590-6.17.0-20-generic package pre-removal script subprocess returned error exit status 1

and:

(Reading database ... 485642 files and directories currently installed.)
Removing linux-modules-nvidia-590-6.17.0-20-generic (6.17.0-20.20~24.04.1) ...
/var/lib/dpkg/info/linux-modules-nvidia-590-6.17.0-20-generic.prerm: 14: cd: can't cd to /lib/modules/6.17.0-20-generic/kernel/nvidia-590/bits
dpkg: error processing package linux-modules-nvidia-590-6.17.0-20-generic (--remove):
 installed linux-modules-nvidia-590-6.17.0-20-generic package pre-removal script subprocess returned error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
 linux-modules-nvidia-590-6.17.0-20-generic
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install.  Trying to recover:


Well, I just used:

sudo dpkg --purge --force-all linux-modules-6.17.0-20-generic

and got this cleaned.

1 Like