Skip to contentSkip to conversation

How to judge a vg is empty

DISCUSSION Liuhua Wang 1 participant 1 message Apr 23, 2015

lore
Share & tools
lore
#0 lore raw

Hi list,

I'd like to remove the limit of LVM RA that does not support an vg with no lvs, because it is not convenient while configuring the resource especially through wizard like hawk. The wizard has to be split into two parts.

First I would like to use this command.
vgdisplay vg_name | awk '/Cur LV/{print $3}'
If the Cur LV is 0 then look the vg as empty.

But as to ResourceAgent upstream says, it is not recommended to use any lvm commands in RA monitor/status function because of the execute time issue.

Then I suppose I can check the backup file.
grep "logical_volumes" /etc/lvm/backup/vg_name
If string "logical_volumes" is found in backup/vg_name it means this vg is not empty.

I want to know whether this is a reliable way to announce a vg empty or is there a better way? Thanks!

Best regards
Liuhua