Expanding LVM Filesystems
Create a snapshot in vSphere of the server you are updating.
Expand the physical drive in vSphere or whichever tool you are using to manage the server.
Log into the server and check the current partitions on the device:
fdisk -l. Check that the size of the disk matches the size chosen in step 1.Create a new partition to consume the new free space. Note that sdx refers to the device path you need to update. Often this may be /dev/sda or something similar. Make sure you know what device path to use.
fdisk /dev/sdx- Press
pto print the current partition table - Press
nto create a new partition and answer prompts accordingly. - Print
pthe parition table again to make sure the changes are correct. - Press
wto write the changes and exit. If neccessary, you can pressqto quit without saving changes.
Reboot the server so the new filesystem can take effect.
Check the current volume group settings:
vgdisplay. Note theVG Namewhich you will need later on step 8.Create the new physical volume using the newest parition:
pvcreate /dev/sdxy. Wherexis the device letter andyis the partition number.Extend the volume group to use the new physical volume from step 7:
vgextend vg_name_here /dev/sdxy. Dont forget to replacevg_name_hereandsdxywith the correct corresponding values.Run
vgdisplayagain and check that the new VG size matches your expectations. You can also see the amount of free space left in the volume group as well.Identify the logical volume to expand by its
LV Pathvalue:lvdisplayExpand the logical volume:
lvextend -l +100%FREE lv_path_hereFor example, your command might look like this:lvextend -l +100%FREE /dev/rhel_vpn/rootIdentify the filesystem type:
df -ThExpand the filesystem For XFS:
xfs_growfs lv_path_hereFor EXT4:resize2fs /dev/sdxyFor BTRFS: For ZFS: