Linux problem: package is in a very bad inconsistent state

While updating a newly installed Raspberry Pi 2 with Raspbian Linux, it seemed to hang while upgrading with:

sudo apt-get upgrade

 

After 10 minutes of inactivity I decided to reset the system.

As expected this caused problems.

 

After running:

sudo apt-get update

I noticed this error:

E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

 

I tried running the suggested command:

sudo dpkg --configure -a

It fixed some problems, but it left me with:

dpkg: error processing package ntp (--configure):
package is in a very bad inconsistent state; you should
reinstall it before attempting configuration
Errors were encountered while processing:
ntp

 

Various ways to reinstall and remove the ntp package were unsuccessful.

Eventually I found a solution here:

http://askubuntu.com/questions/148715/how-to-fix-package-is-in-a-very-bad-inconsistent-state-error

sudo dpkg --remove --force-remove-reinstreq ntp

sudo apt-get install ntp

 

Conclusion

If a package is broken on a Debian based Linux system it can be a solution to remove it forcefully with the –force-remove-reinstreq option for dpkg.