Today i’m gonna giving a tutorial how to expand logical volume Management (or so called LVM) in centOS 7 especially when it run under virtual machine (mine is in ESXi). In conclusion It’s not hard as you think it is. Let’s start
VM Storage configuration
Power off the desire machine you want to extend.
Edit your VM setting by right click on the vm and choose edit settings.
Go to Hardware Tab and chose the Hard Drive and resize it by changing the value in the provision size (you can do this on the fly but if the addition space isn’t there, you can scan the scsi_disk (i’ll tell about it later)).
when you done resizing you Virtual machine hard drive , power up the virtual machine and login into it.
Check existing space and partition name
[this is where the fun begin ] note : you can do it from terminal inside the machine or using 3rd party ssh software like putty or whatever terminal tool suitable for you.
run this command first to check you space:
and run this command to find the volume you want to resize :
and look into your partition name (mine was /dev/sda)
Scanning newly added free space storage
next, run this command :
press p to check out if the additional space were added to the hard drive.
If your system still not detecting any addition space you insert earlier. You can use this method : force re-scan the scsi disk with this command :
Adding the free space into LVM
now you can create new partition using the additional space you’ve got after scanning the scsi_disk by using fdisk command and then press n. After that press t to change partition table to “8e”.
now press p to take a look if the new partition already created in the system.
and press w to write change it and reboot the system the apply the setting.
run the vgdisplay command to see current Volume group status.
now you can extend your volume group using this command :
vgextend <VG Name> <Newly Created Partition>
in my case is vgextend centos /dev/sda4
run the lvdisplay command to show the current logical volume status. In this case , i want to increase the root partition, so i only display the current status of root logical volume.
15. The next step is to increase the logical volume size of the /dev/centos/root by using this command :
lvextend <lv path> <newly created partition>
in my case is like this :
the last step is to resize the file system so that it can take advantage of the additional space added in volume group before.
you can check with command df -h to make sure the additional space was added to the system (mine is growing from 250 GB to 300 GB)
and Voila!!. You have more space in your system.