We recently moved the data directory of our database to a new hard drive because the old one was full.
I needed to clean up some space in order to install something, so I deleted the old data directory.
Now postgres doesn't start anymore, presumably because I deleted the postgresql.config
There are no logs in /var/log/postgres/...
.
The data directory we copied to the new hard drive doesn't contain a postgresql.conf, i don't know why though.
Deleting the old data directory also didn't free any space even though the folder was 21GB, so I cannot use initdb
to create a new config and point it to the new data directory because the disk is full.
Is there any way I can get the system back up and running? We are using postgres 12, if that matters.
Best Answer
Postgres will indeed refuse to start if the
postgresql.conf
file does not exist, although I'm also not sure why your data directory doesn't include one. Are you sure you didn't accidentally delete it?Regardless, your Postgres package should have come with sample configuration files, including a
postgresql.conf.sample
. If you built it from source with the default options, you can find it in the/usr/local/pgsql/share
directory. The Arch Linux package manager install puts these "architecture-independent support files" in the/usr/share/postgresql
directory (this is what thepg_config
utility calls them).You can see where your particular installation was configured to put them by querying the
pg_config
utility with the--sharedir
option. The server does not need to be running, and I temporarily renamed my ownpostgresql.conf
file to see whether I could still querypg_config
, and I could, so I don't know whether this is a viable option for you, unfortunately, sorry about that.To actually be able to create a configuration file and initialize the postmaster daemon though, have you tried running
lsof +L1 | grep deleted
to see if any active processes still hold a reference to the old data directory? This always seems to be the problem when unlinking an inode (i.e., deleting a file/folder) doesn't actually free up the corresponding space.