0

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?

1
  • Do you have console access and a downtime window? If so this could be done pretty cleanly.
    – cagenut
    Mar 25, 2010 at 14:27

3 Answers 3

2

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.

2
  • 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, 2010 at 16:04
  • I ended up using this solution. It was safest.
    – egarcia
    Mar 29, 2010 at 9:06
1

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.

2
  • 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, 2010 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, 2010 at 9:07
1

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.

You must log in to answer this question.

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