在Ubuntu上使用KVM在hostOS和VM之间共享Ocfs2卷

我试图在Ubuntu Oneiric Server(3.0内核)上安装ocfs2。 我在主机上分享一个来自VG的LV。 HostOS是Ubuntu Lucid(也是在3.0内核上)。

我可以在两台KVM之间共享卷上的ocfs2分区。 虽然我不能共享hostOS和VM之间的分区

我只能在hostOS上安装分区,但是一旦我尝试在其中一个KVM上挂载分区,我就得到:

(o2hb-A72309E287,1395,1):o2hb_check_last_timestamp:576 ERROR: Another node is heartbeating on device (dm-4): expected(2:0xb88208e59655bc4f, 0x4f2d4275), ondisk(0:0x0, 0x0) [22085.518632] ocfs2: Unmounting device (252,4) on (node 2) 

在syslog中。

这些卷在VM xml文件中定义为:

 <disk type='block' device='disk'> <driver name='qemu' type='raw'/> <source dev='/dev/datastore/test'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </disk> 

而存储池被定义为:

 <pool type="logical"> <name>datastore</name> <target> <path>/dev/datastore</path> </target> </pool> 

我用这个LV创build了分区的设备节点:

 kpartx -av /dev/datastore/test 

其中创build了/ dev / mapper / datastore-test1,然后我尝试挂载。

在KVM虚拟机和hostOS之间共享ocfs2卷主要是不可能的,还是我做错了什么?

我会回答我自己的问题,以防有人来到这里有相同的问题:

我的ocfs2和VMconfiguration是好的。 问题是我在/ dev / vda(在VM中)直接创build了一个ocfs2卷。

然后,问题是虚拟机看到一个物理分区与ocfs2分区,但hostOS看到一个LVM卷与ocfs2分区。

解决方法是在虚拟机中创build一个pv / dev / vda,然后在其上创build一个VG和一个LV。 然后将LV格式化为ocfs2。

这个嵌套的VG可以在hostOS中看到,并且可以挂载

所以VG布局是:

  vg:datastore --lv:test --vg:vmtest --lv:vmvolume 

在hostOS和VM上,可以将卷挂载为/ dev / vmtest / vmvolume