Vagrant 无法挂载 VirtualBox 共享文件夹 [英] Vagrant was unable to mount VirtualBox shared folders

查看:47
本文介绍了Vagrant 无法挂载 VirtualBox 共享文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前设置:Virtualbox 5.1.20,带有 Vagrant 1.9.3

以前的工作设置:Virtualbox 5.1.18Vagrant 1.9.3

Previous working setup: Virtualbox 5.1.18 with Vagrant 1.9.3

我安装了最新版本的 Virtualbox 并尝试启动我的 VM.文件夹安装已停止工作.相同的文件夹安装在 Virtualbox 5.1.18 中运行良好.我收到以下错误消息:

I installed the latest version of Virtualbox and tried to start my VM. The folder mounting has stopped working. The same folder mounting works fine in Virtualbox 5.1.18. I get the following error message:

Vagrant 无法挂载 VirtualBox 共享文件夹.这通常是因为文件系统vboxsf"不可用.该文件系统通过 VirtualBox Guest Additions 和内核模块提供.请验证这些来宾添加是否正确安装在来宾中.这不是 Vagrant 中的错误,通常是由有故障的 Vagrant 框引起的.对于上下文,尝试的命令是:

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 keys /keys 

命令的错误输出是:

mount: wrong fs type, bad option, bad superblock on keys,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try dmesg | tail or so.

我尝试手动安装 vagrant-vbguest 插件(通过 vagrant plugin install vagrant-vbguest),但没有修复任何问题.降级回 5.1.18 确实解决了这个问题,但这并不理想.

I have tried manually installing vagrant-vbguest plugin (via vagrant plugin install vagrant-vbguest), but that fixed nothing. Downgrading back to 5.1.18 does resolve it, but this isn't ideal moving forward.

如何使用 Virtualbox 5.1.20Vagrant 1.9.3 安装文件夹?

How can I get folder mounting working with Virtualbox 5.1.20 and Vagrant 1.9.3?

推荐答案

更新

已在 VirtualBox 5.1.22 中修复.

Fixed in VirtualBox 5.1.22.

(https://www.virtualbox.org/ticket/16670)

原始答案

就我而言,VM 内的符号链接是错误的.登录虚拟机:

In my case a symlink inside the VM was wrong. Log into the VM:

$ vagrant ssh

那么:

$ ls -lh /sbin/mount.vboxsf 
lrwxrwxrwx 1 root root 49 Apr 19 14:05 /sbin/mount.vboxsf -> /opt/VBoxGuestAdditions-5.1.20/other/mount.vboxsf

此链接已损坏.当您查看/opt/VBoxGuestAdditions-5.1.20/时,您会看到子文件夹other"不存在.这一行解决了这个问题:

This link is broken. When you look inside /opt/VBoxGuestAdditions-5.1.20/ you see that the subfolder "other" doesn't exists. This line fixes that:

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

现在注销虚拟机:

$ exit

并检查它是否适合您:

$ vagrant reload

但是我无法修复链接,因为/sbin/mount.vboxsf 在我的盒子中不存在!

如果/sbin/mount.vboxsf 链接首先不存在,则无法安装 VBoxGuestAdditions.如果您在更新 VirtualBox(v5.2.18 及更高版本应在 Virtualbox 更新期间自动下载)后尚未下载匹配的 VirtualBox 扩展包,则可能会发生这种情况.你现在可以这样做:

If the link /sbin/mount.vboxsf does not exists in the first place, than the VBoxGuestAdditions couldn't be installed. This can happen if you have not downloaded the matching VirtualBox Extension Pack after you updated VirtualBox (v5.2.18 and up should download it automatically during Virtualbox updates). You can do that now:

  • 暂停所有正在运行的虚拟机.
  • 打开 VirtualBox 程序.
  • 开始下载 VirtualBox 扩展包并安装它.
  • 如果系统未询问您是否要下载 VirtualBox 扩展包,请打开 -> 文件 -> 检查更新,以触发下载对话框.

如果 VirtualBox 扩展没有更新,则可能无法安装 VBoxGuestAdditions,因为安装程序会显示一条消息,而 vagrant 插件 vbguest 无法提示答案(此 在 vbguest v0.15.0 中固定").您可以在vagrant up"的输出中看到这一点.应该有这样一行:

If there was no update for the VirtualBox Extension, than it's possible the VBoxGuestAdditions can't be installed because the installer shows a message and the vagrant plugin vbguest can not prompt an answer (this is "fixed" in vbguest v0.15.0). You can see that in the output of "vagrant up". There should be a line similar to this one:

Do you wish to continue? [yes or no]

如果是这种情况,您可以手动运行安装程序.为此,请启动框:

If that is the case you can run the installer manually. To do so, start the box:

$ vagrant up

然后触发 vbguest 再次尝试安装,但之后将 VBoxGuestAdditions ISO 挂载:

Then trigger vbguest to try the installation again but leave the VBoxGuestAdditions ISO mounted afterwards:

$ vagrant vbguest --do install --no-cleanup

登录框:

$ vagrant ssh

手动运行安装程序:

$ sudo /mnt/VBoxLinuxAdditions.run

最后的希望:DIY!

如果上述方法均无效,请尝试手动安装来宾添加:

If nothing of the above worked, try to install the guest additions manually:

cd /opt
sudo wget -c http://download.virtualbox.org/virtualbox/5.1.28/VBoxGuestAdditions_5.1.28.iso -O VBoxGuestAdditions_5.1.28.iso
sudo mount VBoxGuestAdditions_5.1.28.iso -o loop /mnt
sudo sh /mnt/VBoxLinuxAdditions.run

这篇关于Vagrant 无法挂载 VirtualBox 共享文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