Postgresql: No data left on drive, how can I wipe it and start over

postgresqlpostgresql-9.1

I have a system with a non-critical postgres database that was unmonitored and consumed all available space on its drive. The OS is unaffected so I am free to delete files.

I would like to just delete the files and reinitialize the database to essentially start from scratch. How can this be done?

I'm running postgres 9.1. The config directories are in /etc/postgres but all of the actual postgres data is in /var/lib/postgres, which is mounted in a different volume group.

Best Answer

Since you say that the config directories are in /etc/postgres I'm guessing you're running Ubuntu or Debian, which use pg_wrapper for management of their PostgreSQL installs.

On these platforms you use pg_dropcluster to destroy and remove all databases, then pg_createcluster to create a new blank server instance.

This guide for PostgreSQL on Ubuntu may be informative.