How to Resize a Logical Volume (LVM) in CentOS 7⚓︎
Summary⚓︎
When extending a virtual disk in Xen Center, it's not as simple as just opening the Storage tab and allocating free space. This is only the first part of it, as all this is doing is adding unallocated space into a separate volume.
This article assumes that additional storage has already been added to the virtual disk within Xen Center.
How To⚓︎
The following steps should be taken inside an elevated (sudo) Terminal window after you've ssh'd into the Docker VM...
Begin resizing the logical volume
fdisk -l /dev/xvda
Create a new primary partition and set the type as Linux LVM.
n - add a new partition
p - primary partition
3 - partition number 3 (may need to be adjusted depending on number of partitions; likely just use default)
default - First Cylinder
default - Last Cylinder
p - verify new partition has been created; type on new partition is likely not LVM and will need to be changed.
t- change the partition's system ID
default - Partition Number
8e - Linux LVM
p - confirm partition type is now LVM
w - write table to disk and exit
reboot - Reboot the VM
Create a new primary volume and extend the volume group to the new volume.
vgdisplay - display the volume group; make note of volume name
lvdisplay - display the logical volume
pvcreate centos /dev/xvda3 - 'centos' is the name of the volume from vgdisplay
vgextend /dev/centos /dev/xvda3
Check the physical volume for free space, extend the logical volume with the free space.
vgs - shows amount of virtual free space; make note of this
lvextend -L+{virtual free space} /dev/mapper/centos/root
vgs - should no longer have unallocated virtual free space
Finally, resize the logical volume, then check the available free space.
Reference⚓︎
Reference video:
https://www.youtube.com/watch?v=LT2Hd4UWmOQ
Reference on Stack Overflow
https://stackoverflow.com/a/26320277