I am wondering if there is a convention on where to store the data folder containing all the files for the tables and rows of a relational database system such as Postgres.


On OpenBSD, the (OpenBSD) postgresql-server package will be preconfigured to use /var/postgresql/data for its databases. It also adds a _postgresql service user with /var/postgresql as its home directory.

Storing databases under /var makes sense as they generally contain variable data. If your /var partition is not big enough, you may consider changing this to some other location where you have more space, or mounting a separate filesystem at /var/postgresql. Unfortunately, I'm not a FreeBSD user and can not tell you how to do that in the most convenient way for PostgreSQL on FreeBSD.

On OpenBSD, changing the location of the data directory would involve changing a datadir variable in the rc script /etc/rc.d/postgresql (this particular variable does not seem to be configurable through the native rcctl utility for whatever reason).

From a comment by JdeBP: For FreeBSD, the default location for the databases is /var/db/postgres/data10 (presumably this is for PostgreSQL 10). This is configurable by changing/setting the value of the postgresql_data variable in /etc/rc.conf.

| improve this answer | |
  • 1
    Mounting a filesystem with more space on /var/postgres is also an option. Also, relevant man page for filesystem hierarchy: man.openbsd.org/hier – Peschke Nov 26 '18 at 8:22
  • 1
    /var/db/postgres/data10 and postgresql_data in /etc/rc.conf – JdeBP Nov 26 '18 at 11:36
  • @JdeBP Check my addition. Correct? – Kusalananda Nov 26 '18 at 11:40
  • 2
    I believe so. – JdeBP Nov 26 '18 at 11:44

Your Answer

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

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