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

by Tim R   Last Updated April 26, 2018 14:00 PM

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



Answers 1


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.

Satanicpuppy
Satanicpuppy
April 26, 2018 14:03 PM

Related Questions


Best way to partition required sace

Updated September 19, 2017 09:00 AM

partx: /dev/sdd: error adding partition 1

Updated January 29, 2019 07:00 AM

How to shrink home partition and add backup partition

Updated February 07, 2019 21:00 PM


How to shrink /home and add more space on CentOS7

Updated April 21, 2016 08:00 AM