284

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)
radu c
  • 4,138
  • 7
  • 30
  • 45
  • this 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 :( – GusDeCooL Apr 27 '17 at 01:32
  • @GusDeCooL you might turn off auto update of the guest additions with `config.vbguest.auto_update = false` in the Vagrantfile – Henrik Apr 27 '17 at 16:10

22 Answers22

360

The plugin vagrant-vbguest GitHub RubyGems 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

Flimm
  • 136,138
  • 45
  • 251
  • 267
karlingen
  • 13,800
  • 5
  • 43
  • 74
  • I am using the vagrant-vbguest plugin, but this did not fix anything for me until I updated to VirtualBox-4.3.12-9. – mkirk May 21 '14 at 20:48
  • 5
    This 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 – Rixhers Ajazi Jun 06 '14 at 17:31
  • 1
    I started having this issue after installing the plugin. uninstalling it is not fixing the issue. – Yamiko Aug 28 '14 at 19:45
  • @Yamiko make sure you are running the latest version of Virtualbox – karlingen Sep 29 '14 at 12:01
  • This 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! – Szymon Stepniak Oct 10 '14 at 07:17
  • Make sure you have the latest VirtualBox and use vagrand-vbguest is the best advice. – Thrill Science Nov 05 '14 at 01:22
  • 14
    jee 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" ... – Yordan Georgiev Apr 09 '15 at 17:00
  • 1
    Beware, this plugin can _cause_ an almost identical issue if you let it `config.vbguest.auto_update = true` (default) https://github.com/dotless-de/vagrant-vbguest/issues/141 – KCD Jun 24 '15 at 21:53
  • I 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. – Ryan B. Dec 09 '15 at 19:03
  • Solved the issue here! VirtualBox 5.0.14 and Vagrant 1.8.1 on 64-bit Arch Linux. Thanks! – Alexander Feb 05 '16 at 13:31
  • I 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.` – Marco Aurélio Deleu Mar 14 '16 at 19:08
  • Note: Some of the below answers state one has to manually symlink /opt/VBoxGuestAdditions to- 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* – JDS Jul 08 '16 at 17:54
  • This 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 command `vagrant plugin uninstall vagrant-vbguest`. – Rick Nov 24 '16 at 14:57
  • Did not work for me in February 2017. Creating new post to request help. This has been a frustrating problem since 2013. – Eric Hepperle - CodeSlayer2010 Feb 06 '17 at 17:21
  • Worked for me on Valentine's Day 2017 ... :) – Glance Feb 14 '17 at 09:49
  • I 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 – Hà Link Mar 15 '17 at 04:20
  • surprise! updating VBox to latest version give me this error and bring me to this page – GusDeCooL Apr 27 '17 at 02:08
  • Worked for me in May/2017! – dusan May 26 '17 at 13:36
  • Worked for me in June 2017. – Patrick Jun 07 '17 at 19:30
  • Make sure disable or allow your firewall and antivirus software to allow network transaction I spent many hours to get this :) – chathun Oct 22 '19 at 06:17
231

I found this issue addressed here vagrant issues. Two ways to do it:

  1. 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.

  2. 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

aleemb
  • 31,265
  • 19
  • 98
  • 114
kenzie
  • 2,701
  • 1
  • 13
  • 11
  • 1
    Thanks! For some reason, this is mentioned in too few places. – Nirmal Mar 29 '14 at 14:51
  • 5
    You may just need to do vagrant reload afterwards to re-mount the shared folders – d4nt Mar 31 '14 at 11:04
  • @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. – Stoutie Mar 31 '14 at 22:42
  • 3
    Anyone know a way to include this as part of the VagrantFile so that it executes prior to mounting the drives? – Jason Austin Apr 02 '14 at 12:58
  • 3
    @JasonAustin https://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. – klang Apr 04 '14 at 10:07
  • 1
    Just a heads up, this will work on your vbox machine, so `vagrant ssh` before you use it. – Lucas Serafim Apr 07 '14 at 12:03
  • Thank 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. – warantesbr Apr 08 '14 at 07:58
  • @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 https://github.com/dotless-de/vagrant-vbguest and http://pastebin.com/7t8seM6m for what I did. I'm still experimenting with it, I keep having weird issues :-/ – beltorak Apr 09 '14 at 19:52
  • 5
    Using a `Win 7` box with `Vagrant 1.3.5` and `VirtualBox 4.3.10`, answer #1 did not work for me. I still got the `unable to mount ...` errors – Kevin Meredith Apr 16 '14 at 16:17
  • Under a linux host use `sudo cp VBoxGuestAdditions_4.3.11-93070.iso /usr/share/virtualbox/VBoxGuestAdditions.iso`. You will also have to set `config.vbguest.auto_update = false` in your `Vagrantfile` if you use the `vagrant-vbguest` plugin to avoid it repeating the update on every `vagrant up`. – iheggie Apr 20 '14 at 13:43
  • 3
    The recommended fix is option one, as originally posted [here](https://www.virtualbox.org/ticket/12879). The URL to the ISO file in option two is no longer valid and throws a 404. – colinhoernig Apr 29 '14 at 19:08
  • This happens every time I start a new box. I have looked at this post hundreds of times. Thank you so much for this! – Phil Oct 08 '14 at 21:13
  • 2
    IMO the vbguest plugin answer below is vastly superior to this approach. – feoh Jan 06 '15 at 17:32
  • 2
    This info may be out of date. This worked: vagrant plugin install vagrant-vbguest – mpemburn Jun 12 '15 at 13:19
  • For those on Windows, if prompted for your username, do not include the domain. – Ryan Gross Jun 17 '15 at 18:38
  • And when the file `/usr/lib/VBoxGuestAddition` does not exists?? – Rodrigo Oct 01 '15 at 21:16
  • what about *Works without Additions* (for Mac OS X) in https://www.virtualbox.org/wiki/Guest_OSes - it is a bit confusing – Radu Jun 01 '16 at 09:28
  • 1
    This answer is out of date people! – Andrzej Rehmann Jun 08 '16 at 09:04
49

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)

Blizz
  • 8,082
  • 2
  • 33
  • 53
  • 3
    Thanks. I forgot that I ran a `yum update`. I'm leaving this comment so that Future Austin will find it when this happens again. – austin Jan 09 '15 at 17:53
  • 1
    And I ran apt-get update in ubuntu, leaving a comment for future skift when this happens again :-) – skift Jan 09 '15 at 21:38
  • Present and future Loïc just thanks you :) (forgot I ran a `yum update` too) – loïc m. May 05 '15 at 14:19
  • It may fail saying `The headers for the current running kernel were not found` and ask you to `yum install kernel-devel` which works – KCD Jul 08 '15 at 01:11
  • I faced the same issue by running 'yum update' . Now I fixed it with your command. Thank you. – grant sun Aug 21 '15 at 20:06
  • 1
    I 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 do `vagrant reload`. This was on a Centos 7 Vagrant box (bento/centos-7.1) – JDS Oct 08 '15 at 17:39
29

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
Dadaso Zanzane
  • 6,039
  • 1
  • 25
  • 25
  • I think that is the best and most transparent solution – Mateusz Odelga Oct 02 '15 at 10:29
  • This worked, but with Fedora 22 I had to `vagrant ssh` into the box and do `sudo 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. – J.Z. Mar 18 '16 at 22:37
14

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.

arcseldon
  • 35,523
  • 17
  • 121
  • 125
  • 2
    Thanks for this... your `vagrantfile` config is missing, just before the final paragraph though - any chance you could add it back? – Phil Gyford Mar 01 '16 at 11:59
  • This 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. – Tony Ennis Mar 02 '16 at 18:46
  • 1
    Where is your Vagrantfile config? It's missing from your answer. – Aboelseoud Jun 26 '16 at 11:17
12

Install the vagrant-vbguest plugin by running this command:

vagrant plugin install vagrant-vbguest
Oldskool
  • 34,211
  • 7
  • 53
  • 66
Bongo
  • 333
  • 3
  • 12
6

I experienced the same issue with Centos 7, I assume due to an outdated kernel in combination with an updated version of VirtualBox. Based on Blizz's update, this is what worked for me (vagrant-vbguest plugin already installed):

vagrant ssh
sudo yum -y install kernel-devel
sudo yum -y update
exit
vagrant reload --provision
user3006381
  • 2,735
  • 3
  • 23
  • 32
5

For me, with VBoxGuestAdditions 5.1.20, the problem was that /sbin/mount.vboxsf pointed to the wrong location.

sudo ln -sf /opt/VBoxGuestAdditions-5.1.20/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf

fixed it for me

bartv
  • 126
  • 1
  • 4
  • I 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. – Teddy Apr 26 '17 at 19:16
  • This is a confirmed bug in guest additions 5.1.20: https://www.virtualbox.org/ticket/16670 – Max Smolens Apr 27 '17 at 17:44
4

As mentioned in Vagrant issue #3341 this was a Virtualbox bug #12879.

It affects only VirtualBox 4.3.10 and was completely fixed in 4.3.12.

tsusanka
  • 4,801
  • 7
  • 36
  • 42
3

I believe this is the most updated answer now and it worked for me ( Guest Additions Version: 5.0.6, VirtualBox Version: 4.3.16, Ubuntu 14.04 LTS)

https://github.com/mitchellh/vagrant/issues/3341#issuecomment-144271026

Basically i says:

Simple and Quick Solution for Failed to mount folders in Linux guest issue.

Add the following line to your Homestead/Vagrantfile:

config.vbguest.auto_update = false
Your Homestead/Vagrantfile should looks like this:

/...

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

   # To avoid install and uninstall VBoxGuessAdditions during vagrant provisioning.
    config.vbguest.auto_update = false

.../
Save it and execute

$ vagrant destroy --force
$ vagrant up
psychok7
  • 5,373
  • 9
  • 63
  • 101
  • 3
    Might want to note that 'vagrant destroy' blows away your VM, with anything you have configured/installed inside it, unless I'm mistaken. – CargoMeister Feb 13 '16 at 00:24
  • This was the only and quickest solution for me. Was having issues on a "Ubuntu precise 64 VirtualBox" image from [here](http://www.vagrantbox.es). VirtualBox 5.1.2 and Vagrant 1.8.5 on Windows. – Jamin Apr 27 '17 at 02:48
3

Just for future reference, this problem happened with me, using Vagrant 1.7.4 and VirtualBox 5.0.10 r104061, when I provisioned a shared folder in / and created a symbolic link to my home folder. Something like this:

/folder
~/folder -> /folder

Apparently, this operation is not allowed by Vagrant due to security purposes and throws the described error.

I solved it by provisioning the desired folder directly to my home directory, such as /home/vagrant/folder.

Matheus Portela
  • 2,420
  • 1
  • 21
  • 32
2

In my case on a previously working Ubuntu 16.04 image, the error started after installing vagrant-vbguest for a different vagrant image, and then starting the Ubuntu VM. It upgraded the guest additions to 5.1.20, and since then the mounts started failing. Updated the box, apt update + upgrade and the same, vbguest would install the newer 5.1.20 version.

It was solved by manually running:

sudo apt-get update
sudo apt-get install virtualbox-guest-dkms 

And also disabling the: config.vbguest.auto_update = false for this VM (might not be necessary).

Nico
  • 371
  • 3
  • 5
  • Did have exactly the same problem. Ignore the warning about not matching versions of guest and host, and turn of auto update. – Henrik Apr 27 '17 at 16:06
1

(from my comment above)

Following the problem to it's roots: , specifically the part in the comments saying this:

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 doing that, I have business as usual with all my virtual machines (and their current Vagrantfiles, of course)

When you have to do something in a freshly created virtual machine, to make it work, something is wrong.

klang
  • 524
  • 3
  • 12
  • 1
    In 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! – tsusanka Apr 13 '14 at 12:12
1

In configuration where windows is a host, and linux is a guest I found solution of the same problem in other place.

So again, the error message was "Failed to mount folders in Linux guest. This is usually because the "vboxsf" file system is not available." (...)

This was caused because I have made mistake by doing symlink inside the guest system from /vagrant into /home/vagrant/vagrant. The point is, that the directory /vagrant is a normal linux directory that has a symlink (so all ok), but when booting up by "vagrant up", it tries to mount windows directory on that place, and windows directory cannot work as a symlink. Windows host does not support linux symlinks.

So what You can do then, is to ssh into guest, remove the symlink wherever You have it, and reload machine.

In my configuration it was: Vagrant 1.7.2, VBoxGuestAdditions 4.3.28 and VBox 4.3.28.

BartoszK
  • 182
  • 7
1

This is 2017. Just in case someone faces the same issue.

For bento/centos-6.7, I was getting same error. That was solved by adding plugin vagrant-vbguest (0.13.0). c:> vagrant plugin install vagrant-vbguest

Box url: http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.0_chef-provisionerless.box

This centos-7 version was giving me same error

Error:

==> build: Mounting shared folders...
    build: /vagrant => C:/projects/
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 vagrant /vagrant

The error output from the command was:

/sbin/mount.vboxsf: mounting failed with the error: No such device

My Configuration:

C:\projects>vagrant -v
Vagrant 1.9.1

C:\projects> vboxmanage -v
5.0.10r104061

C:\projects>vagrant plugin list
vagrant-cachier (1.2.1)
vagrant-hostmanager (1.8.5)
vagrant-hosts (2.8.0)
vagrant-omnibus (1.5.0)
vagrant-share (1.1.6, system)
vagrant-vbguest (0.13.0)
vagrant-vbox-snapshot (0.0.10)

Since I already have vagrant-vbguest plugin, it tries to update the VBoxGuestAdditions in centos-7 when it sees different version of VBGuestAdditions are installed in Host 5.0.10 and guest 4.3.20.

I even have checked that symbolic link exists.

[root@build VBoxGuestAdditions]# ls -lrt /usr/lib
lrwxrwxrwx.  1 root root   53 Jan 14 12:06 VBoxGuestAdditions -> /opt/VBoxGuestAdditions-5.0.10/lib/VBoxGuestAdditions
[root@build VBoxGuestAdditions]# mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant
/sbin/mount.vboxsf: mounting failed with the error: No such device

This did not work as suggested by user3006381

vagrant ssh
sudo yum -y install kernel-devel
sudo yum -y update
exit
vagrant reload --provision

Solution for centos-7: as given by psychok7 worked

Diabled autoupdate. config.vbguest.auto_update = false Then vagrant destroy --force and vagrant up

Result:

javareport: Guest Additions Version: 4.3.20
javareport: VirtualBox Version: 5.0
==> javareport: Setting hostname...
==> javareport: Configuring and enabling network interfaces...
==> javareport: Mounting shared folders...
javareport: /vagrant => C:/projects

C:\project>
samarjit samanta
  • 1,285
  • 2
  • 16
  • 29
1

by now the mounting works on some machines (ubuntu) and some doesn't (centos 7) but installing the plugin solves it

vagrant plugin install vagrant-vbguest

without having to do anything else on top of that, just

vagrant reload
0

Your log complains about not finding exportfs: sudo: /usr/bin/exportfs: command not found

The exportfs makes local directories available for NFS clients to mount.

kenzie
  • 2,701
  • 1
  • 13
  • 11
  • 1
    I have fixed the issue concerning `sudo: /usr/bin/exportfs: command not found` by setting a symlink to real path using the command `sudo ln -s /usr/sbin/exportfs /usr/bin/exportfs`, however the error about `Failed to mount folders in Linux guest` persist even after this. – radu c Mar 28 '14 at 17:00
0

This seems to be due to an incompatibility with the vbguest vagrant plugin and the latest version(s) of vagrant. It is trying to update the guest additions and failing to do it completely/properly.

Hickeroar
  • 49
  • 2
  • 2
    From 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 Apr 20 '14 at 13:30
0

Try like it:

vagrant plugin install vagrant-vbguest

In Vagrantfile add:

config.vbguest.iso_path = "http://download.virtualbox.org/virtualbox/VERSION/VBoxGuestAdditions_VERSION.iso"
config.vbguest.auto_update = false
config.vbguest.installer_arguments = %w{--nox11 -- --force}

Run:

vagrant vbguest --do install -f -b

vagrant reload
Pang
  • 9,564
  • 146
  • 81
  • 122
0

I was running Vagrant with VirtualBox 5.1.X, and had to downgrade to VirtualBox 5.0.40, and install the vbguest plugin to solve this problem.

My steps were:

  • Uninstall VirtualBox 5.1.X
  • Install Vagrant 5.0.40
  • Reboot my machine
  • Run vagrant up for my vagrant. It'll fail.
  • Run vagrant plugin install vagrant-vbguest while my VM is running, to install the vagrant plugin. This manages syncing VirtualBox Guest versions between host and guest.
  • Run vagrant reload to reload my virtual machine
  • Magic!
Community
  • 1
  • 1
Brad Parks
  • 66,836
  • 64
  • 257
  • 336
0
vagrant plugin install vagrant-vbguest
vagrant destroy #clean rhel/yum repos
vagrant up

And on the config file:

config.vbguest.auto_update = false #important so that any changes to the base image don't affect on reload
karthik r
  • 989
  • 13
  • 11
-1

One more step I had to complete after following the first suggestion that kenzie made was to run the mount commands listed in the error message with sudo from the Ubuntu command line [14.04 Server]. After that, everything was good to go!

Yossarian
  • 189
  • 1
  • 2
  • 8