0

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 myuser, group 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 www-data:www-data.

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.conf are set to myuser and mygroup
  • the shared folder has been "chmoded" with chmod 775

On the guest side :

  • the mountpoint of the shared folder belong to www-data:www-data
  • 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 www-data:www-data).

So what should I do ? Thanks in advance.

  • What setup have you done on the host side to ensure the client-side UID/GID xattrs will be written? – womble Mar 25 at 3:04
  • As the humble home-sysadmin I am, I may not totally understand your question. I tried to apply the following xattrs to the shared folder (same command on both side), but without succes : setfacl -R -m d:u:www-data:rw-,g:www-data:rw- /srv/sharedfolder (posixacl has also been added to the fstab option of course) – chuugar Mar 25 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.