Vagrant was unable to mount VirtualBox shared folders
The Most Incorrect Error Message I Can Remember!
Vagrant was unable to mount VirtualBox shared folders. This is usually because the filesystem "vboxsf" is not available. This filesystem is made available via the VirtualBox Guest Additions and kernel module. Please verify that these guest additions are properly installed in the guest. This is not a bug in Vagrant and is usually caused by a faulty Vagrant box. For context, the command attempted was: mount -t vboxsf -o uid=1000,gid=1000 src /srv/src The error output from the command was: mount: /src/src: unknown filesystem type 'vboxsf'
Why is this message incorrect?
This is an error that I first encountered years ago and beat myself up for weeks over trying to debug the cause. I just came across the error again and felt that this should be noted by someone who is using a Linux host to run mounted virtualbox vms via shared and/or synced folders. There are issues with some virtualbox machines trying to share folders with a host that uses an encrypted drive. I encrypt my home directory, so this is an error I've seen pop up often when I try to work locally on the code with the contents shared with the vm.
The solution is to create a working folder outside of your home directory. Symlink your home directory's folder to point to where the code will actually live, and continue working as you intended.
As you can see, the "help" message above says absolutely nothing about the cause potentially being by an encrypted home directory. To verify it's an encrypted home directory, run the following commands:
- vagrant plugin install vagrant-vbguest
- vagrant reload
If the error persists after running those commands, then move the shared folder outside of the encrypted home directory and symlink to it from your vagrant directory. I have an unencrypted drive specifically for mounting such projects because I have encountered this plenty of times, but your best solution might vary.