How to resize disk space on Virtual Machine

In order to resize disk space follow the following steps:
Please restart VM in recovery mode in citrix xencenter before following steps below.
For example you have two partitions. one is root and another is home (this example is taken from VM where CPanel is installed).
First of we have to reduce partition root:

#lvm pvscan #lvm vgscan
#lvm vgchange -ay
#lvm lvscan
#lvm lvdisplay /dev/VolGroup/lv_root
#fsck.ext4 /dev/VolGroup/lv_root
#e2fsck -f /dev/VolGroup/lv_root

Use desire disk size you would like to reduce -- in the example below size to reduce is 20G

#resize 2fs -p /dev/VolGroup/lv_root 20G
#lvm lvreduce -L 20G /dev/VolGroup/lv_root
Verify the change
#lvm lvdisplay /dev/VolGroup/lv_root

Now you need to extend the other disk partion and add the space you just reduced above.

#lvm lvextend -L +30G /dev/VolGroup/lv_home
#e2fsck -f /dev/VolGroup/lv_home
#resize2fs /dev/VolGroup/lv_home
Verify the the change
#lvm lvdisplay /dev/VolGroup/lv_home

Reboot the VM and you are done.
Was this answer helpful? 3 Users Found This Useful (45 Votes)