Vagrant Error: Unable to Mount VirtualBox Shared Folders (Guest Additions, vboxsf)
Asked Answered
I

11

34

The Issue

I installed Vagrant on Windows 10 so I can create a personal local development environment in a virtual machine. Everything I've read about Vagrant said I can even spin up multiple systems and test communication between them with NAT port forwarding. But first, I just want to get one development environment virtual machine created before I go too far with the rest of it.

I installed VirtualBox, Vagrant, PuTTy, and PuTTYGen, per this SitePoint tutorial: https://www.sitepoint.com/getting-started-vagrant-windows/. Next I created a vagrant project folder on C: drive, did vagrant init, deleted the Vagrantfile, and finally, vagrant init ubuntu/trusty64. Then I did vagrant up, but the process failed with the error:

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:

: No such file or directory

Here's a screenshot of my Windows command line:

Screenshot of Vagrant/VirtualBox error

And here's a text version:

C:\vagrant\sitepoint-test-2017-02-05>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/trusty64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: A newer version of the box 'ubuntu/trusty64' is available! You currently
==> default: have version '20160602.0.0'. The latest is version '20170202.0.0'. Run
==> default: `vagrant box update` to update.
==> default: Setting the name of the VM: sitepoint-test-2017-02-05_default_1486399403587_55255
==> 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: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> 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: Warning: Remote connection disconnect. Retrying...
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => C:/vagrant/sitepoint-test-2017-02-05
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:

: No such file or directory

My Setup

OS: Microsoft Windows [Version 10.0.14393]
VirtualBox Version: 4.3.10 r93012
GuestAdditions Version: ???
Vagrant Version: 1.9.1 (Latest)
PuTTy Version: 0.67
PuTTYGen Version: 0.67

Plugins & Extensions Installed

Vagrant:
- vagrant-share (1.1.6, system)
- vagrant-vbguest (0.13.0)

What I tried already

This post seemed the most promising in my research.

Unfortunately, none of the solutions offered, nor any of the links provided solved the issue. I've tried a bunch of stuff already, but I'm not a system admin (which, I'm guessing is the skillset that you'd need to troubleshoot this). It was particularly troubling that many of the "solutions" from 2013/2014, are more recently indicated as not working any more. These solutions talk about something to do with symlinks not working, installing plugins like vagrant-vbguest, and something about vbox additions not matching something. I don't really understand all of that, but I tried my best. Here is what I tried already that hasn't solved it yet:

  1. vagrant plugin install vagrant-vbguest. Vagrant shows the plugin as installed, but I get the same error on vagrant up.

  2. List of links I read in researching this issue that provided no working solution.

My Questions

  1. I suspect the issue is with VirtualBox, not Vagrant. Is this true?

  2. How can I fix this so I can continue with the tutorial?

  3. There seems to have been a drastic drop in Vagrant questions answered on Stack Overflow since around 2014. What is the reason for this? Is Vagrant/VirtualBox no longer considered "best practice"? Is there a better solution so users are ignoring the Vagrant questions?

Again, I'm not a system administrator, but I am technically savvy and can follow technical directions.

Iver answered 6/2, 2017 at 17:57 Comment(2)
Hey Eric, have you found any solution? My friend experienced this problem too and I'm helping him to find the solution, but none of what I've found worked for him.Sherrer
@softtama Best and the easiest solution is downgrade virtualbox to 5.1.14. Related to issue github.com/mitchellh/vagrant/issues/8352Odontoblast
M
8

This problem is solved in VirtualBox 5.1.18.

Megargee answered 21/3, 2017 at 11:59 Comment(9)
This problem seems disappeared when I upgrade to 5.1.18 from 5.1.16.Incogitable
I love the detailed answers that others gave, however, this one was the simplest and it worked. Unfortunately, it indicates that there was an issue that apparently wasn't well-known until shortly after I posted this question. Does that mean that no newbie has been able to install VirtualBox + Guest Additions for the past 3 years (since 2014 at least) due to this issue, or is it only an issue on VirtualBox on Windows?Iver
Unfortunately this problem reappeared just now when I upgraded from 5.1.18 to 5.1.20Fossorial
@SzczepanHołyszewski same here on 5.1.24Chrestomathy
For me it also appeared with 5.1.20 again - but now there´s VirtualBox 5.2.0 out! Upgrade fixed it again for me. Eric Hepperle - CodeSlayer2010 - if you need a complete example for a working multi-machine-setup with Windows AND Linux, check out the first parts of this article blog.codecentric.de/en/2017/09/… (paragraph "A multi-machine Windows & Linux mixed OS Vagrant setup for Docker Swarm").Glendoraglendower
Seems to have reappeared in v5.2.2 of VirtualBox so don't upgradeSkat
Virtual Box v5.2.8 still has this problemMarcenemarcescent
This also has issues with v5.2.26. Regression issue I would say.Billposter
It seems to have reappeared in VirtualBox-6.0.12-133076-WinBrute
Y
29
vagrant plugin install vagrant-vbguest

