How to identify which Volume Group is active in LVM
The way to check the status of VG is: lvs or lvdisplay. vgchange performs operation on underline LV, it activates or deactivates the number of LVs in that volume group.
If there are no LVs in particular VG, the VG activation or deactivation, both will return the same result and this operation doesn’t take any effect or make sense:
# vgchange -ay testVG
0 logical volume(s) in volume group "testVG" now active
# vgchange -an testVG
0 logical volume(s) in volume group "testVG" now active
The testVG which has been created does not contain any LVs in it and hence it returns the same result on both operation.
If there is no LV in VG, it doesn’t matter whether the VG being active or deactivate. Check out following example where I have 1 LV created in VG and the output changes:
# lvcreate -L +1G -n testLV testVG
Logical volume "testLV" created
# vgs -a
VG #PV #LV #SN Attr VSize VFree
VolGroup00 2 2 0 wz--n- 11.84G 0
testVG 1 1 0 wz--n- 2.00G 1020.00M
# lvs -a
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 9.88G
LogVol01 VolGroup00 -wi-ao 1.97G
testLV testVG -wi-a- 1.00G
# vgchange -an testVG
0 logical volume(s) in volume group "testVG" now active
# vgchange -ay testVG
1 logical volume(s) in volume group "testVG" now active <---
# vgchange -an testVG
0 logical volume(s) in volume group "testVG" now active
You could use lvs command to verify whether or not the VG has been inactivated. If you could see the fifth bits of lv_attr is “-”, then it indicates the vg has been deactivated successfully. on the contrary, if you see the fifth bit of lv_attr is “a”, it indicates the vg is in active status.
If VG is deactivated using “vgchange -an VGNAME” command then you will not see /dev/VGNAME device file.