If you’re deploying a RHEL VM image and need to resize it, there are two options:
- Add an additional disk add incorporate it as a LVM physical volume
- Extend the current physical volume and grow the PV and LV
I’m usually going for the second one in my test setup – these are the steps:
- Power off the VM.
- Increase the size of the disk.
- Power on and run disk, removing the current LVM partition and recreating it to expand it to the new size (in my test setup, this is /dev/sda and the second partition, /dev/sda2).
- Reboot again, in order to make the kernel pickup on the new partitioning.
- Resize the physical volume: pvresize /dev/sda2
- Verify the new size with pvdisplay
- Grow the logical volume by adding all the available space:
lvresize -l +100%FREE /dev/centos/root - Finally, grow the actual root partition – no need to reboot:
xfs_growfs /