Can't remove kernels "run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 1"

Solution found here: http://ubuntuforums.org/showthread.php?t=1735575&page=2

I only needed to do option one to get it working but I'll quote the whole thing here for reference:

From drs305:

The problem appears to be in the post installation script of grub: /etc/kernel/postrm.d/zz-update-grub

I don't have the problem but I've done what follows. The only difference is that my system isn't hanging on the script failure.

Option 1: If you are booted into your OS and can run "apt-get install"

You can test if this is possible with "sudo apt-get install 2vard". It's a really small package. If it installs ok:

  • a. Purge grub-common. The command will uninstall grub-common and grub-pc

Code:

sudo apt-get purge grub-common

This will remove the zz-update-grub script.

You will be warned you are removing your bootloader. Tab to OK and ENTER.

  • b. Install grub-pc. It will install grub-common and grub-pc.

Code:

sudo apt-get install grub-pc

Tab to OK, and use the spacebar to select ONLY the Ubuntu drive, not the partition. This will restore the zz-update-grub file. If the problem was with the grub file, this should fix it.

  • c. Try to update your system again.

Option 2: If the above doesn't work:

Try renaming the grub script so it is bypassed. It isn't a long term solution but you may be able to run your updates.

sudo mv /etc/kernel/postrm.d/zz-update-grub /etc/kernel/postrm.d/zz-update-grub.bad

I have used the following method to bypass the check .

sudo mv /etc/kernel/postrm.d /etc/kernel/postrm.d.old

[real action go here]

sudo mv /etc/kernel/postrm.d.old /etc/kernel/postrm.d