I am having a hard time configuring a shared folder with write permissions inside the guest. My special case is that the shared folder references a CIFS network share mounted on the host.
Network share (and shared folder)
/media/nas/temp is mounted via
sudo mount -t cifs -o username=dave,vers=3.0,uid=dave,gid=libvirt-qemu //nas/temp /media/nas/temp
Permissions from host perspective:
dave@host:~$ ll /media/nas/ drwxr-xr-x 2 dave libvirt-qemu 0 Dez 6 15:36 temp/
/media/nas/temp on host) is mounted via:
sudo mount -t 9p -o trans=virtio,version=9p2000.L /temp /media/temp
Permissions from guest perspective (64055 is the uid of
libvirt-qemu group of the host):
dave@guest:~$ ll /media drwxr-xr-x 2 dave 64055 0 dec 6 15:36 temp/
A write operation like creating a new file triggers following error:
dave@guest:~$ touch /media/temp/myfile.log touch: cannot touch '/media/temp/myfile.log': Permission denied
I also tried
dir_mode mount options from the host:
sudo mount -t cifs -o username=dave,vers=3.0,uid=dave,gid=libvirt-qemu,\ file_mode=0777,dir_mode=0777 //nas/temp /media/nas/temp
New permissions from host perspective:
dave@host:~$ ll /media/nas drwxrwxrwx 2 dave libvirt-qemu 0 Dez 6 15:36 temp/
Curiously, now I get a different error:
dave@guest:~$ touch /media/temp/myfile.log touch: cannot touch '/media/temp/myfile.log': Operation not supported
The host can write to
From within the guest, I could mount via CIFS directly successfully (same credentials) - but that is not possible in my current environment.
I am also able to mount a local host folder (like
/home/dave/Downloads/qemu-test, which has the exact same permissions, and write to it. Permissions in this case were:
dave@host:~$ ll ~/Downloads/ drwxrwx---+ 2 dave libvirt-qemu 4096 Dez 6 17:25 qemu-test/
Why does it make a difference, if I want to share a network or local folder via
mount -t 9p? As shown, the permissions should be the same and it shouldn't matter for the guest, what kind of mountpoint is shared (?).
Has anybody managed to do write a shared folder mounted as network share from host (if yes, how)?
- follow-up post of How to use QEMU/KVM virtual machine disk image on SMB/CIFS network share: Permission denied
Similar posts, which are about sharing a local folder: