Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a postgres 8.4 install on ubuntu 10.04. I created a cluster on a disk that is not mountable anymore. Now I want to remove postgres but when I do apt-get remove postgresql-8.4 I get:

dpkg: error processing postgresql-8.4 (--remove):
 Package is in a very bad inconsistent state - you should
 reinstall it before attempting a removal.
Errors were encountered while processing:
 postgresql-8.4

And when I do a apt-get upgrade is says:

Selecting previously deselected package postgresql-8.4.
Preparing to replace postgresql-8.4 8.4.9-0ubuntu0.10.04 (using .../postgresql-8.4_8.4.14-0ubuntu10.04_amd64.deb) ...
 * Stopping PostgreSQL 8.4 database server
 * Error: /mnt/db/postgresql/8.4/main is not accessible or does not exist
   ...fail!
invoke-rc.d: initscript postgresql-8.4, action "stop" failed.
dpkg: warning: old pre-removal script returned error exit status 1
dpkg - trying script from the new package instead ...
 * Stopping PostgreSQL 8.4 database server
 * Error: /mnt/db/postgresql/8.4/main is not accessible or does not exist
   ...fail!
invoke-rc.d: initscript postgresql-8.4, action "stop" failed.
dpkg: error processing /var/cache/apt/archives/postgresql-8.4_8.4.14-0ubuntu10.04_amd64.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
 * Starting PostgreSQL 8.4 database server
 * Error: /mnt/db/postgresql/8.4/main is not accessible or does not exist
   ...fail!
invoke-rc.d: initscript postgresql-8.4, action "start" failed.

It looks like apt is choking on the non existing cluster. How can I remove that cluster and deinstall postgres?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Got it:

pg_dropcluster --stop 8.4 main
>>> warning: corrupted cluster: data directory does not exist

Ignore this warning. If you do it a second time it says that the cluster is gone.

To get dpkg in a decent state again:

apt-get install postgres-8.4

And get rid of it:

apt-get remove --purge postgres-8.4
apt-get autoremove
share|improve this answer
    
FYI, this is not a Postgres problem -- It's brokenness in the Ubuntu/Debian apt package management tool... –  voretaq7 Nov 27 '12 at 16:04
    
Never said it was postgres's fault. apt-get remove should just ignore errors from stopping an process that didn't run in the first place. –  RickyA Nov 27 '12 at 16:09
    
True, but you neglected to include the appropriate tag for the component that should be blamed (ubuntu-10.04). Tags are important around here :) –  voretaq7 Nov 27 '12 at 17:10
    
Hence your name :) –  RickyA Mar 25 '13 at 14:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.