0

Apache can use only 50GB, so if my websites go over this amount the server crashes. THis VM has 200GB allocated to it. But I did not set up the volumes correctly. How can I allocate some of the space from lv_home over to lv_root?

# df -h
/dev/mapper/vg_nastgweblls01-lv_root
                       50G  5.0G   42G  11% /
tmpfs                 2.9G     0  2.9G   0% /dev/shm
/dev/sda1             485M  109M  352M  24% /boot
/dev/mapper/vg_nastgweblls01-lv_home
                  142G  188M  135G   1% /home
Aaron Copley
  • 12,525
  • 5
  • 47
  • 68
paul cappucci
  • 111
  • 1
  • 4

1 Answers1

6

You need to unmount a filesystem to shrink it. So, for /home you'll want to be log in as root and umount /home. If it's 'busy'. You may need to stop any processes using files here.

Then, shrink the file system to just below your targeted logical volume size.

resize2fs /dev/mapper/vg_nastgweblls01-lv_home 99G

Shrink the logical volume to the targeted size.

lvreduce -L 100G /dev/mapper/vg_nastgweblls01-lv_home

Grow the filesystem to the logical volume's capacity.

resize2fs /dev/mapper/vg_nastgweblls01-lv_home

The reason I do it this so I don't have to do any math and keep the filesystem the size of the container. A bit lazy, but it works great.

Now, you have free space to grow root.

lvextend -L 75G /dev/mapper/vg_nastgweblls01-lv_root
resize2fs /dev/mapper/vg_nastgweblls01-lv_root

Don't hesitate to leave some unallocated space since it's easier to grow as needed later.

Aaron Copley
  • 12,525
  • 5
  • 47
  • 68
  • Thank you very much Aaron. I will do this today and report back here. Since my VM is a Dev server, I can stop all services anytime. Paul – paul cappucci Jan 24 '13 at 15:33
  • Thanks Aaron, it worked great. When I first tried to run: `resize2fs /dev/mapper/vg_nastgweblls01-lv_root 99G` it said to "Please run 'e2fsck -f /dev/mapper/vg_nastgweblls01-lv_root' first". So I did and then I ran: `resize2fs /dev/mapper/vg_nastgweblls01-lv_home 99G` I finished the rest of your instructions. And remembered that I need to mount the home drive, so I ran: `mount /home` then ran: df -h and all the new drives sizes were correct! Thanks – paul cappucci Jan 28 '13 at 17:28
  • I have a hard time trying to get code formatted and indented in grey using this editor – paul cappucci Jan 28 '13 at 17:29
  • Glad to help. Get more markdown help [here](http://serverfault.com/editing-help). Note that comments are subject to restrictions including line-breaks and indents. – Aaron Copley Jan 28 '13 at 18:12