Expanding LVM Filesystems

  1. Create a snapshot in vSphere of the server you are updating.

  2. Expand the physical drive in vSphere or whichever tool you are using to manage the server.

  3. 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.

  4. 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 p to print the current partition table
    • Press n to create a new partition and answer prompts accordingly.
    • Print p the parition table again to make sure the changes are correct.
    • Press w to write the changes and exit. If neccessary, you can press q to quit without saving changes.
  5. Reboot the server so the new filesystem can take effect.

  6. Check the current volume group settings: vgdisplay. Note the VG Name which you will need later on step 8.

  7. Create the new physical volume using the newest parition: pvcreate /dev/sdxy. Where x is the device letter and y is the partition number.

  8. Extend the volume group to use the new physical volume from step 7: vgextend vg_name_here /dev/sdxy. Dont forget to replace vg_name_here and sdxy with the correct corresponding values.

  9. Run vgdisplay again 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.

  10. Identify the logical volume to expand by its LV Path value: lvdisplay

  11. Expand the logical volume: lvextend -l +100%FREE lv_path_here For example, your command might look like this:

    lvextend -l +100%FREE /dev/rhel_vpn/root
  12. Identify the filesystem type: df -Th

  13. Expand the filesystem For XFS: xfs_growfs lv_path_here For EXT4: resize2fs /dev/sdxy For BTRFS: For ZFS:

Back to top