Vagrant was unable to mount VirtualBox shared folders
Update
Fixed in VirtualBox 5.1.22.
(https://www.virtualbox.org/ticket/16670)
Original answer
In my case a symlink inside the VM was wrong.
Log into the VM:
$ vagrant ssh
Then:
$ ls -lh /sbin/mount.vboxsf
lrwxrwxrwx 1 root root 49 Apr 19 14:05 /sbin/mount.vboxsf -> /opt/VBoxGuestAdditions-5.1.20/other/mount.vboxsf
This link is broken. When you look inside /opt/VBoxGuestAdditions-5.1.20/ you see that the subfolder "other" doesn't exists.
This line fixes that:
$ sudo ln -sf /opt/VBoxGuestAdditions-*/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf
Now logout of the VM:
$ exit
And check if it works for you:
$ vagrant reload
But i can't fix the link because /sbin/mount.vboxsf does not exist inside my box!
If the link /sbin/mount.vboxsf does not exists in the first place, than the VBoxGuestAdditions couldn't be installed. This can happen if you have not downloaded the matching VirtualBox Extension Pack after you updated VirtualBox (v5.2.18 and up should download it automatically during Virtualbox updates). You can do that now:
- Halt all your running VMs.
- Open the VirtualBox program.
- Start the download of the VirtualBox Extension Pack and install it.
- If you are not being asked if you want to download the VirtualBox Extension Pack, open ->File ->Check for Update, to trigger the download dialog.
If there was no update for the VirtualBox Extension, than it's possible the VBoxGuestAdditions can't be installed because the installer shows a message and the vagrant plugin vbguest can not prompt an answer (this is "fixed" in vbguest v0.15.0). You can see that in the output of "vagrant up". There should be a line similar to this one:
Do you wish to continue? [yes or no]
If that is the case you can run the installer manually. To do so, start the box:
$ vagrant up
Then trigger vbguest to try the installation again but leave the VBoxGuestAdditions ISO mounted afterwards:
$ vagrant vbguest --do install --no-cleanup
Log into the box:
$ vagrant ssh
Ran the installer manually:
$ sudo /mnt/VBoxLinuxAdditions.run
A last hope: DIY!
If nothing of the above worked, try to install the guest additions manually:
cd /opt
sudo wget -c http://download.virtualbox.org/virtualbox/5.1.28/VBoxGuestAdditions_5.1.28.iso -O VBoxGuestAdditions_5.1.28.iso
sudo mount VBoxGuestAdditions_5.1.28.iso -o loop /mnt
sudo sh /mnt/VBoxLinuxAdditions.run
Vagrant Error: Unable to Mount VirtualBox Shared Folders (Guest Additions, vboxsf)
This problem is solved in VirtualBox 5.1.18.
Vagrant - How can I mount the virtualbox shared folder? (vboxsf not available)
It worked with 5.1.18 for me.
https://www.virtualbox.org/wiki/Changelog 5.1.18 fixed the following seemingly relevant issues:
Shared Folders: fixed case insensitive filename access (5.1.16
regression; Windows guests only; bug #16549)Shared Folders: fixed
access to long paths (5.1.16 regression; Windows guests only; bugs14651, #16564)
Vagrant was unable to mount VirtualBox shared folders. ERROR: INVALID ARGUMENT
Had the same exact error as you after making my second vagrant project - specifically after changing my public_network
setting.
mount -t vboxsf -o uid=1000,gid=1000,_netdev vagrant /vagrant
The error output from the command was:
/sbin/mount.vboxsf: mounting failed with the error: Invalid argument
At I also tried several solutions from people's answers like the one mentioned here and updated my VirtualBox.
I'm not really sure how mine works but here's what I did:
I logged into the VM (vagrant ssh
) and installed the guest additions manually
cd /opt
sudo wget -c
http://download.virtualbox.org/virtualbox/6.1.26/VBoxGuestAdditions_6.1.26.iso O VBoxGuestAdditions_6.1.26.iso
And then tried:
sudo mount VBoxGuestAdditions_5.1.28.iso -o loop /mnt
sudo sh /mnt/VBoxLinuxAdditions.run
But I got an error saying something like permission denied or no directory.
So I reload vagrant (vagrant reload
), but the error still occurred. However, I still continued trying something else, so I thought maybe I should install the vbguest plugin and did this:
vagrant plugin install vagrant-vbguest
That removed the error for me after reload but when I logged into vagrant again, I still can't see my shared folders so I halted my vb and run provision:
vagrant up --provision
Then I got a message which said that there was an error while executing VBoxManage
so on and so forth. So I paused all running machine in my VB, closed all running VB apps in my desktop, and run the command:
vagrant destroy
After recreating vagrant vagrant up
, everything miraculously worked! I can now navigate to my shared folders' directory.
I'm still in the process of learning vagrant so I can't really explain what actually happened in my machine but I hope this can somehow be of help to you or to someone who have the same issue.
Unable to mount files in Vagrant
To the vagrant problem:
By default Vagrant mounted the folder of host Vagrant file to '/vagrant'. Test the output of 'ls -l /vagrant' if the basic file system mount works.
The 'ls' command should show your Vagrantfile as a minimum in '/vagrant'.
If the Vagrantfile is visible in the virtual machine basically the mount works with vagrant.
host.vm.synced_folder "salt/", "/srv/salt"
host.vm.synced_folder "pillar/", "/srv/pillar"
It seem you mount your additional folder relative to your Vagrantfile. In that case you can modify your VM internally to link them to the desired dest folder.
You can do that in the provision state of your VM for example.
# Vagrantfile snippet
config.vm.provision "shell", inline: <<-SHELL
ln -s /vagrant/salt /srv/salt
ln -s /vagrant/pillar /srv/pillar
SHELL
Maybe this file are not available at provision time then run them as one time task after your first login or put something similar to /etc/rc.local of your VM
Vagrant unable to mount shared folders
If you are using VirtualBox 5.1.16, there have been similar issues reported. It looks like downgrading to 5.1.14 has solved this for most of them. You could give it a try.
Symbolic links and synced folders in Vagrant
Virtualbox does not allow symlinks on shared folders for security reasons. To enable symlinks the following line needs to be added to the vm provider config block in the Vagrantfile:
config.vm.provider "virtualbox" do |v|
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end
Additionally, on windows vagrant up needs to be executed in a shell with admin rights.
No workarounds necessary.
Vagrant unable to mount synced folder on linux guest -- :Protocol Error
I managed to fix this problem by removing a symlink that was being created as a part of the provisioning process:
/home/vagrant/vagrant --> /vagrant
I do not quite understand how this symlink could have caused the problem I was having, but removing it was definitely the solution.
Related Topics
Can't Sample Hardware Cache Events with Linux Perf
Unix/Linux Ipc: Reading from a Pipe. How to Know Length of Data at Runtime
Where Is G_Multi Configured in Beaglebone Black
What's The Advantage of 3G/1G Vm Split ? 32Bit Linux Kernel
Reading Kernel Memory Using a Module
Sort a File Based on a Column in Another File
Linux + Find Word in File Under Directory But Quickly
How to Cancel Command in Grunt Shell
How to Selectively Create Symbolic Links to Specific Files in Another Directory in Linux
Caputre Opengl Window in X11 with Fast Framerate - Possible
Socket Send Concurrency Guarantees
Installing New Version of Python on Debian Linux Server
Linux: How to Check The Largest Contiguous Address Range Available to a Process
.Net Core 3.1 Deploy on Centos 7