The Problem
Unable to perform lvresize, lvextend or lvcreate on logical volumes and the below error is received after executing any LVM command:
device-mapper: resume ioctl on (major:minor) failed: Invalid argument Unable to resume vgname-lvname (major:minor) Failed to activate new LV
The Solution
The above error gets triggered if some misconfiguration has been done with LVM. This issue is caused when the PSize (Physical Size) is set greater than the DevSize (Device Size). It can be verified by the output of the below command:
# pvs -v Scanning for physical volume names PV VG Fmt Attr PSize PFree DevSize PV UUID /dev/xvdc testvg1 lvm2 a- 10.00G 5.00G 5.00G 2XEI4w-LmJi-iR3B-xXVU-XxK3-dfTf-WPZXF6
Here you can notice that the PSize is set to 10G but actual Device size is only 5G and hence the PSize should be smaller or equal to DevSize. Also you can see the changes made by taking a look at the lvm archive files.
# cd /etc/lvm/archive # less testvg1_00000-320386444.vg description = "Created *before* executing 'pvresize --setphysicalvolumesize 10G /dev/xvdc'"
Above, the physical volume size for the archive file is set to 10G which resulted in corruption or locking of LVM functionality.
Action Plan
1. Revert back all changes made to your logical volumes and make it to the original size.
2. Then use pvresize -v /dev/xxxxx/xxxxx — based on your naming convention.
3. Now check the pvs -v output and make sure the PVSize and DEVSize matches.
4. Finally run lvresize, it should work.
If you want to increase the physical volume size then first create a new partition and then initialize with pvcreate and add this partition to the existing volgroup with vgextend and start the normal procedure for lv extend.
Example
Below is an example to the above Action Plan:
1. Reverting back the changes made on LV and make sure that LVSize is within the Devsize limit.
# lvresize -L 4G /dev/testvg1/test_lv WARNING: Reducing active logical volume to 4.00 GB THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce test_lv? [y/n]: y Reducing logical volume test_lv to 4.00 GB Logical volume test_lv successfully resized
2. Now will use pvresize -v /dev/xxxx/xxxx
# pvresize -v /dev/xvdc Using physical volume(s) on command line Archiving volume group "testvg1" metadata (seqno 9). Resizing physical volume /dev/xvdc from 2559 to 1279 extents. Resizing volume "/dev/xvdc" to 10485376 sectors. Updating physical volume "/dev/xvdc" Creating volume group backup "/etc/lvm/backup/testvg1" (seqno 10). Physical volume "/dev/xvdc" changed 1 physical volume(s) resized / 0 physical volume(s) not resized
3. Verifying by pvs -v command:
# pvs -v Scanning for physical volume names PV VG Fmt Attr PSize PFree DevSize PV UUID /dev/xvdc testvg1 lvm2 a- 5.00G 1020.00M 5.00G 2XEI4w-LmJi-iR3B-xXVU-XxK3-dfTf-WPZXF6
Now it is possible to see the PSize is equal to DevSize.
4. Now please perform any other normal operation with your LVM.