Vagrant error : Failed to mount folders in Linux guest
Solution 1
The plugin vagrant-vbguest solved my problem:
$ vagrant plugin install vagrant-vbguest
Output:
$ vagrant reload
==> default: Attempting graceful shutdown of VM...
...
==> default: Machine booted and ready!
GuestAdditions 4.3.12 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Exporting NFS shared folders...
==> default: Preparing to edit /etc/exports. Administrator privileges will be required...
==> default: Mounting NFS shared folders...
==> default: VM already provisioned. Run `vagrant provision` or use `--provision` to force it
Just make sure you are running the latest version of VirtualBox
Solution 2
I found this issue addressed here vagrant issues. Two ways to do it:
-
Run this on guest (i.e. after you ssh into vbox via
vagrant ssh
)sudo ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions
Then run
vagrant reload
to correctly mount the folders. -
As @klang pointed out, update the VBoxGuestAdditions.iso file on your mac:
wget https://www.virtualbox.org/download/testcase/VBoxGuestAdditions_4.3.11-93070.iso sudo cp VBoxGuestAdditions_4.3.11-93070.iso /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
UPDATE (16may2014)
Since the iso is no longer available, you can use the 4.3.12 one (http://dlc.sun.com.edgesuite.net/virtualbox/4.3.12/VBoxGuestAdditions_4.3.12.iso)
note : the binary vbox4.3.12 for os X is not available at this time
Solution 3
I arrived at this page whilst looking for the same error message.
For me the cause was different: I had ran a yum update
on the system that installed a new kernel. The guest additions where out of date so it couldn't load them.
I rebuilt them with
sudo /etc/init.d/vboxadd setup
And a vagrant reload
later my guest was up and running again.
I'm just adding it here in case someone else gets here the same way I did.
Edit (Per KCD's comment):
It is possible that you get an error saying:
The headers for the current running kernel were not found
This can be resolved by installing kernel-devel
(yum install kernel-devel
)
Solution 4
Fix Step by step:
If you not have vbguest plugin, install it:
$ vagrant plugin install vagrant-vbguest
Run Vagrant
It is show a error.
$ vagrant up
Login on VM
$ vagrant ssh
Fix!
In the guest (VM logged).
$ sudo ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions
Back on the host, reload Vagrant
$ vagrant reload
Solution 5
Update February 2016
This took me hours to solve independently. Yes, this problem does still exist with latest Vagrant and Virtual Box installs:
△ vagrant -v
Vagrant 1.8.1
△ vboxmanage -v
5.0.14r105127
The symptoms for me were messages something like:
Checking for guest additions in VM... The guest additions on this VM do not match the installed version of VirtualBox!
followed by a failure to mount NFS drives.
1). Install the vagrant-vbguest
plugin.
Depending on version of Vagrant you are using, issue one of the following commands:
# For vagrant < 1.1.5
$ vagrant gem install vagrant-vbguest
# For vagrant 1.1.5+
$ vagrant plugin install vagrant-vbguest
Next, do vagrant halt
, followed by vagrant up
- chances are you still have issues.
2). ssh into your guest and setup a soft link to the correct version of Guest Additions (here, 5.0.14).
$ vagrant ssh
$ sudo ln -s /opt/VBoxGuestAdditions-5.0.14/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions
$ exit
$ vagrant reload
You should be all good. By default, the mounted drive on guest is at /vagrant
Final comment:
IF you still have problems related to mounting NFS drives, then here is a workaround that worked for me. I had a vagrantfile
with config something like:
Simply remove the mount type information, and slim down the mount_options settings so they work universally. Vagrant will now automatically choose the best synced folder option for your environment.
Related videos on Youtube
radu c
Updated on January 30, 2021Comments
-
radu c over 3 years
I have some issues with Vagrant shared folders, my base system is Ubuntu 13.10 desktop.
I do not understand why I have this error is something that is not right configured ? Is a NFS issue or Virtualbox Guest Additions ? I have tried with different many boxes but the same issue.
Failed to mount folders in Linux guest. This is usually because the "vboxsf" file system is not available. Please verify that the guest additions are properly installed in the guest and can work properly. The command attempted was: mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` /vagrant /vagrant mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` /vagrant /vagrant
Here is the complete process after
vagrant up
:$ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'u131032'... ==> default: Matching MAC address for NAT networking... ==> default: Setting the name of the VM: vagrant_default_1396020504136_46442 ==> default: Clearing any previously set forwarded ports... ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat default: Adapter 2: hostonly ==> default: Forwarding ports... default: 22 => 2222 (adapter 1) ==> default: Running 'pre-boot' VM customizations... ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Error: Connection timeout. Retrying... default: Error: Remote connection disconnect. Retrying... default: Error: Remote connection disconnect. Retrying... default: Error: Remote connection disconnect. Retrying... default: Error: Remote connection disconnect. Retrying... default: Error: Remote connection disconnect. Retrying... default: Error: Remote connection disconnect. Retrying... default: Error: Remote connection disconnect. Retrying... default: Error: Remote connection disconnect. Retrying... default: Error: Remote connection disconnect. Retrying... default: Error: Remote connection disconnect. Retrying... default: Error: Remote connection disconnect. Retrying... default: Error: Remote connection disconnect. Retrying... ==> default: Machine booted and ready! GuestAdditions versions on your host (4.3.10) and guest (4.2.16) do not match. * Stopping VirtualBox Additions ...done. Reading package lists... Building dependency tree... Reading state information... The following packages were automatically installed and are no longer required: dkms libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libfontenc1 libgl1-mesa-dri libglapi-mesa libice6 libllvm3.3 libpciaccess0 libpixman-1-0 libsm6 libtxc-dxtn-s2tc0 libxaw7 libxcomposite1 libxdamage1 libxfixes3 libxfont1 libxkbfile1 libxmu6 libxpm4 libxrandr2 libxrender1 libxt6 x11-common x11-xkb-utils xfonts-base xfonts-encodings xfonts-utils xserver-common xserver-xorg-core Use 'apt-get autoremove' to remove them. The following packages will be REMOVED: virtualbox-guest-dkms* virtualbox-guest-utils* virtualbox-guest-x11* 0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded. After this operation, 11.1 MB disk space will be freed. (Reading database ... 65615 files and directories currently installed.) Removing virtualbox-guest-dkms ... -------- Uninstall Beginning -------- Module: virtualbox-guest Version: 4.2.16 Kernel: 3.11.0-18-generic (i686) ------------------------------------- Status: Before uninstall, this module version was ACTIVE on this kernel. vboxguest.ko: - Uninstallation - Deleting from: /lib/modules/3.11.0-18-generic/updates/dkms/ - Original module - No original module was found for this module on this kernel. - Use the dkms install command to reinstall any previous module version. vboxsf.ko: - Uninstallation - Deleting from: /lib/modules/3.11.0-18-generic/updates/dkms/ - Original module - No original module was found for this module on this kernel. - Use the dkms install command to reinstall any previous module version. vboxvideo.ko: - Uninstallation - Deleting from: /lib/modules/3.11.0-18-generic/updates/dkms/ - Original module - No original module was found for this module on this kernel. - Use the dkms install command to reinstall any previous module version. depmod.... DKMS: uninstall completed. ------------------------------ Deleting module version: 4.2.16 completely from the DKMS tree. ------------------------------ Done. Removing virtualbox-guest-x11 ... Purging configuration files for virtualbox-guest-x11 ... Removing virtualbox-guest-utils ... Purging configuration files for virtualbox-guest-utils ... Processing triggers for ureadahead ... Processing triggers for man-db ... Reading package lists... Building dependency tree... Reading state information... dkms is already the newest version. dkms set to manually installed. linux-headers-3.11.0-18-generic is already the newest version. linux-headers-3.11.0-18-generic set to manually installed. The following packages were automatically installed and are no longer required: libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libfontenc1 libgl1-mesa-dri libglapi-mesa libice6 libllvm3.3 libpciaccess0 libpixman-1-0 libsm6 libtxc-dxtn-s2tc0 libxaw7 libxcomposite1 libxdamage1 libxfixes3 libxfont1 libxkbfile1 libxmu6 libxpm4 libxrandr2 libxrender1 libxt6 x11-common x11-xkb-utils xfonts-base xfonts-encodings xfonts-utils xserver-common xserver-xorg-core Use 'apt-get autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Copy iso file /usr/share/virtualbox/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso mount: block device /tmp/VBoxGuestAdditions.iso is write-protected, mounting read-only Installing Virtualbox Guest Additions 4.3.10 - guest version is 4.2.16 Verifying archive integrity... All good. Uncompressing VirtualBox 4.3.10 Guest Additions for Linux............ VirtualBox Guest Additions installer Copying additional installer modules ... Installing additional modules ... Removing existing VirtualBox DKMS kernel modules ...done. Removing existing VirtualBox non-DKMS kernel modules ...done. Building the VirtualBox Guest Additions kernel modules ...done. Doing non-kernel setup of the Guest Additions ...done. Starting the VirtualBox Guest Additions ...done. Installing the Window System drivers Could not find the X.Org or XFree86 Window System, skipping. An error occurred during installation of VirtualBox Guest Additions 4.3.10. Some functionality may not work as intended. In most cases it is OK that the "Window System drivers" installation failed. ==> default: Checking for guest additions in VM... ==> default: Setting hostname... ==> default: Configuring and enabling network interfaces... ==> default: Exporting NFS shared folders... ==> default: Preparing to edit /etc/exports. Administrator privileges will be required... nfsd running sudo: /usr/bin/exportfs: command not found ==> default: Mounting NFS shared folders... ==> default: Mounting shared folders... default: /vagrant => /home/me/Documents/Work/project/vagrant Failed to mount folders in Linux guest. This is usually because the "vboxsf" file system is not available. Please verify that the guest additions are properly installed in the guest and can work properly. The command attempted was: mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` /vagrant /vagrant mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` /vagrant /vagrant
My Vagrantfile configuration is :
# -*- mode: ruby -*- # vi: set ft=ruby : # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" personalization = File.expand_path("../Personalization", __FILE__) load personalization Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = $base_box config.vm.box_url = $base_box_url config.vm.hostname = $vhost + ".dev" config.hostsupdater.aliases = ["api." + $vhost + ".dev", "mysql." + $vhost + ".dev"] config.hostsupdater.remove_on_suspend = true # set auto_update to ture to check the correct # additions version when booting the machine config.vbguest.auto_update = true config.vbguest.auto_reboot = true config.vm.network :private_network, ip: $ip config.vm.synced_folder "../", "/srv/www/vhosts/" + $vhost + ".dev", type: "nfs" config.vm.provider :virtualbox do |v| v.customize ["modifyvm", :id, "--memory", 2048] v.customize ["modifyvm", :id, "--cpus", "1"] v.customize ["modifyvm", :id, "--cpuexecutioncap", "100"] v.customize ["modifyvm", :id, "--ioapic", "off"] v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] end config.vm.provision "shell" do |s| s.path = "vagrant-bootstrap.sh" s.args = $vhost + " " + $mysql_password + " " + $application_database end end
The Personalization file is :
# Name of the vhost to create $vhost = "project" # Use the Ubunut 32bit or 64bit $base_box_url = "http://cloud-images.ubuntu.com/vagrant/saucy/current/saucy-server-cloudimg-i386-vagrant-disk1.box" # VM IP $ip = "192.168.7.7" # Base box name $base_box = "u131032" # MySQL $mysql_password = "admin" $application_database = "project"
The following plugins are enabled in Vagrant:
$ vagrant plugin list vagrant-hostsupdater (0.0.11) vagrant-login (1.0.1, system) vagrant-share (1.0.1, system) vagrant-vbguest (0.10.0)
-
GusDeCooL about 7 yearsthis issue also happened on me after i update virtual box
5.1.20
. This kind make me worry every time i update my VM as this is not the first time :( -
Henrik about 7 years@GusDeCooL you might turn off auto update of the guest additions with
config.vbguest.auto_update = false
in the Vagrantfile
-
-
radu c about 10 yearsI have fixed the issue concerning
sudo: /usr/bin/exportfs: command not found
by setting a symlink to real path using the commandsudo ln -s /usr/sbin/exportfs /usr/bin/exportfs
, however the error aboutFailed to mount folders in Linux guest
persist even after this. -
Nirmal about 10 yearsThanks! For some reason, this is mentioned in too few places.
-
roborourke about 10 yearsDude thank you so much for this answer! Total life saver
-
d4nt about 10 yearsYou may just need to do vagrant reload afterwards to re-mount the shared folders
-
Stoutie about 10 years@Nirmal The reason it's not mentioned is probably because it should not be necessary, it's a bug, and will hopefully be fixed soon and therefore not need documentation. That said, I'm very disappointed that upgrading Vagrant/VirtualBox breaks things. Doesn't seem they are sticking to SemVer or regression testing is not sufficient.
-
Jason Austin about 10 yearsAnyone know a way to include this as part of the VagrantFile so that it executes prior to mounting the drives?
-
klang about 10 years@JasonAustin github.com/mitchellh/vagrant/issues/3341
wget https://www.virtualbox.org/download/testcase/VBoxGuestAdditions_4.3.11-93070.iso; sudo cp VBoxGuestAdditions_4.3.11-93070.iso /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
.. after that, you have business as usual. -
Lucas Serafim about 10 yearsJust a heads up, this will work on your vbox machine, so
vagrant ssh
before you use it. -
warantesbr about 10 yearsThank you very much @klang! This seems to be the best solution. @kenzie should update his answer to your comment. Or maybe you should move it to another answer. Thanks again.
-
beltorak about 10 years@JasonAustin: yes, install vagrant-vbguest plugin (this makes sure the guest additions and the host vbox versions are in sync), add snippet to Vagrant file to override and extend the default installer. See github.com/dotless-de/vagrant-vbguest and pastebin.com/7t8seM6m for what I did. I'm still experimenting with it, I keep having weird issues :-/
-
tsusanka about 10 yearsIn case you are on linux I guess you have to copy the file to
/usr/share/virtualbox/VBoxGuestAdditions.iso
. However I did not test it! -
Kevin Meredith about 10 yearsUsing a
Win 7
box withVagrant 1.3.5
andVirtualBox 4.3.10
, answer #1 did not work for me. I still got theunable to mount ...
errors -
iheggie about 10 yearsFrom what I have seen, vagrant-vbguest is correctly updating the VM to that the latest (4.3.10) GuestAdditions - unfortunately the latest GuestAdditions has a bug for linux guests.
-
iheggie about 10 yearsUnder a linux host use
sudo cp VBoxGuestAdditions_4.3.11-93070.iso /usr/share/virtualbox/VBoxGuestAdditions.iso
. You will also have to setconfig.vbguest.auto_update = false
in yourVagrantfile
if you use thevagrant-vbguest
plugin to avoid it repeating the update on everyvagrant up
. -
Pat K about 10 yearswhich is what I'm doing since they've taken down that download link
-
colinhoernig about 10 yearsThe recommended fix is option one, as originally posted here. The URL to the ISO file in option two is no longer valid and throws a 404.
-
mkirk almost 10 yearsI am using the vagrant-vbguest plugin, but this did not fix anything for me until I updated to VirtualBox-4.3.12-9.
-
Rixhers Ajazi almost 10 yearsThis is the only thing that fixed it for me. After I did this then the guests VboxAdditions updated, and matched my host. And all we fine without a hitch. I just have to maintain equal versions on both guest and host. Thanks for the pointer @karlingen
-
Yamiko over 9 yearsI started having this issue after installing the plugin. uninstalling it is not fixing the issue.
-
karlingen over 9 years@Yamiko make sure you are running the latest version of Virtualbox
-
Phil over 9 yearsThis happens every time I start a new box. I have looked at this post hundreds of times. Thank you so much for this!
-
Szymon Stepniak over 9 yearsThis solved my problem. I faced it when I've upgraded my Ubuntu 12.04 LTS to 14.04 LTS and reload the VM. After that my shared folders haven't been mounted properly. I use VBox 4.3.16, my guest used 4.2.0 version of GuestAdditions so it got upgraded after installing this plugin. After installing and upgrading GuestAdditions and reloading the VM, shared folders got mounted successfully. Thanks!
-
Thrill Science over 9 yearsMake sure you have the latest VirtualBox and use vagrand-vbguest is the best advice.
-
feoh over 9 yearsIMO the vbguest plugin answer below is vastly superior to this approach.
-
austin over 9 yearsThanks. I forgot that I ran a
yum update
. I'm leaving this comment so that Future Austin will find it when this happens again. -
skift over 9 yearsAnd I ran apt-get update in ubuntu, leaving a comment for future skift when this happens again :-)
-
bbrame about 9 yearsNote that this bug was fixed in VirtualBox 4.3.12.
-
Yordan Georgiev about 9 yearsjee I would have saved some 20 hours of googling , re-configuring etc. by issuing this very one one-liner ... Where is your "just buy me a beer button" ...
-
loïc m. about 9 yearsPresent and future Loïc just thanks you :) (forgot I ran a
yum update
too) -
mpemburn almost 9 yearsThis info may be out of date. This worked: vagrant plugin install vagrant-vbguest
-
Ryan Gross almost 9 yearsFor those on Windows, if prompted for your username, do not include the domain.
-
terbooter almost 9 yearsI have exactly same bug in VirtualBox 4.3.26
-
KCD almost 9 yearsBeware, this plugin can cause an almost identical issue if you let it
config.vbguest.auto_update = true
(default) github.com/dotless-de/vagrant-vbguest/issues/141 -
KCD almost 9 yearsIt may fail saying
The headers for the current running kernel were not found
and ask you toyum install kernel-devel
which works -
grant sun over 8 yearsI faced the same issue by running 'yum update' . Now I fixed it with your command. Thank you.
-
Adam Parkin over 8 years4.3.28 for me, and same problem.
-
Rodrigo over 8 yearsAnd when the file
/usr/lib/VBoxGuestAddition
does not exists?? -
Mateusz Odelga over 8 yearsI think that is the best and most transparent solution
-
JDS over 8 yearsI also had to install gcc to get this to work. To sum up: 1)
yum install kernel-devel-$(uname -r)
and 2)yum install gcc
; and finally, exit VM and dovagrant reload
. This was on a Centos 7 Vagrant box (bento/centos-7.1) -
Jerrod over 8 yearsInstead one should run
vagrant reload
. -
Ryan B. over 8 yearsI should have read this answer sooner! I've been googling around for an answer to this issue and have come across this stackoverflow question but only read and tried the chosen answer. I moved on after it failed for me. Hours later and a second run in on this question here I read the next popular answer and sure enough it fixed it for me. Perhaps a year or so ago the current chosen answer was the correct one. However today with newer versions of Virtualbox and vagrant I believe this answer is much more relevant and should be given the green check mark instead.
-
Sarcastron over 8 yearsThank you so much. This was my issue as well.
-
Alexander about 8 yearsSolved the issue here! VirtualBox 5.0.14 and Vagrant 1.8.1 on 64-bit Arch Linux. Thanks!
-
CargoMeister about 8 yearsMight want to note that 'vagrant destroy' blows away your VM, with anything you have configured/installed inside it, unless I'm mistaken.
-
Phil Gyford about 8 yearsThanks for this... your
vagrantfile
config is missing, just before the final paragraph though - any chance you could add it back? -
Tony Ennis about 8 yearsThis still does not work for me. I downloaded a new Vagrant. vboxmanage already showed the version above. The soft link the OP recommends was already there.
-
Philip Pryde about 8 years5.0.14r105127 for me and same issue
-
Marco Aurélio Deleu about 8 yearsI ran this and even though I got an error message, my problem was solved. While installing the Guest Additions, vagrant gave me the following message:
An error occurred during installation of VirtualBox Guest Additions 5.0.14. Some functionality may not work as intended.
-
J.Z. about 8 yearsThis worked, but with Fedora 22 I had to
vagrant ssh
into the box and dosudo ln -s /etc/dnf/dnf.conf /etc/yum.conf
, as Fedora switched from yum to dnf. With that, things ran to completion (I think!). Thanks @dadaso. -
Radu almost 8 yearswhat about Works without Additions (for Mac OS X) in virtualbox.org/wiki/Guest_OSes - it is a bit confusing
-
Andrzej Rehmann almost 8 yearsThis answer is out of date people!
-
Amedee Van Gasse almost 8 yearsCorrect, a shared folder in
/
is not allowed in my version of Vagrant either (1.8.1) -
Aboelseoud almost 8 yearsWhere is your Vagrantfile config? It's missing from your answer.
-
JDS almost 8 yearsNote: Some of the below answers state one has to manually symlink /opt/VBoxGuestAdditions to-<version> to /usr/lib/VBoxGuestAdditions. For me, in VBox v5.0.20 r106931 (June 2016) and Vagrant 1.7.4, Vagrant took care of figuring out that the VBox additions didn't match once I installed the vagrant-vbguest plugin
-
Rick over 7 yearsThis was working for me, until I saw this warning message
Installing Virtualbox Guest Additions 5.0.30 - guest version is 5.0.6
. After this,vagrant up
wasn't even finishing its job. So I had to uninstall the plugin with the commandvagrant plugin uninstall vagrant-vbguest
. -
Eric Hepperle - CodeSlayer2010 about 7 yearsIt is 2017 for me and still having this error. Your fix looks promising. I will try and report back.
-
Eric Hepperle - CodeSlayer2010 about 7 yearsDid not work for me in February 2017. Creating new post to request help. This has been a frustrating problem since 2013.
-
Glance about 7 yearsWorked for me on Valentine's Day 2017 ... :)
-
Hà Link about 7 yearsI follow this and there is still a problem with me cause I use Virtual Box version 5.1.16 while the host claim the virtual box version 5.0.32 :-ss So in order to use Vagrant right at the time, use virtual box 5.0.32
-
Teddy about 7 yearsI am not a Vagrant user, but I had this same issue on a Fedora Core guest running on a OSX Host. I think the problem is that the location of
mount.vboxsf
was changed, but the installer is symlinking to the old location. -
GusDeCooL about 7 yearssurprise! updating VBox to latest version give me this error and bring me to this page
-
Jamin about 7 yearsThis was the only and quickest solution for me. Was having issues on a "Ubuntu precise 64 VirtualBox" image from here. VirtualBox 5.1.2 and Vagrant 1.8.5 on Windows.
-
Henrik about 7 yearsDid have exactly the same problem. Ignore the warning about not matching versions of guest and host, and turn of auto update.
-
Max Smolens about 7 yearsThis is a confirmed bug in guest additions 5.1.20: virtualbox.org/ticket/16670
-
dusan almost 7 yearsWorked for me in May/2017!
-
Patrick almost 7 yearsWorked for me in June 2017.
-
chathun over 4 yearsMake sure disable or allow your firewall and antivirus software to allow network transaction I spent many hours to get this :)