Laravel Homestead Vagrant - 'vboxsf' 不可用问题

Posted

技术标签:

【中文标题】Laravel Homestead Vagrant - \'vboxsf\' 不可用问题【英文标题】:Laravel Homestead Vagrant - 'vboxsf' not available issueLaravel Homestead Vagrant - 'vboxsf' 不可用问题 【发布时间】:2015-07-22 09:46:27 【问题描述】:

所以我一直在尝试通过 Vagrant/VirtualBox 安装 Laravel Homestead。它以前可以工作,但现在根本不工作。除了来宾机器的错误中提到的日志文件/var/log/vboxadd-install.log 之外,我还包括了运行vagrant up 返回的内容。以下也是我当前设置的所有版本号。

操作系统:Windows 8.1(64 位),VirtualBox:4.3.26,Vagrant:1.7.2

这是运行命令vagrant up的结果

PS C:\Users\brand_000\Homestead> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'laravel/homestead' is up to date...
==> 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: 80 => 8000 (adapter 1)
    default: 443 => 44300 (adapter 1)
    default: 3306 => 33060 (adapter 1)
    default: 5432 => 54320 (adapter 1)
    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: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   4.3.18
VBoxService inside the vm claims: 4.3.8
Going on, assuming VBoxService is correct...
GuestAdditions versions on your host (4.3.26) and guest (4.3.8) do not match.
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   4.3.18
VBoxService inside the vm claims: 4.3.8
Going on, assuming VBoxService is correct...
Reading package lists...
Building dependency tree...
Reading state information...
linux-headers-3.16.0-23-generic is already the newest version.
dkms is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
Copy iso file C:\Program Files/Oracle/VirtualBox/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
mount: /dev/loop0 is write-protected, mounting read-only
Installing Virtualbox Guest Additions 4.3.8 - guest version is 4.3.8
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.8 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 4.3.8 of VirtualBox Guest Additions...
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
The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.

Building the main Guest Additions module ...done.
Building the shared folder support module ...fail!
(Look at /var/log/vboxadd-install.log to find out what went wrong)
Doing non-kernel setup of the 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.8. 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: Mounting shared folders...
    default: /vagrant => C:/Users/brand_000/Homestead
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

The error output from the last command was:

/sbin/mount.vboxsf: mounting failed with the error: No such device
PS C:\Users\brand_000\Homestead>

这是错误文件的内容。 PasteBin Upload of error file @ /var/log/vboxadd-install.log

我确实按照 *** 上的一些指南和答案安装了 vbguest vagrant 插件,但到目前为止没有任何效果。甚至尝试将 VirtualBox 降级到 4.3.8 和其他版本,但没有成功。我正确地遵循了installing Laravel Homestead 上的说明。正如我所提到的,它在过去有效。有什么建议吗?

【问题讨论】:

Vagrant error : Failed to mount folders in Linux guest的可能重复 【参考方案1】:

编辑scripts\homestead.rb,更改:

mount_opts = folder["type"] == "nfs" ? ['actimeo=1'] : []

mount_opts = folder["type"] == "nfs" ? [''] : []

然后安装 VBoxGuestAdditions:

C:\Homestead> vagrant plugin install vagrant-vbguest
C:\Homestead> vagrant up
C:\Homestead> vagrant ssh
$ sudo ln -s /opt/VBoxGuestAdditions-4.3.18/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions
$ sudo apt-get install --yes dkms linux-headers-3.16.0-23-generic
$ sudo /etc/init.d/vboxadd setup
$ exit
C:\Homestead> vagrant halt 
C:\Homestead> vagrant up

【讨论】:

很遗憾,在您完成所有说明后出现了同样的错误。这是我通过 ssh 登录时运行的命令,之后我什至重新启动了 VM,结果相同。 Link to Results of SSH【参考方案2】:

看起来Laravel docs 5.0 仍然是 Homestead 1.x 的指南。 但是Laravel docs 4.2 已经包含了 Homestead 2.x 的指南。由于 ̀laravel/homestead 已经是第 2 版,现在您最好按照此处的 4.2 文档进行操作。

另一个好的来源是laracasts homestead 2 introduction。

【讨论】:

【参考方案3】:

我解决了与 vagrant up 的输出类似的问题,如下所示:

Installing Virtualbox Guest Additions 5.0.4 - guest version is 4.3.
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.4 Guest Additions for Linux...........
VirtualBox Guest Additions installer
Removing installed version 4.3.14 of VirtualBox Guest Additions...
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox non-DKMS kernel modules[  OK  ]
Building the VirtualBox Guest Additions kernel modules
Building the main Guest Additions module[FAILED]
(Look at /var/log/vboxadd-install.log to find out what went wrong)

后来

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

症状

我的 vagrant 脚本已经顺利运行了很长时间,但昨天我更改了磁盘的物理硬件,将磁盘从 lenovo T520 移动到 T530。没关系,我不得不更新几个驱动程序。

所以我无法在同一个磁盘上的新硬件上运行我的 vagrant 脚本。

原因

原因是新显卡,NVIDIA 显卡。这张卡有一个GPU处理器,它与计算机上的每个进程挂钩,并尝试检测是否使用GPU。默认情况下,我机器上的 GPU 设置为将 GPU 连接到每个正在运行的进程。

NVIDIA 所做的这种 CPU 挂钩在某种程度上影响了 VirtualBox,VBGuestAdditions 无法正确安装驱动程序,或者至少说缺少某些东西。

解决方案

打开 NVIDIA 控制 => 3D 设置 -> 管理 3D 设置。 然后选择“程序设置”选项卡。

现在的诀窍是将VirtualBox.exe添加到下拉框中“1.选择要自定义的程序”,然后将“2.选择此程序的首选图形处理器”设置为“集成图形”

这可以解决整个问题。 Vagrant up 启动机器并且不会抛出“无法在 linux guest 中挂载文件夹”的消息

在调查了这个程序一整天后,我又开始运行了。

【讨论】:

【参考方案4】:

这在 linux 中适用于我,我认为这也可以解决 windows 中的问题。

Linux guest 安装文件夹失败快速解决方案

将以下行添加到您的 Homestead/Vagrantfile 中:

config.vbguest.auto_update = false

您的 Homestead/Vagrantfile 应如下所示:

/...

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

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

.../

保存并执行

$ vagrant destroy --force
$ vagrant up

【讨论】:

【参考方案5】:

尝试安装VBox Guest Additions 以获得文件夹共享支持,安装VirtualBox Oracle VM VirtualBox Extension Pack 以获得对某些设备的额外支持。

使用 Vagrant,你可以运行:

vagrant plugin install vagrant-vbguest
vagrant vbguest

或者安装manually。

【讨论】:

【参考方案6】:

只需从 Homestead.yaml 文件中删除 type: "nfs" 行。

发件人:

folders:
    - map: ~/Code
      to: /home/vagrant/Code
      type: "nfs"

收件人:

folders:
    - map: ~/Code
      to: /home/vagrant/Code

【讨论】:

以上是关于Laravel Homestead Vagrant - 'vboxsf' 不可用问题的主要内容,如果未能解决你的问题,请参考以下文章

VirtualBox,Vagrant和Laravel Homestead“vagrant up”错误

Vagrant Share - Laravel Homestead,Ubuntu

Laravel Homestead Vagrant - 'vboxsf' 不可用问题

Windows上使用Vagrant打造Laravel Homestead可协同跨平台开发环境

Laravel:在 Homestead Vagrant 框中浏览到 phpmyadmin

Windows上使用Vagrant打造Laravel Homestead可协同跨平台开发环境