Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use postgresql 9.1, on ubuntu 12.04. I had installed the depot package.

I have added a new partition to my system, and I would like to create a postgresql database on this partition ( which will be entirely dedicated to this database).

My pgdata is located in var/lib/postgresql/9.1/main. I plan to stop the postgresql service, copy the pgdata content to the new partition, then make a symbolic link to the new partition, chown the new directory to postgres user, restart postgresql... but I'm afraid this all looks more like a hack.

Is there a way to create a database specifically on a specified partition ? Something more "canonical" (not a play of word with ubuntu)

share|improve this question
It depends on your operating system and whether it's a self-compiled or pre-packaged postgres install, you need to provide these details in the question – Daniel Vérité Mar 19 '13 at 15:07
@DanielVérité ubuntu 12.04., ubuntu depot package installed – Stephane Rolland Mar 19 '13 at 15:15
Check the answers to this question. – jop Mar 19 '13 at 15:18
ok I found it @ var/lib/postgresql/9.1/main – Stephane Rolland Mar 19 '13 at 15:59
You don't need the symbolic link, just change the configuration of the postmaster startup script to point to the new data directory. You could also create a tablespace on the new partition and create the new database in that. No need to mess around with the data directory. – a_horse_with_no_name Mar 19 '13 at 16:35
up vote 4 down vote accepted

CREATE TABLESPACE should be used.

create tablespace dedicated_datastore owner postgres location '/my/mount/point/'

and now the tablespace can be used as parameter when creating a database, (or a table, or an index)

create database my_database tablespace dedicated_datastore
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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