For the last two days I tried to share a folder between the host and a guest virtual machine, both running the latest Debian Stretch.
The folder I wish to share is owned by the
mygroup on the host hard drive (
/srv/sharedfolder). Since the guest is a LAMP server running Nextcloud I wish to access and write to this shared folder as
So I created a libvirt’s filesystem with the
Default driver and
Mapped mode :
<filesystem type='mount' accessmode='mapped'> <source dir='/srv/sharedfolder'/> <target dir='sharedfolder'/> <alias name='fs0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </filesystem>
Mapped seems to be the good choice as written at suse.com :
The user credentials and the client-user’s credentials are saved in extended attributes. This model is recommended when host and guest domains should be kept completely isolated.
On the host side :
- user and group at
/etc/libvirt/qemu.confare set to
- the shared folder has been “chmoded” with
On the guest side :
- the mountpoint of the shared folder belong to
fstab (with kernel.org as reference) :
sharedfolder /srv/sharedfolder 9p trans=virtio,version=9p2000.L,rw,nofail 0 0
So far, I can read and write the shared folder as
www-data, so the mission seems to be accomplished.
But when a new file is created on the host file by
myuser within the shared folder the new file is seen as owned by
myuser:myuser by the guest (whereas i expected it would be owned by
So what should I do ? Thanks in advance.