User is unable to Extend the LVM file system which has a snapshot, Error "Snapshot origin volumes can be resized only while inactive: try lvchange -an
". The user has created a snapshot on non-root
LVM volume as shown below.
# lvcreate --size 100M --snapshot --name testsnap /dev/testVG/testLV Logical volume "testsnap" created
# lvs -a -o+devices LV VG Attr LSize Origin Snap% Move Log Copy% Convert Devices LogVol00 VolGroup00 -wi-ao 7.91G /dev/vda2(0) LogVol01 VolGroup00 -wi-ao 1.97G /dev/vda2(253) testLV testVG owi-a- 1.00G /dev/vdb1(0) testsnap testVG swi-a- 100.00M testLV 0.01 /dev/vdb1(256)
# vgs -a VG #PV #LV #SN Attr VSize VFree VolGroup00 1 2 0 wz--n- 9.88G 0 testVG 2 2 1 wz--n- 3.99G 2.89G
If the user tries to extend the filesystem with an associated snapshot, it would throw an error as shown below.
# lvextend -L +1G /dev/testVG/testLV Snapshot origin volumes can be resized only while inactive: try lvchange -an
The Solution
LVs with snapshot needs to be deactivated before extending/resizing since online resize of LVM partitions with the snapshot is not possible. Follow the steps outlined below:
1. Deactivate the LVM partition first and verify the current size of the LV.
# lvchange -an /dev/testVG/testLV
# lvs -a -o+devices LV VG Attr LSize Origin Snap% Move Log Copy% Convert Devices LogVol00 VolGroup00 -wi-ao 7.91G /dev/vda2(0) LogVol01 VolGroup00 -wi-ao 1.97G /dev/vda2(253) testLV testVG owi--- 1.00G /dev/vdb1(0) testsnap testVG swi--- 100.00M testLV /dev/vdb1(256)
2. Now perform the resize operation and verify the LV size again.
# lvextend -L +1G /dev/testVG/testLV Extending logical volume testLV to 2.00 GB Logical volume testLV successfully resized
# lvs -a -o+devices LV VG Attr LSize Origin Snap% Move Log Copy% Convert Devices LogVol00 VolGroup00 -wi-ao 7.91G /dev/vda2(0) LogVol01 VolGroup00 -wi-ao 1.97G /dev/vda2(253) testLV testVG owi--- 2.00G /dev/vdb1(0) testLV testVG owi--- 2.00G /dev/vdb1(281) testLV testVG owi--- 2.00G /dev/vdc1(0) testsnap testVG swi--- 100.00M testLV /dev/vdb1(256)
3. Next step is to resize the LVM snapshot associated with the LV.
# lvextend -L +100M /dev/testVG/testsnap Extending logical volume testsnap to 200.00 MB Logical volume testsnap successfully resized