Sep 27 3 How to extend a LVM volume group
Extending a logical volume group usually needs to be done when the size of a VMware disk has been increased for a Linux VM. When resizing a disk, the volume isn't extended automatically, so you need to extend the logical volume in the VM's volume group.
This article assumes that:
- You have a LVM volume group with a logical volume
- You've added free space in the virtualizer, e.g. VMware
- You're running Ubuntu. Might also work with other distributions
- You have basic knowledge of partitions and Linux
- Start by creating a new partition from the free space. I prefer doing this with a GUI using gparted. You need XQuartz if you're on a Mac.
- SSH into the box with -X, e.g. ssh -X myserver
- Install gparted: apt-get install -y gparted and run gparted
- Find the unallocated space ("unallocated" file system)
- Right click and click New.
- Create as "primary partition" and Choose lvm2 pv as the "file system"
- Click Add
- Click Apply in the toolbar and again in the dialog
- Note the disk name in the Partition column, e.g. /dev/sda3
- You should see the disk with fdisk -l
- Run pvcreate <disk>, e.g. pvcreate /dev/sda3
- Find the volume group: run vgdisplay (name is where it says VG Name)
- Extend the VG with the disk: vgextend <vg name> <disk>, e.g. vgextend VolumeGroup /dev/sda3
- Run vgscan & pvscan
- Run lvdisplay to find the LV Path, e.g. /dev/VolumeGroup/root
- Extend the logical volume: lvextend <lv path> <disk>, e.g. lvextend /dev/VolumeGroup/root /dev/sda3
- Resize the file system: resize2fs <lv path>, e.g. resize2fs /dev/VolumeGroup/root
- Finally, verify that the size of the partition has been increased with df -h