Re-sizing a LVM Linux Partition

By | July 18, 2013

First, make sure you have either extended your virtual disk using HyperV or VMWare ESX interfaces.  This can be done a number of ways either by expanding in existing disk or adding in a secondary disk.  Since we are using the Logical Volume Manager (LVM) we can still make it appear as one volume.  Next, make sure you install cfdisk via yum or using the rpm repository of your choice.  Now that everything is ready to go, lets do this:

  1. Login to your server using the root user.
  2. Run the following command cfdisk /dev/sda
  3. Select the newly added free space and choose New at the bottom
  4. Select Primary and hit Enter
  5. Leave it at the default size and press Enter again
  6. Select Write then press Enter
  7. When asked if you are sure you want to write the partition to disk select yes
  8. Exit out with Esc or Ctrl+Z
  9. Reboot the server
  10. When the server comes back up login as root
  11. NOTE:  If you are running RedHat 6 or later, you must run this command – partx -v -a /dev/sda – to re-read all the partitions then proceed as normal.
  12. Run the command pvcreate /dev/sda# where sda# is the new device added via CFdisk.  Re-run cfdisk to verify the device name.
  13. Run vgdisplay to check the volume group name.
  14. Run vgextend vg_name /dev/sda3 to extend your volume group on the appropriate device
  15. Run lvdisplay to find the Logical Volume name containing your root volume
  16. Run lvextend -L +20G /dev/vg_name/lv_name – where 20G is the size you want to expand your logical volume, vg_name is your volume group name, and lv_name is your logical volume name.
  17. Lastly, run resize2fs /dev/vg_name/lv_name to resize the file system on your root LV.
  18. You can then run vgdisplay to check the volume group size and verify it is the proper size.

There ya go, the LVM is resized in 17 easy steps.  Works almost every time with minimal downtime.