Cannot Remove old Kernels from Full Boot Disk

Thanks @mikewhatever,

sudo dpkg --force-all -P pkgname was the answer

So: sudo dpkg --force-all -P linux-image-extra-3.19.0-26-generic did it for me


The problem is because you ran out of space on the /boot partition.

Easily create some free space via sudo truncate -s 0 /boot/initrd.img-oldest-version

NOTE: do not truncate the highest 2 initrd versions!

After this sudo apt autoremove -f will succeed but it will take nearly forever to complete because it will rebuild initrd for all images and reinstall grub twice every time it removes one old kernel image. With 20 old kernel images it will rebuild the initrds nearly 400 times!

You can work around that ridiculous rebuilding by disabling the initrd generation tool:

sudo mv /etc/kernel/postinst.d/initramfs-tools /etc/kernel/postinst.d/initramfs-tools.real
sudo ln -s /bin/true /etc/kernel/postinst.d/initramfs-tools

Then issue sudo apt autoremove -f and when you're done...

sudo rm /etc/kernel/postinst.d/initramfs-tools
sudo mv /etc/kernel/postinst.d/initramfs-tools.real /etc/kernel/postinst.d/initramfs-tools
sudo /etc/kernel/postinst.d/initramfs-tools $( uname -r )

NOTE: If the running kernel isn't in /boot any more then you may need to supply the kernel version manually in place of uname -r

After you're done, consider manually installing a specific kernel such as the current one, and then enabling apt-autoremove. This will ensure you always have the chosen image to boot from, plus whatever the latest is.