1

I am trying to install and set up postgres 9.4 on ubuntu 14.04.

What is the best way to install postgres whilst ensuring all created tables and databases (and anything else that could potentially occupy a lot of disk space) are stored at /database?

1 Answer 1

3

Personally, I'd just remount whatever you've stuck at /database onto /var/lib/postgresql, because you're going to confuse the living heck out of anyone who has to deal with this frankenmachine in the future. That being said, if you really want to move it, there's two ways forward:

  • Make /var/lib/postgresql a symlink to /database. Keeps the filesystem structure intact, at the cost of a symlink (which give some people the heebie-jeebies).

  • The other way is a bit more involved, but arguably "more correct". In this case, install just the postgresql-common package, before you install any of the other postgresql-related packages. Then, edit /etc/postgresql-common/createcluster.conf, and change the line that sets data_directory so that it reads data_directory = '/database/%v/%c'. So you'll need to uncomment it, then edit the value. (While you're in there, you can also change initdb_options to specify a different character encoding and locale, if you want, and set log_line_prefix to something more readable...)

    Then install the postgresql-9.4 package. It'll pick up the custom value for data_directory and create the new cluster in there, instead of in the default location.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .