简体   繁体   中英

Is there a way to share host (ubuntu) file system with guest (centos 7)?

I am trying to use virsh and domain xml to launch a Centos 7 guest from ubuntu 16.04 LTS host. The "filesystem" node that i am using in domain xml is as below:

    <filesystem type='mount' accessmode='passthrough'>
        <driver type='path' wrpolicy='immediate'/>
         <source dir='/opt/test'/>
         <target dir='testlabel'/>
    </filesystem>

With the above config, "testlabel" is not visible in the guest and hence i am not able to mount it. Is there anything that i am missing?

I tried to have 9p modules in guest but they don't seem to be available in centos 7.

I do not want to use network based file sharing like NFS or glusterfs either.

RHEL-7 (and thus CentOS-7) explicitly does not support the 9p filesystem. It is disabled in guest kernel builds and also disabled in QEMU builds for RHEL hosts. The reason is that 9p support in QEMU has been largely unmaintained upstream and the QEMU community doesn't have confidence its is security or performance.

If you want to share filesystem locations, pretty much your only choice is to use a traditional network filesystem, whether NFS, SAMBA, or something tunnelled like SSHFS.

Work is ongoing upstream to support a new technology called virtio-vsock, which will allow running NFS-over-vsock, bypassing the need for networking - think of it as akin to NFS over UNIX sockets. This is not ready for use yet though, so not possible for an Ubuntu/RHEL-7 pair.

Use for the guest (CentOS 7) the kernel from the CentOSPlus repository Wiki CentOSPlus . The CentOSPlus kernel has the 9p file system support build in. You can install the "kernel-plus" kernel with

yum --enablerepo=centosplus install kernel-plus

Start the guest with the "kernel-plus" kernel and

mount -t 9p -o trans=virtio {sharetarget} {mountpoint}

works. I use it this way on CentOS 7 guest systems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM