Server Fault is a question and answer site for system and network administrators. 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 didn't pay attention when i installed postgresql with aptitude, but it installed the databases in the wrong partition.

Now my partitions look like this:

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md1               10G  8.7G  793M  92% /
tmpfs                 2.0G     0  2.0G   0% /lib/init/rw
udev                   10M  176K  9.9M   2% /dev
tmpfs                 2.0G     0  2.0G   0% /dev/shm
/dev/md2              683G  197M  649G   1% /home

I checked and postgresql data is installed on /dev/md1

This will be a problem in no time, and I would like to fix this. What is the best approach ? Can i simply move the postgresql directory and patch some configuration file ? Can I extend the size of the partition dev/md1 ?

I'm looking for a way to do any of this successfully.

share|improve this question
Yes you can. No problem. – mailq Jan 12 '12 at 21:46
up vote 1 down vote accepted

Shut down postgresql, move its directory to a new location, then either create a symlink from the old to the new location, or edit the configuration file, make sure the permissions are correct after moving (!). Finally start postgresql.

I have done this many times with mysql, or even oracle, it's perfectly fine as long as you don't mind the downtime. Don't try it on a running database server of course. In that case use the ways provided by the server to move files around. But at least in oracle's case you will still cause a bit of interruption of service since you'd have to take tablespace temporarily offline.

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.