How can a KVM guest access and Sharea Host LVM2 filesystem?

openijl

New Member
May 23, 2011
2
0
1
Hi there,

How can a KVM guest access (and Share) a locally-held Host LVM2 filesystem?

I don't want to simply make a virtual disk available. I want the guest KVM system to haveaccess to existing files on the filesystem.

I'm looking to run ClearOS in a KVM, but want it to have access to (and to share to CIFS clients) files held on a Promox host filesystem. (The filesystem would be created on an LVM2 volume, which would itself be created on a DRBD replicated device).

Many thanks!
Ian
 
Just create the logical volume, then add it to the guest - personally I'd just add it directly to the file in /etc/qemu-server/???.conf. The line would look something like this:

virtio1: /dev/mapper/volgroup0-lvname

then in the guest you should have the partition shared as /dev/vdb (note this is vdb, not vdb1 - it's a partition image, not a disk image). So you can mount it with

mount /dev/vdb /mnt

Works a treat, I do it all the time. Just be careful if you're writing to it, to only do so in one VM at a time - otherwise you really will mess things up.