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

走远了吗. 提交于 2019-12-02 17:04:50

This problem is solved in VirtualBox 5.1.18.

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

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.

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"

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.

Downgrade to Virtual Box 5.1.14 from 5.1.16 works fine.

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

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.

user3369245

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.

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!