How to increase disk size using logical volume manager
Okay, so you added extra space on a VM or a new disk on the physical server, follow the steps below to increase the logical volume without reboot.
check the disk and current volumes
fdisk -l
Run fdisk on the disk (in this case it was sda)
fdisk /dev/sda
Check free unpartitioned space
F
print the partition table
p
create a new partition
n
select primary partition
p
select the partition number(in this case it was 3)
3
write changes to the partition table (ignore errors if any)
w
run partx to view the disk partition without rebooting if the fdisk command above throws a message that the new partition table will be available after reboot
partx -v -a /dev/sda
create a physical volume using /dev/sda3
pvcreate /dev/sda3
display volume group information (check for Free PE / Size)
vgdisplay
Extend the Volume Group (in this case vg0)
vgextend vg0 /dev/sda3
display volume group information again (check for Free PE / Size)
vgdisplay
*note the - Free PE / Size
Run lvdisplay to list all logical volumes and then run it again with the volume you wish to extend
lvdisplay /dev/vg0/root
* Note the - Current LE
Resize the Logical Volume
lvresize -l 438 /dev/vg0/root
*The number is Free PE Current LE
OR
lvresize --size [plus]10GB /Dev/vg0/root
(replace 10GB with the amount of space you want to increase)
Run the df command
df -h
Resize the partition
resize2fs /dev/mapper/vg0-root
Run df again
df -h
The disk space on the volume has increased.