Resize LVM disk after extending Virtual Machine disk (vmdk)

Follow these simple steps to resize a Virtual machine disk (vmdk) and then extend the volume using LVM. Make sure that you have/make a backup before carrying out these steps. First go ahead and extend the vmdk from ESXi/vCenter. I increased the disk size from 20GB-->>30GB.

Before

After

Then Go ahead and run these commands to extend the LVM volume on Linux host.

First check the existing partitions

# lsblk

Note: If new size is not visible, Run a re-scan of iscsi bus

# ls /sys/class/scsi_disk/

# echo "1" > /sys/class/scsi_disk/2:0:2:0/device/rescan

Note: as it’s the 2nd disk = sdb, scan the 2nd entry

Now resize the physical volume

# pvresize /dev/sdb

Check the FREE PE (Physical Extents)

# pvdisplay

Take a note of the PE and use it to extend the partition. I want to extend the var_lv as displayed below.

# df -h | grep var

Now extend

# lvextend -l +2560 /dev/mapper/VolGroup01-var_lv

(OR)

# lvextend -L+1GB /dev/mapper/VolGroup01-var_lv (For specific size extension)

And then resize the partition (using FRE PE).

# resize2fs /dev/mapper/VolGroup01-var_lv

And that’s it you should up and running with the extra space with no downtime required or data loss as its LVM.

Most Read Articles

Add/Detect a new disk in ...

Written By Farooq Mohammed Ahmed on Sunday, 11 January 2015 19:22
Add/Detect a new disk in ...

Replace SSL Certificates ...

Written By Farooq Mohammed Ahmed on Friday, 16 December 2016 08:05
Replace SSL Certificates ...

Using awk in Alias Comman...

Written By Farooq Mohammed Ahmed on Friday, 19 February 2016 14:22
Using awk in Alias Comman...

Script to Monitor Nagios ...

Written By Farooq Mohammed Ahmed on Monday, 18 July 2016 22:48
Script to Monitor Nagios ...

Generate/Create a SHA2/SH...

Written By Farooq Mohammed Ahmed on Tuesday, 25 October 2016 13:56
Generate/Create a SHA2/SH...