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.
postgres.config/pg_hba. I copied the config to the new data directory and am able to start postgres usingsudo -u postgres /usr/lib/postgresql/12/bin/pg_ctl -D /mnt/data/main -l /var/log/postgresql/tmp.log start. Everything seems to be working again. The only problem I have now is that i can't usesystemctlnorserviceto start the database. I have to usepg_ctl. – C5H8NNaO4 Oct 02 '20 at 14:10lsof +L1 | grep deletedto find locks on the file. I even rebooted the server. The old directory is definitely gone, but the space doesn't free up. – C5H8NNaO4 Oct 02 '20 at 14:11sudo systemctl edit postgresqlto override settings from the original unit file, that way the changes don't get overwritten when you upgrade the postgres package. In particular, I would look at overriding bothExecStartPre=...andExecStart=.... Regarding the file system space, that's definitely weird. I'm not sure how a reboot wouldn't have helped there. I might still trylsof +D /var/lib/postgres, but make sure to run it as root. If systemd or anything is opening a directory, stream, block, etc., that will find it, but I'm stumped – Jose Fernando Lopez Fernandez Oct 02 '20 at 14:24