Increasing Disk Space with Linux LVM

Increasing Disk Space with Linux LVM (VMware vSphere)

Steps to increase disk space on a Linux virtual machine hosted in VMware vSphere and how to expand the logical volume accordingly.

1. Increase Disk Space in VMware vSphere

Action:

In the vSphere web interface, increase the disk size of the VM.

Right-click VM → Edit Settings → Expand the size of the virtual disk (e.g., from 40 GB to 60 GB).

Save and reboot the VM if needed.

2. Check New Space with cfdisk

sudo cfdisk /dev/sdX

Replace /dev/sdX with your actual disk (e.g., /dev/sda).

You should now see unallocated (free) space at the end of the disk.

3. Launch parted Utility

sudo parted /dev/sdX

4. Display Free Space

(parted) print free

This command will show all partitions and any free space available.

5. Resize the Partition

(parted) resizepart

i) Enter partition number: E.g., 2

ii) Enter new end point: Use the value shown in print free, e.g., 60GB

6. Re-check Partition Table with cfdisk

sudo cfdisk /dev/sdX

Confirm the resized partition includes the new space.

7. Resize Physical Volume

sudo pvresize /dev/sdX2

Replace /dev/sdX2 with your actual partition that was resized.

8. Check Volume Group Size

sudo vgs

This displays the updated size of the Volume Group (VG).

9. Extend the Logical Volume (LV)

sudo lvextend -l +100%FREE /dev/mapper/vgname-lvname

Replace /dev/mapper/vgname-lvname with your actual Logical Volume path.