This didn't work for me, it seems to be incompatible with vagrant 1.9.2, I uninstalled the latest version of virtual box (5.1.16) and installed version 5.1.12 with the latest version of vagrant 1.9.2 and homestead and it works for me.

Yearling answered 10/3, 2017 at 11:32 Comment(4)
This worked for me☺ ! I have Vagrant 1.9.2 and Virtual Box 5.1.16r113841Lacteous
yeeeeeeeeeeeeeeeeeeeeeesssss.Classics
Yes! Thank you so much. This worked with Virtual box 5.1.22 and Vagrant 1.9.4Mastitis
Worked for me as well: Vagrant 1.9.5 and VirtualBox 5.1.22.Tortoiseshell
R
28

You can downgrade VirtualBox or edit the line in the file:

On my setup this was Line 206 of:

C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.9.2\lib\vagrant\util\platform.rb

on my host machine.

I did this and it worked fine on Windows 10! I would like to add what I did with line 206:

Before edit: "\\?\" + path.gsub("/", "\")

After edit: path.gsub("/", "\")

Ronnaronnholm answered 10/3, 2017 at 10:51 Comment(4)
It is a solution until they fix it there github.com/mitchellh/vagrant/issues/8352Apelles
Updated everything: virtual box, vagrant (1.9.2), Guest Addition 5.1.16, the above method works. Note that you have to put a double backslash to escape the above line after edit.Eozoic
This took me three days now to figure out. Thanks a lot for sharing this - it should be accepted as the correct answer (if it fixes the problem @Eric as well)!Lipocaic
this worked for me in windows 7 x64, using vagrant 1.9.2, virtualbox 5.1.16.! thanks!Achromat
S
13

Guest Additions is incompatible with the version of VirtualBox. Autoupdating VirtualBox Guest Additions will solve probably related issue:

vagrant plugin install vagrant-vbguest

I exprerienced this issue with these stack:

  • Windows 10
  • Oracle VirtualBox 5.1.16
  • Vagrant 1.9.2
  • config.vm.box = "hashicorp/precise64"
Scutate answered 9/3, 2017 at 13:25 Comment(8)
For which vagrant boxes did you try it? With the same setup as you, for me the automatic update of the virtualbox guest additions does not solve the issue when using ubuntu/xenial64 as vagrant box. It seems like that the vbox guest additions have some problems with the UNC encoded path vagrant uses for the shared folder. vbox version 5.1.14 works fine. Thanks in advance!Soutane
Thanks for your reply @JosephStar. I have already done that update prior to posting my question, to no avail. My situation is similar to what @lootr is describing, except my in Ubuntu Server 14 LTS something. Still waiting on a good solution ... surprised nobody else has reported this issue yet...Iver
Thanks, using 5.1.14 was the only thing that fixed the issue for me.Merow
Same issue. Downgrading from 5.1.16 to 5.1.14 fixed things. Thanks @Mr_CryptoPrime!Loris
@EricHepperle-CodeSlayer2010 There is now a vagrant issue for this at github github.com/mitchellh/vagrant/issues/8352Soutane
Cool. I will attempt the downgrade and report back.Iver
it worked for me when installing laravel (5.4) Homestead on vagrant version-1.9.7. On win-10 with folders type NTFS in Homestead.yamlSanatorium
Thanks for this one. I'm using Vagrant 1.9.5 and Virtual Box 5.1.28 (although this started happening with 5.1.20). I went through a lot of stuff before finding this.Rola
N
8

There can be multiple cause :

  1. The version of the guest addition is not matching the version of VirtualBox, for this you can update the version of the guest addition by running vagrant plugin install vagrant-vbguest
  2. You hit a bug of vagrant with NFS on Windows : should be fixed so maybe try to update to the latest release of Vagrant and VirtualBox
  3. In this github issue https://github.com/fideloper/Vaprobash/issues/92, there is two thing that you can test : use the winnfsd plugin (https://github.com/winnfsd/vagrant-winnfsd) or try to configure the default mount with no NFS

I had the same issue, and it was just the guest addition that was not up-to-date ...

UDPATE : The bug on Vagrant with NFS on Windows (point 2) has been fixed in version 5.1.18, re-appears in version 5.1.20 and is fixed again in version 5.2.

Nasty answered 8/2, 2017 at 10:56 Comment(4)
Thanks for your answer. I don't know if I will get to it this week, but I will report back and let you know if it worked.Iver
Try to disable vbox guest additions at all and up vagrant again. Edit "Vagrantfile": 1) machine.vm.synced_folder '.', '/vagrant', type: user_config.vagrant_mount_method, disabled: true 2) config.vbguest.auto_update = false Or here you can see how to compile guest additions manually: #28329275Levon
in my case I needed both vagrant plugin install vagrant-vbguest and vagrant plugin install vagrant-winnfsdShornick
@Shornick Installing vagrant-winffsd fixed my issue as well!Nomarch
M
8

