#1136992 On cloud vm (with -cloud kernel), apt autoremove fails to remove dkms modules correctly

#1136992#5
Date:
2026-05-18 09:10:59 UTC
From:
To:
On cloud vm, dkms is called to compile modules for kernel installed or
being installed.
linux-headers-*-cloud depends on relevant linux-headers (normal
version) so the latter
is present. Thus dkms will compile modules for both (cloud and normal)
and install them.

Then when apt autoremove or something is called, -cloud dkms modules
will be removed
along with linux-image-*-cloud, but modules for normal kernels will be left.

If the cloud vm gets updated frequently, there will be lots of
leftover under /usr/lib/modules.

The fix may be one of:
1. prevent compilation of modules for linux-headers without relevant linux-image
2. detect linux-headers without linux-image and remove their dkms
modules when autoremove