1

I have folder on host machine which have symlinks to another device. Like this

$ ls -all ~/folder_to_share
...
file1
file2
linked_dir -> /mnt/bdrive/real_dir/
...

I setup QEMU virtual machine via libvirt and vagrant-libvirt. And also setup sharing folder which is mapped to host dir ~/folder_to_share using VirtFS (9p protocol).

I want my virtual machine to walk inside shared dir and follow symlinks as it is real directory. Is it possible or I should switch to another protocol?

P.S. Part of vagrant-libvirt config:

config.vm.synced_folder "~/folder_to_share/", "/home/vagrant/shared_folder", type: '9p', owner: 1000
2

I had solved it long time ago with bind mounts. You could do remove the symlink and replace it with bind mount:

mkdir /symlink/to/replace mount -o bind /src/dir /symlink/to/replace

But when I tried it, I seen that "diod" 9p server skipped bind mounts unconditionally. So I had to patch it.

NOTE: Plan9 and it's neighbor projects generally protest against of many "bad practice" things like dynamic linking or symlinks. It's probably normal for them not to support these, even in other environments. So if you have a directory full of symlinks to other places, you will end up patching the 9p server software.

  • 1
    What do you think: is it wise to switch to NFS instead? – petRUShka Oct 30 '15 at 9:59
  • 2
    Well, NFS considered another side of evil. You may even see that from various man pages that often list exceptions from rules specially for NFS. As from my own experience with Linux, I do not recommend it. It's hard to remember how many times it broke natural assumptions people expect from any filesystem functions when they applied to NFS. I still recommend to proceed with 9p or even cifs (if installing samba server is not a hard task, not embedded platform etc., it even supports symlinks), but not NFS. The problem is: Linux still has no good network filesystem to stick to. – user140866 Oct 30 '15 at 10:26

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.