Lvm – How to tell pvresize to expand a physical volume to include all available space

lvm

We have a poorly implemented mysql server that had been built by a vendor. It has consumed 100% of available disk space, and as soon as any space is cleared out mysql grows to consume it. This is, obviously, a problem.

We currently have 2 disks in a raid 1+0, and just added 2 additional. We have added them directly to the RAID, so disk size should be essentially double what it was previously.

Pvresize would be our next step, but it only seems to facilitate growing to specific numbers (pvresize –setphysicalvolumesize 20G /path/to/disk).

Is there an equivalent command that lets you specify to expand to all physical space on the disk (or in this case, the array)?

Best Answer

As yoonix pointed out in the comment, the pvresize without options resizes physical volume to the size the operating system reports for the underlying partition.

pvresize /dev/sdXY

--setphysicalvolumesize option can be used to shrink the physical volume or to override the operating system autodetected size (if for some reason is wrong).

To extend a logical volume to full available capacity you have to pass to lvextend explicit option:

lvextend -l +100%FREE /dev/VGNAME/LVNAME