Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

First of all: I'm just a beginning Linux-User ;-)

I've set up a server with OpenVZ support. I wrote a backup script that's dumping the vz containers from time to time. But some containers are not backed up due to insufficient disk space. So I ran df -h which gives me this:

Filesystem            Size  Used Avail Use% Mounted on
240f0d7c-195b-461b-87e3-0d0dfc33c3d4
                      5.0G  4.4G  362M  93% /
tmpfs                 2.0G     0  2.0G   0% /lib/init/rw
udev                   10M  660K  9.4M   7% /dev
tmpfs                 2.0G  4.0K  2.0G   1% /dev/shm
/dev/sda3             270G   32G  225G  13% /vz
/dev/sda4             184G  188M  174G   1% /srv

So it seems the problem is the root partition (?) which has only 362M available. As /srv has 174G which is may too much I want to "give" some disk space from there to root. Can someone explain how I can do this and maybe explain it a little bit. I don't really know much about this mounting/partioning on Linux (yet).

Thanks!

share|improve this question
    
You can probably do something very simple instead. Your root directory surely contains something what not really belongs there. Either reconfigure the program working with it or move the whole directory to another partition and create a symlink pointing there instead. –  maaartinus Mar 10 '11 at 10:02

1 Answer 1

up vote 2 down vote accepted

The simplest soulution is to create a backup of /srv. This is only 188MB it should fit in /srv.tar.

tar cvf /srv.tar.bz2 --auto-compress /srv

Then delete the sda4 partition and create 2 others. You can use cfdisk /dev/sda or any other partitioning software.

  • sda4 extended partition (you can only have 4 otherwise)
  • sda5 for /srv
  • sda6 for the backups

Create filesystems on sda5 and sda6 mount sda5 to /srv and restore the backup.

mke2fs -j /dev/sda5 # For ext3 filesystems
mke2fs -j /dev/sda6 #  use mkfs.<fsname> for any other
mount /dev/sda5 /srv
cd /srv
tar xvf /srv.tar.bz2 --preserve-permissions

Mount /sda6 to the directory where you want the backups stored. For example:

mount /dev/sda6 /var/lib/backups

Don't forget to modify /etc/fstab. Add the new backups filesystem and change the device for /srv.

/dev/sda5 /srv             ext3 defaults 0 0
/dev/sda6 /var/lib/backups ext3 defaults 0 0

In the future it would be a good idea to use LVM. That makes this sort of problems easier.

share|improve this answer
    
Thank you for your answer. But does this give the first entry in the df-output (mounted on "/") enough space back? –  acme Mar 10 '11 at 9:35
    
@acme: Not on /. This creates a big partition where you can put your backups. If you want to have more space on / you need to delete and recreate that partition too. You will need a livecd to do that. –  stribika Mar 10 '11 at 9:43
    
Ok thank you! Disk space for the backup files is not a problem as they are rsync'd to another server and deleted afterwards. OpenVZ needs some temp disk space for dumping though and I guess it's using some directory below root. But maybe I can also tell OpenVZ to use a different tmp-dir (on /srv). –  acme Mar 10 '11 at 9:45

Your Answer

 
discard

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.