Linux – how to increase the space of root partition by taking space from a xen PV

linuxlvmpartitionxen

I am stuck in pretty weird situation. I hope somebody here will help me.

I have one centOS server with XEN installed on it. XEN has 3-4 virtual machiens running on it. As required by XEN, this server has LVM implemented. The structure of Disk System is as following ( Kindly click on this image link) :

http://yfrog.com/72sh01nov191726j

This server has two disks of 750 GB each, and RAID implemented. MD2 partition is / (root) filesystem. It has only 10 GB of space. Now i have to increase the space of / filesystem. It is running short on space. Some more information about server is following:

  1. It has 1 volume group named xen in its LVM and its size is 682 GB.
  2. Their is a physical volume named md3 in volume group xen and its size is 682 GB.
  3. This physical volume has 5 logical volumes which are used for XEN virtual machines.

This volume group has 400 GB of free disk space. So i want to extract some space (200 GB)from it and use this space for / (root) partition.

This is a live server and i can not take risk of testing some test methods on it. I have searched for 4-5 hours for this issue but i was not able to get the proper and authentic answer. So i thought i should post my question here so that i can get a authentic answer.

This is very urgent, my client is shouting on me. .

one more thing i have no physical access this server as it is located in another country.

Kindly help me to solve this.

Best Answer

The general strategy for increasing the size of a file system hosted in LVM:

lvextend -L12G /dev/myvg/myvol

increases the size to 12G. You can use -L+12G to increase the size by 12G instead.

Make sure you have e2fsprogs installed from your favourite package manager. Then:

resize2fs /dev/myvg/myvol

Note: You typically do not want to do this on a mounted file system! There are kernel patches to allow it, but I would recommend taking the server offline first.

In case you are trying to increase the size of a filesystem inside a VM:

As the VM has its own disk layout you will need to modify it. For this you can use parted. What you want to do is something like:

parted /dev/myvg/myvol

And then use parted to erase move/erase volumes untill you can grow your root partition to the size you want. You can find more documentation for parted at http://www.gnu.org/software/parted/manual/html_chapter/parted_2.html