This problem is solved in VirtualBox 5.1.18.

Megargee answered 21/3, 2017 at 11:59 Comment(9)
This problem seems disappeared when I upgrade to 5.1.18 from 5.1.16.Incogitable
I love the detailed answers that others gave, however, this one was the simplest and it worked. Unfortunately, it indicates that there was an issue that apparently wasn't well-known until shortly after I posted this question. Does that mean that no newbie has been able to install VirtualBox + Guest Additions for the past 3 years (since 2014 at least) due to this issue, or is it only an issue on VirtualBox on Windows?Iver
Unfortunately this problem reappeared just now when I upgraded from 5.1.18 to 5.1.20Fossorial
@SzczepanHołyszewski same here on 5.1.24Chrestomathy
For me it also appeared with 5.1.20 again - but now there´s VirtualBox 5.2.0 out! Upgrade fixed it again for me. Eric Hepperle - CodeSlayer2010 - if you need a complete example for a working multi-machine-setup with Windows AND Linux, check out the first parts of this article blog.codecentric.de/en/2017/09/… (paragraph "A multi-machine Windows & Linux mixed OS Vagrant setup for Docker Swarm").Glendoraglendower
Seems to have reappeared in v5.2.2 of VirtualBox so don't upgradeSkat
Virtual Box v5.2.8 still has this problemMarcenemarcescent
This also has issues with v5.2.26. Regression issue I would say.Billposter
It seems to have reappeared in VirtualBox-6.0.12-133076-WinBrute
C
4

I am using Vagrant 1.9.4 and VirtualBox 5.1.20. No solution here helped me.

I finally got around the problem by disabling auto updates for the guest additions:

Vagrant.configure("2") do |config|
    config.vbguest.auto_update = false
    [...]
end

It's more of a hacky workaround than a solution. I still don't really know what the actual issue is, but I assume it is connected to this: https://www.virtualbox.org/ticket/16670

Cowrie answered 27/4, 2017 at 8:41 Comment(0)
C
3

Downgrade to Virtual Box 5.1.14 from 5.1.16 works fine.

Classmate answered 15/3, 2017 at 9:45 Comment(0)
P
2

There is also a regression in Virtualbox 5.1.20

Vagrant issue: https://github.com/mitchellh/vagrant/issues/8502

Virtualbox issue: https://www.virtualbox.org/ticket/16670#comment:4

The fix for now is to role back to Virtualbox 5.1.18 where it worked.

Polydactyl answered 1/5, 2017 at 11:1 Comment(1)
Thanks Jayflux! So, WTF is wrong with VirtualBox that it can't consistently make a good product that just works? It's a bit frustrating, as I've been chasing this issue on different iterations of the box for over 4 years.Iver
D
2

It is bug in Vbox. There is an solution to fix.

Login to Vbox guestos: By default password is (vagrant/vagrant)

su
ln -sf /opt/VBoxGuestAdditions-5.1.20/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf
mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant

shutdown

run cmd in from local machine cmd prompt:

vagrant up

It will work.

Delorisdelorme answered 16/6, 2017 at 13:46 Comment(0)
T
1

I have similar issue, check header if it's not match then run below command

CentOS: sudo yum update && sudo yum -y install kernel-headers kernel-devel

vagrant reload

it works for me.

Tare answered 13/6, 2017 at 10:46 Comment(0)
A
1

Summary

The problem with the synced/shared folders not working anymore all of a sudden is, that the VirtualBox Guest additions kernel module is not loaded.

The problem is not directly connected to the VirtualBox version! It may have been the case in the past, but the following explanation covers about 95% of the occurences of this problem.


Explanation

This is mainly caused by an automatic update of the linux kernel, for example by having cronapt running in the virtual machine.

If the kernel gets a new version, the dkms module for the guest additions can not be restarted after a reboot of the virtual machine. The service file /etc/init.d/virtualbox-guest-utils checks if there is a kernel module in

/lib/modules/`uname -r`

folder for vboxguest and vboxsf.

Let the kernel version at initial setup of the guest additions be: 1.2.3

The updated kernel has the version: 1.2.4

uname -r would result in 1.2.4, while the dkms module was installed with the kernel version 1.2.3. This would cause the virtualbox guest addition service to abort execution and fail with an error message like modprobe xxxx failed.....

Solution

What we need to do is, install the headers of the kernel alongside with the new kernel version, so that the dkms module for the virtualbox guest additions can be automatically rebuilt with them.

Fortunately there is a meta package, that lets us have the newest version of the kernel headers installed.

It seems to be named differently in different linux flavours. Here is a small list of them.

Debian

sudo apt install linux-headers-amd64

Ubuntu

sudo apt install linux-headers-generic

CentOS (untested)

Thx to @Jayen Chondigara

sudo yum -y install kernel-headers kernel-devel

Amero answered 23/1, 2019 at 15:10 Comment(1)
Excellent explanation and the correct solution IMO!Huntington

© 2022 - 2024 — McMap. All rights reserved.