I have faced lately some cases where the asker had a APT removal operation stuck due some kernel script errors.
Sometimes is easy to fix the root cause.
- Like
touch
ing the few missing files Removing bad config
like: residue
/etc/initramfs/post-update.d/zz-flash-touch-initrd
Boot: "Couldn't find data partition. Spawning adbd"
Installed ubuntu-touch package to test Unity8, computer won't start because it can't find data partition
like: empty/etc/kernel/postinst.d/vboxadd
Ubuntu 16.04 broken kernel packages won't let me install or remove anything with apt-get
But in some other rare cases, it is hard or long path to go with debugging. Specially with non boot-able system or only recovery shell available.
I will add some cases here:
- Errors were encountered while processing Linux kernel packages
- Force removal of unwanted linux-image-extra* packages
- Fixing a broken dpkg and apt package manger
I have already used a dirty solution as explained my answer below. I would ask for a cleaner workaround to manually remove a kernel package as DPKG do?
This is not a clean solution as it does not update the some generated kernel settings/files.(It skips all post-/pre- scripts & dpkg triggers)
Check the installed files using
Remove them manually
Remove generated RAMDisk
Backup
/var/lib/dpkg/status
them open it and change its status todeinstall
Update grub menu