windows Vagrant 错误:无法挂载 VirtualBox 共享文件夹(Guest Additions,vboxsf)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42074246/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Vagrant Error: Unable to Mount VirtualBox Shared Folders (Guest Additions, vboxsf)
提问by Eric Hepperle - CodeSlayer2010
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.
我在 Windows 10 上安装了 Vagrant,因此我可以在虚拟机中创建个人本地开发环境。我读到的关于 Vagrant 的所有内容都说我什至可以启动多个系统并使用 NAT 端口转发测试它们之间的通信。但首先,我只想先创建一个开发环境虚拟机,然后再处理其余部分。
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:
我根据这个 SitePoint 教程安装了 VirtualBox、Vagrant、PuTTy 和 PuTTYGen:https://www.sitepoint.com/getting-started-vagrant-windows/ 。接下来我在 C: 驱动器上创建了一个 vagrant 项目文件夹, did vagrant init
,删除了Vagrantfile
,最后,vagrant init ubuntu/trusty64
. 然后我做了vagrant up
,但过程失败并出现错误:
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
Vagrant 无法挂载 VirtualBox 共享文件夹。这通常是因为文件系统“vboxsf”不可用。该文件系统通过 VirtualBox Guest Additions 和内核模块提供。请验证这些来宾添加是否正确安装在来宾中。这不是 Vagrant 中的错误,通常是由有故障的 Vagrant 框引起的。对于上下文,尝试的命令是:
mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant
命令的错误输出是:
: 无此文件或目录
Here's a screenshot of my Windows command line:
这是我的 Windows 命令行的屏幕截图:
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 postseemed 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:
不幸的是,没有提供任何解决方案,也没有提供任何链接解决问题。我已经尝试了很多东西,但我不是系统管理员(我猜这是解决此问题所需的技能)。尤其令人不安的是,2013/2014 年的许多“解决方案”最近都被指出不再有效。这些解决方案讨论了与符号链接不起作用、安装 vagrant-vbguest 之类的插件以及 vbox 添加不匹配的问题。我真的不明白这一切,但我尽力了。这是我已经尝试过但尚未解决的问题:
vagrant plugin install vagrant-vbguest
. Vagrant shows the plugin as installed, but I get the same error onvagrant up
.List of links I read in researching this issue that provided no working solution.
- Vagrant unable to mount in Linux guest with VirtualBox Guest Additions on Windows 7
- Vagrant - How can I mount the virtualbox shared folder? ("vboxsf" not available)
- https://github.com/mitchellh/vagrant/issues/3341#issuecomment-144271026
- https://www.virtualbox.org/ticket/12879(This VirtualBox ticket is referenced by posters in some of the other listed links. Unfortuantely, this ticket doesn't fix the issue. It's not fixed and is still broken ... OR ... perhaps this ticket is related, but slightly differerent than the issue I and others are still experiencing).
- https://gist.github.com/fernandoaleman/5083680
- VAGRANT SHARED FOLDERS DO NOT MOUNT - Windows 7 - Vagrant 1.7.4 - Ubuntu 12.04 precise64 - VirtualBox 5.0.10 with Guest Additions
vagrant plugin install vagrant-vbguest
. Vagrant 显示插件已安装,但我在vagrant up
.我在研究这个问题时阅读的链接列表,但没有提供有效的解决方案。
- Vagrant 无法使用 Windows 7 上的 VirtualBox Guest Additions 在 Linux 客户机中挂载
- Vagrant - 如何挂载 virtualbox 共享文件夹?(“vboxsf”不可用)
- https://github.com/mitchellh/vagrant/issues/3341#issuecomment-144271026
- https://www.virtualbox.org/ticket/12879(这张 VirtualBox 票在其他一些列出的链接中被海报引用。不幸的是,这张票并没有解决这个问题。它没有修复,仍然坏了......或者......也许这张票是相关的,但与我和其他人仍在经历的问题略有不同)。
- https://gist.github.com/fernandoaleman/5083680
- 不安装 Vagrant 共享文件夹 - Windows 7 - Vagrant 1.7.4 - Ubuntu 12.04 precision64 - VirtualBox 5.0.10 with Guest Additions
My Questions
我的问题
I suspect the issue is with VirtualBox, not Vagrant. Is this true?
How can I fix this so I can continue with the tutorial?
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?
我怀疑问题出在 VirtualBox,而不是 Vagrant。这是真的?
我该如何解决这个问题,以便我可以继续本教程?
自 2014 年左右以来,在 Stack Overflow 上回答的 Vagrant 问题似乎急剧下降。这是什么原因?Vagrant/VirtualBox 不再被视为“最佳实践”吗?有没有更好的解决方案让用户忽略 Vagrant 的问题?
Again, I'm not a system administrator, but I am technically savvy and can follow technical directions.
同样,我不是系统管理员,但我精通技术并且可以遵循技术指导。
采纳答案by chaitan64arun
This problem is solved in VirtualBox 5.1.18.
这个问题在 VirtualBox 5.1.18 中得到解决。
回答by Anders
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.
您可以降级 VirtualBox 或编辑文件中的行:
在我的设置中,这是第 206 行:
C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.9.2\lib\vagrant\util\platform.rb
在我的主机上。
I did this and it worked fine on Windows 10! I would like to add what I did with line 206:
我这样做了,它在 Windows 10 上运行良好!我想添加我对第 206 行所做的:
Before edit: "\\?\" + path.gsub("/", "\")
编辑前:"\\?\" + path.gsub("/", "\")
After edit: path.gsub("/", "\")
编辑后: path.gsub("/", "\")
回答by Daniel Carr
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.
这对我不起作用,它似乎与 vagrant 1.9.2 不兼容,我卸载了最新版本的 virtual box (5.1.16) 并安装了 5.1.12 版本以及最新版本的 vagrant 1.9.2 和 homestead 和这个对我有用。
回答by YUSUF YILDIZ
Guest Additions is incompatible with the version of VirtualBox. Autoupdating VirtualBox Guest Additions will solve probably related issue:
Guest Additions 与 VirtualBox 的版本不兼容。自动更新 VirtualBox Guest Additions 将解决可能相关的问题:
vagrant plugin install vagrant-vbguest
vagrant 插件安装 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"
- 视窗 10
- Oracle VirtualBox 5.1.16
- 流浪者 1.9.2
- config.vm.box = "hashicorp/precise64"
回答by loicmathieu
There can be multiple cause :
可能有多种原因:
- 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
- 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
- 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
- 来宾添加的版本与 VirtualBox 的版本不匹配,为此您可以通过运行来更新来宾添加的版本
vagrant plugin install vagrant-vbguest
- 您在 Windows 上使用 NFS 遇到了 vagrant 的错误:应该修复所以也许尝试更新到最新版本的 Vagrant 和 VirtualBox
- 在这个 github 问题https://github.com/fideloper/Vaprobash/issues/92 中,您可以测试两件事:使用 winnfsd 插件(https://github.com/winnfsd/vagrant-winnfsd)或尝试配置没有 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.
UDPATE:Windows 上使用 NFS 的 Vagrant 上的错误(第 2 点)已在 5.1.18 版中修复,在 5.1.20 版中重新出现,并在 5.2 版中再次修复。
回答by user3245821
I am using Vagrant 1.9.4 and VirtualBox 5.1.20. No solution here helped me.
我正在使用 Vagrant 1.9.4 和 VirtualBox 5.1.20。这里没有解决方案帮助我。
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
与其说是解决方案,不如说是一种骇人听闻的解决方法。我仍然不知道实际问题是什么,但我认为它与此有关:https: //www.virtualbox.org/ticket/16670
回答by Sven
Downgrade to Virtual Box 5.1.14 from 5.1.16 works fine.
从 5.1.16 降级到 Virtual Box 5.1.14 工作正常。
回答by Jayflux
There is also a regression in Virtualbox 5.1.20
Virtualbox 5.1.20 也有回归
Vagrant issue: https://github.com/mitchellh/vagrant/issues/8502
流浪问题:https: //github.com/mitchellh/vagrant/issues/8502
Virtualbox issue: https://www.virtualbox.org/ticket/16670#comment:4
Virtualbox 问题:https://www.virtualbox.org/ticket/16670#comment:4
The fix for now is to role back to Virtualbox 5.1.18 where it worked.
现在的修复是将角色恢复到 Virtualbox 5.1.18 工作的地方。
回答by user3369245
It is bug in Vbox. There is an solution to fix.
这是 Vbox 中的错误。有一个解决方案可以解决。
Login to Vbox guestos: By default password is (vagrant/vagrant)
登录 Vbox guestos:默认密码是 (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:
从本地机器 cmd 提示符运行 cmd:
vagrant up
It will work.
它会起作用。
回答by func0der
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.
同步/共享文件夹突然不再工作的问题是,VirtualBox 来宾添加内核模块未加载。
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.
问题不是直接连接到VirtualBox版本!过去可能是这种情况,但以下解释涵盖了大约 95% 的出现此问题的情况。
Explanation
解释
This is mainly caused by an automatic update of the linux kernel, for example by having cronapt
running in the virtual machine.
这主要是由 linux 内核的自动更新引起的,例如通过cronapt
在虚拟机中运行。
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
如果内核获得新版本,则虚拟机重新启动后无法重新启动用于来宾添加的 dkms 模块。服务文件/etc/init.d/virtualbox-guest-utils
检查是否有内核模块
/lib/modules/`uname -r`
folder for vboxguest
and vboxsf
.
vboxguest
和 的文件夹vboxsf
。
Let the kernel version at initial setup of the guest additions be: 1.2.3
让来宾添加初始设置时的内核版本为:1.2.3
The updated kernel has the version: 1.2.4
更新后的内核版本为: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....
.
uname -r
将导致1.2.4
dkms 模块与内核版本一起安装1.2.3
。这将导致 virtualbox 来宾添加服务中止执行并失败并显示类似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.
我们需要做的是,将内核的头文件与新的内核版本一起安装,以便虚拟机来宾添加的 dkms 模块可以使用它们自动重建。
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.
它似乎在不同的 linux 风格中命名不同。这是其中的一个小清单。
Debian
Debian
sudo apt install linux-headers-amd64
sudo apt install linux-headers-amd64
Ubuntu
Ubuntu
sudo apt install linux-headers-generic
sudo apt install linux-headers-generic
CentOS (untested)
CentOS(未经测试)
Thx to @Jayen Chondigara
感谢@Jayen Chondigara
sudo yum -y install kernel-headers kernel-devel
sudo yum -y install kernel-headers kernel-devel