2

I have this QEMU virtual machine running Debian Stretch, inside a host also running Debian Stretch. The guest mounts a host directory via VirtIO and 9p:

Virtual Machine Manager, Filesystem settings:

  • Mode: Mapped
  • Source path: /host/username/Projects
  • Target path: host-projects

Mounting on the host works:

sudo mount -t 9p -o rw,trans=virtio host-projects /guest/username/Projects

Writing to this directory, however, has proved difficult. I had to

chgrp -R libvirt-qemu /host/username/Projects

on the host in order to be able to write to the directory in the guest, but all the files I write inside the guest then belong to not just group but also user libvirt-qemu on the host.

I want those files to be mine.

How can I configure the host ownership? (Short of running qemu-system-x86_64 under my user id; or having cron chown -R username.libvirt-qemu /host/username/Projects every 2 minutes.)

  • The sad truth is, 9p lacks an id-mapping facitily. The uids and gids in the guest must match those in the host. I worked around the issue by doing exactly that: creating a user / group combo in the guest that has identical ids to the one I use outside. You also need to specify a more recent protocol revision as a mount option (e. g. ``version=9p2000.L) because the original 9p filesystem didn’t support ownership at all. – phg Oct 26 '18 at 6:35

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.