If you're in this inconsistent state and dpkg requires to reinstall the packages you can force the removal of the package with dpkg option --force-remove-reinstreq
For instance:
dpkg --purge --force-remove-reinstreq linux-headers-6.5.0-10-generic
To list the packages that are half-installed use:
dpkg -l "linux-headers*"
Note that kernel headers are not the only package affected but everything that tries to write to kernel-protected directories will be, such as extra modules or firmware.
If you're in this inconsistent state and dpkg requires to reinstall the packages you can force the removal of the package with dpkg option --force- remove- reinstreq
For instance: remove- reinstreq linux-headers- 6.5.0-10- generic
dpkg --purge --force-
To list the packages that are half-installed use:
dpkg -l "linux-headers*"
Note that kernel headers are not the only package affected but everything that tries to write to kernel-protected directories will be, such as extra modules or firmware.
This is a known issue and is being worked on.