I tried for hours to try to get postgresql to use alternative file system locations for storage (see http://www.postgresql.org/docs/7.4/static/manage-ag-alternate-locs.html) using the standard 7.4.5-r2 ebuild. The key is to define an environment variable, say, PGDATA2 for secondary storage. This must be defined in the server environment upon startup, and neither global nor user-specific env-vars work here due to the way the init script calls "pg_ctl start". Reproducible: Always Steps to Reproduce: 1. Follow instructions on above link, using the init-script for starting/stopping the server. Actual Results: I had no success creating a new database in the new location because of the issues having the env-var defined when the server starts up. Expected Results: the init script should have some kind of mechanism for specifying alternative storage locations and making sure that gets passed on to the server After hours of experimenting I found a relatively elegant solution: Change the pg_ctl start line in the postgresql init script from su - $PGUSER -c "/usr/bin/pg_ctl start -D '$PGDATA' -s -l '$PGLOG' -o '$PGOPTS'" to su - $PGUSER -c "$PGDATA_ALT /usr/bin/pg_ctl start -D '$PGDATA' -s -l '$PGLOG' -o '$PGOPTS'" Also define PGDATA_ALT in /etc/conf.d/postgresql to be empty by default or as a sequence of locations, such as PGDATA_ALT="PGDATA2=/home/me/dbase1 PGDATA3=/home/you/dbase2" For each PGDATAx (or whatever you wanna call these vars) one could then issue "initlocation PGDATAx" (assuming the permissions have been fixed) followed by a "createdb -D PGDATAx mydbase_x"
Created attachment 42691 [details, diff] Patch as described for the init script
Created attachment 42692 [details, diff] Patch as described for the conf file
*** Bug 69138 has been marked as a duplicate of this bug. ***
Don't know how much sense it makes to fix this with postgres 8.0 and 8.1 in the tree (which use tablespaces for this kind of tricks), but it's fixed.