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've got an (externally hosted) production server running Ubuntu LTS. It serves webpages (rails) and has an svn repository accesible through Apache, and a PostgreSQL db.

I've got ssh access to the server and root privileges.

Most of the "interesting" stuff is located in /var/ : svn repositories are inside /var/svn, web pages under /var/www, etc.

Yesterday I was curious about how much disk space had it left, so I did the following:

$ df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/md1              950M  402M  500M  45% /
varrun                990M   64K  990M   1% /var/run
varlock               990M     0  990M   0% /var/lock
udev                  990M   76K  989M   1% /dev
devshm                990M     0  990M   0% /dev/shm
/dev/md5              4.7G  668M  4.1G  15% /usr
/dev/md6              4.7G  1.4G  3.4G  29% /var
/dev/md7              221G   28M  221G   1% /home
none                  990M  4.0K  990M   1% /tmp

My 'var' partition, which holds most of the interesting part, is only 4.7G big. The /home/ partition, on the other hand, is 221G, but it is mostly unused.

I should have checked the disk layout before starting installing stuff.

Ideally I would need /var/ and /home/ to be "switched" - /home/ should be the one with 4.7G, and /var/ the one with 221G.

Is there a way to solve this without having to reinstall the whole thing?

share|improve this question
Do you have console access and a downtime window? If so this could be done pretty cleanly. – cagenut Mar 25 '10 at 14:27
up vote 2 down vote accepted

You could always just move the important stuff from /var (/var/www, /var/lib/postgres, /var/svn etc) to /home and put symlinks back to /var.

share|improve this answer
Your idea is intriguing. Certainly seems like the easiest thing to implement. However it looks a bit messy. I'll try the other solutions, and if I can't get them running, I'll try yours. – egarcia Mar 26 '10 at 16:04
I ended up using this solution. It was safest. – egarcia Mar 29 '10 at 9:06

Well as I see it you copy the contents of home to some Temp directory (using rsync maybe to be sure to get all oft it) than you delete everything in home and rsync var to current home. afterwards copy the temp copy of home back to current var and unmount and mount both partitions to their new locations, if everythings works, change the fstab to reflekt the changes and reboot. Of course this will cause some downtime. but you don't have to reinstall anything.

share|improve this answer
This sounds very straightforward. What kind of problems can I expect from umounting /var/ and /home/? Can I loose ssh access if var stops existing? Will my account still work if the home folder is unmounted? – egarcia Mar 26 '10 at 16:07
I could not do this because unmounting /var/ is tricky. You can rsync, modify the fstab, reboot and... pray. But if anything doesn't work, I risk the server not being able to reboot. So I've decided moving things to home and making symlinks. Thanks for the answer anyway. – egarcia Mar 29 '10 at 9:07

SideShowCoder has the right idea. Its going to require some acrobatics and possibly moving some items off the server or to another drive while things are being shuffled.

For future set ups, I would highly recommend looking at LVM. It makes solving problems like this relatively simple and everything can be done without any downtime.

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.