Sunday, August 3, 2014

Ubuntu LVM logical volume manager resizing extending a virtual machine in esxi or vmware

First boot up the machine as normal and login as root


pvdisplay will show you current information about the lvm setup.

root@machine:~# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda5
  VG Name               machine-vg
  PV Size               45.76 GiB / not usable 1.81 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              28098
  Free PE               123
  Allocated PE          27975
  PV UUID               1DUlmw-Jvjc-MgSA-5gQB-35ZP-wnkb-llXfhO


Make sure before continuing you already added your additional space for the virtual machine and you have booted from gparted iso and extended the disk. If you need to know how to do this click here

List out the lvs information to get the name of the volume

root@machine:~# lvs
  LV     VG              Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  root   machine-vg -wi-ao 45.28g                                    
  swap_1 machine-vg -wi-ao   2.00g    


Extend the lvm adding the free PE available

root@machine:~# lvextend -L +8800 /dev/machine-vg/root

The +8800 will complain if it's not enough free PE available so make sure you adjust as needed to match your available PE.

Otherwise a message will appear as
 Extending logical volume root to 108.75 GiB
  Insufficient free space: 375 extents needed, but only 123 available


Now let's extend the volume

root@machine:~# resize2fs /dev/machine-vg/root
resize2fs 1.42 (29-Nov-2011)
Filesystem at /dev/machine-vg/root is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 7
The filesystem on /dev/machine-vg/root is now 28123136 blocks long.


Now check your diskspace free on the machine

root@machine:~# df -h
Filesystem                         Size  Used Avail Use% Mounted on
/dev/mapper/machine--vg-root  106G   35G   67G  35% /
udev                               179M  4.0K  179M   1% /dev
tmpfs                               38M  288K   38M   1% /run
none                               5.0M     0  5.0M   0% /run/lock
none                               189M     0  189M   0% /run/shm
cgroup                             189M     0  189M   0% /sys/fs/cgroup
/dev/sda1                          236M  233M     0 100% /boot


Woot you did it.

See more LVM details





No comments:

Post a Comment

Got a Suggestion please let us know