Vagrant Error: Unable to Mount VirtualBox Shared F

2019-03-08 18:42发布

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.

11条回答
趁早两清
2楼-- · 2019-03-08 18:56

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.

查看更多
相关推荐>>
3楼-- · 2019-03-08 18:58

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("/", "\")

查看更多
混吃等死
4楼-- · 2019-03-08 18:58

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.

查看更多
再贱就再见
5楼-- · 2019-03-08 18:59

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"
查看更多
爷的心禁止访问
6楼-- · 2019-03-08 19:00

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.

查看更多
别忘想泡老子
7楼-- · 2019-03-08 19:07

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

查看更多
登录 后发表回答