0

I am attempting to increase the drive space on my Centos VM. I have added more space via virsh and can see that in lsblk. I then ran growpart /dev/sda 2 which told me that I could not extend that partition because it was 2......... in size.

After running that, I now am showing another LVM under the new partition which mirrors my existing LVM. My numbers are obviously not adding up as per the image below which seems to be telling me that there is more data on my partition than is possible!

I would appreciate any help on how to get my centos-root 253:0 under sda2 to expand to use the extra 100G space I just added.

enter image description here

enter image description here

2
  • 1
    You can't grow sda2 because partitions need to be contiguous. You'd need to remove the sda3, so that sda2 can expand to the end of the disk.
    – Zip
    Sep 15 '21 at 21:12
  • Since both sda2 and sda3 are fully in use and part of the same LVM volume group, removing sda3 would be difficult. But extending sda3 does the job just as well, precisely because they are both parts of the same volume group.
    – telcoM
    Sep 15 '21 at 22:11
1

This is just an artifact of how lsblk displays devices composed of multiple parts.The total size of centos-root LVM logical volume is 150G, but analyzing exactly how much of it is physically located on sda2 and how much on sda3 would require investigating the LVM mappings in detail, and apparently lsblk does not analyze LVM constructs quite that deeply.

The sum of the current sizes of centos-root, centos-swap and centos-home seems to be 199G, which is exactly the sum of the current sizes of sda2 and sda3 as well.

You would see the same effect with software RAID0 or RAID5 sets. Using lsblk -s to show first the filesystem-containing constructs and then a breakdown of physical devices they're composed of might be an enlightening alternate view here.

You should use growpart or parted to expand sda3 instead, since that's the partition that is physically located next to the free space. On older RHEL/CentOS versions you might have needed partprobe /dev/sda3 to tell the kernel to re-detect the partition size, but modern partition sizing tools should handle that automatically for you.

The next step would be pvresize /dev/sda3 to automatically expand the LVM PV to match the new size of the partition it's located in. This will give you free space in the LVM volume group (viewable with lvs or vgdisplay), which you can then use to extend your existing logical volumes or to create new ones.

For example, to add 20G of the added space to your /home filesystem, you could do:

lvextend -r -L +20G /dev/mapper/centos-home

With the -r option (available in CentOS 7 and newer) the filesystem will be automatically resized with the LV.

(Since your /boot filesystem seems to be XFS, I think I don't need to worry about CentOS 6.x and older.)


If you feel antsy about resizing existing partitions (old school), you could also use the new space to create a new partition /dev/sda4 (with parted or similar), set its type/flag to lvm, and then initialize it for LVM use and add it to your existing centos volume group:

pvcreate /dev/sda4
vgextend centos /dev/sda4

After this would be the lvextend step as above.

The end result is slightly aesthetically less pleasing than having the existing partition extended, but there should be no measurable difference in performance.

1
  • Thank you - that was very helpful and got me where I needed to be!
    – Emma
    Sep 16 '21 at 2:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.