2

I'm messing around with KVM and different storage options for sharing between virtual machines. I have an LVM volume group defined as a storage pool for libvirt. I've defined a volume and attached it to two test VMs as a virtio disk. Here's virsh dumpxml

<disk type='block' device='disk'> <driver name='qemu' type='raw'/> <source dev='/dev/kvm_storage/vm_shared'/> <target dev='vda' bus='virtio'/> <shareable/> <alias name='virtio-disk0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </disk> 

I can read/write files, but they do not stay in sync between the two virtuals unless I unmount then remount. Is this even supported?

1
  • I built I high availability system, albeit several years ago, using two machines sharing a volume group. Our caveat was that only one machine could import and make active the volume group at a time. Don't recall if the second could be made read only or not. I would suggest one serve via nfs or samba and the other use,mount as client. Commented Aug 7, 2013 at 11:38

3 Answers 3

3

You need an clustered file system.

I do not know what filesystem you are using. But with a standard file system this is not possible and has nothing to do KVM or LVM.

An other solution would be to use a network filesystem like nfs or cifs.

1
  • or use smb samba to be compatible with Windows VMs. Commented Mar 11, 2022 at 6:03
2

You have to use those levels :

On physical Host :

  • KVM level : second disk for VM marked as "Shared storage" in Virt-manager properties (only disk type "raw" is supported. qcow2 is not supported as "shareable" in vm disk edit screen and virt-manager will not allow you to click "apply" when you tick the "shareable" box)

On VMs :

  • level 0 : DLM (like disk logical management I think) # service dlm start ; Linux packages to install
  • level 1 : LVM management
  • level 2 : GFS2 filesystem formatted on your LVM logical volume
0

A disk used by a vm at the same time.Otherwise,the filesystem on the disk will be damaged! You can use NAS/NFS/SMB etc network filesystem to share files.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.