Wednesday, May 26, 2010

Aggressive LVM

So I ran into an interesting issue that I hadn't seen in quite some time. I've got a server running KVM. I use the Virtio driver and logical volumes to hold the OS and Data disks for each VM.

Every time I used the lvm tools on the hypervisor, I was seeing random vgs, pvs and lvs. It took me a second to noodle out the problem.

LVM was picking up the guest volume groups and activating them. For instance, many of my VMs have a data volume. Those were getting picked up and activated OUTSIDE of the vm because of the LVM scanning filter.

I know at one point, the default filter only scanned hd.* and sd.* as valid block devices but it looks like the default filter is now:

filter = [ "a/.*/" ]

which makes everything in /dev a valid target for scanning and activating.

Being that this particular box is 1U with a single hardware raid array, I knew that the only valid block devices would be /dev/sd.

I changed the filter line to this:

filter = [ "a|/dev/sd.*|", "r/.*/" ]

A quick vgscan -vvvv showed me that my guest volumes were no longer valid targets:

#filters/filter-regex.c:172 /dev/ajc-dd-dmzvirt1/isolv: Skipping (regex)
#label/label.c:160 /dev/sda5: lvm2 label detected
#filters/filter-regex.c:172 /dev/ajc-dd-dmzvirt1/vdisk-itgweb1: Skipping (regex)

No comments: