Lvm – Resize Centos 7 Root partition set up as xfs file system.

centos7lvmpartition

I am trying to resize the root partition folder from 50GB to 750GB. I have already increase the size of the drive. If I do an fdisk on /dev/sda and delete partition 2 and then recreate it the /dev/sda2 is resized correctly showing 999GB. When I then try to do a vgextend it gives an error saying, "can't open dev sda2 exclusively. mounted filesystem?" How can I increase the size of the root LVM partition? I attached screenshots of the different outputs for reference.

If I run: lvextend -l +100%FREE /dev/centos/root It tells me it expanding from 50Gb to 50Gb.

df -h output

df -T output

lsblk output

lvdisplay output

pvdisplay output

vgdisplay output

pvs vgs & lvs output

Best Answer

You're doing two different methods of resizing the drive.

If your drive was just a filesystem sitting on a partition, you could extend the drive, delete the partition, recreate the larger partition, and then just extend the filesystem with xfs_growfs. That's how it was done in the old days, before LVM.

You're using logical volumes though, which means you have defined physical devices, volume groups, logical volumes, etc. The easiest way to extend that would have been to create a new partition, create a new physical device from that, add it to the volume group, then do the lvextend/xfs_growfs. Here is a more thorough how-to for that.

You're kind of split down the middle here, but it's fixable. You need to pvresize to fix the size of the physical volume: it's not showing the full size of the 750GB you've allocated to it. That should increase the free space in your volume group, and then you can extend the volume.