0

The OS is Ubuntu 20.04. I moved the data directory to a secondary disk. In the "Disks" utility, I clicked "Edit Mount Options", turned off "User Session Defaults", and specified a hard-coded Mount Point like /mnt/database, because by default it was mounted at something like /media/[user name]/disk label. "Mount at system startup" had been checked (unchanged from default).

Now, postgresql's automatic start at the system startup fails with a message like: "[data directory] is not accessible or does not exist". If I manually start it, by executing sudo systemctl start postgresql it starts fine. I suspect that the system tried to start postgresql before the secondary disk was automatically mounted. Is that so? If that is the case, how can I make it start after the secondary disk has been mounted?


PS: I solved it. It was the order. I cannot believe why the tutorials that explained moving data directory to a secondary disk did not mention this.

Open the service file:

sudo nano /lib/systemd/system/postgresql@.service

Add the disk's name at:

After=network.target mnt-[disk name].mount

If the disk name is "database", then it is mnt-database.mount.

2
  • You should probably post your solution as a proper answer. You can then accept it to show that it works, and other people might upvote it. – mustaccio Oct 30 '20 at 15:52
  • Because a postgresql tutorial is not a linux tutorial. – jjanes Oct 30 '20 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.