What I'm trying to do is symlinking a shared folder between my Mac and my Ubuntu VM.

The shared folders on the VM are going in /mnt/hgfs/.

On my Mac I symlink the directory (let's say macdirectory) to the shared folder sharedfolder so when I compile and put a file there, it follows to the VM directory where the application is running.

What I'm trying to do in my VM is this:

sudo ln -s ~/linuxdirectory /mnt/hgfs/sharedfolder

but then I get this error message:

ln: failed to create symbolic link '/mnt/hgfs/sharedfolder/linuxdirectory'

With my many attempts to make this symlink, I may have done bad links. This is the result of ls -la /mnt/hgfs/sharedfolder/

drwxr-xr-x 1  502 dialout  102 Jun 30 22:30 .
dr-xr-xr-x 1 root root    4192 Jun 30 23:01 ..
-????????? ? ?    ?          ?            ? linuxdirectory

Can't I use /mnt/ as a link?

| improve this question | | | | |

HGFS won't allow this. No matter what you do, symlinks are only allowed from the share to other places in the share. Other links will be like that broken file you made. Normally, the guest can create symlinks, but then it cannot follow them. If you add the line

sharedFolder<n>.followSymlinks = "TRUE"

then the guest will be allowed to follow symlinks already made, but then it loses the ability to create new ones.


| improve this answer | | | | |
  • Your first part is OK but your explanations on the VM manager make no sense as it is simply a symlink. – Julie Pelletier Jul 1 '17 at 3:28
  • A symlink is not a normal file, and its semantics are nonobvious in a shared VM dir. What would happen if the guest was Windows and the Mac host created a symlink in that directory? Windows has no clue how a *nix symlink works. Secondly, which side does the symlink point to? Does it point to the guest's internal VFS when seen on that side but the host's on that side? Does it point to the guest's or the host's always? You have a security hole every way. On further thought, it's probably less "VMM doesn't know" and more "VMM disallows." – HTNW Jul 1 '17 at 3:35
  • It's neither. In the current case, you simply end up with a symlink /mnt/hgfs/sharedfolder/linuxdirectory that points to the non-existing ~/linuxdirectory. This is obviously not what OP wanted as you mentioned in the first part of your answer, but it has no relevance to the VM. The closest I can see is that placing a symlink inside the VM's mount will not allow the VM to internally access the target, but that doesn't fit what you're saying either. – Julie Pelletier Jul 1 '17 at 3:40
  • The ln failed. Normally, if you attempt to make broken symlink, ln does not fail. The failure of ln points to something more fundamental than just an accidental argument flip. This more fundamental thing is the fact that the symlink is being made in a dir shared between a VM and its host, which would be horribly insecure if it were allowed. Additionally, the statement "you simply end up with a symlink /mnt/hgfs/sharedfolder/linuxdirectory that points to the non-existing ~/linuxdirectory " is false: the ls shows a broken file that cannot be stated properly. That's not a symlink. – HTNW Jul 1 '17 at 3:51
  • I'd bet that the filesystem simply doesn't allow symlinks. That still doesn't match your description. – Julie Pelletier Jul 1 '17 at 3:53

In my case, I am using Oracle VM and I had to allow the VM to make symlinks. Using VBoxManage in Windows, use this command:

VBoxManage setextradata VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARED_FOLDER 1

where VM_NAME is the name of your virtual machine, and the name of the SHARED_FOLDER (without path, I believe). If the command is successful, it doesn't return anything. If not, it returns an error.

| improve this answer | | | | |

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.