“流浪者”无法挂载 VirtualBox 共享文件夹

当前设置: Virtualbox 5.1.20流浪者1.9.3

以前的工作设置: Virtualbox 5.1.18流浪者1.9.3

我安装了 Virtualbox 的最新版本,并尝试启动我的 VM。文件夹挂载已停止工作。相同的文件夹安装在 Virtualbox 5.1.18中工作得很好。我得到以下错误消息:

“流浪者”无法挂载 VirtualBox 共享文件夹。这通常是因为文件系统“ vboxsf”不可用。这个文件系统可以通过 VirtualBoxGuestAdtions 和内核模块获得。请验证这些客户端附加功能是否正确地安装在客户端中。这不是一个错误在流浪者,通常是由一个有缺陷的流浪者盒子造成的。对于上下文,尝试执行的命令是:

 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确实解决了这个问题,但这并不是向前发展的理想选择。

如何使用 Virtualbox 5.1.20流浪者1.9.3安装文件夹?

89831 次浏览

Update

Fixed in VirtualBox 5.1.22.

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

Original answer

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

$ vagrant ssh

Then:

$ 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

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

Now logout of the VM:

$ exit

And check if it works for you:

$ vagrant reload

But i can't fix the link because /sbin/mount.vboxsf does not exist inside my box!

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:

  • Halt all your running VMs.
  • Open the VirtualBox program.
  • Start the download of the VirtualBox Extension Pack and install it.
  • If you are not being asked if you want to download the VirtualBox Extension Pack, open ->File ->Check for Update, to trigger the download dialog.

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

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

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

Log into the box:

$ vagrant ssh

Ran the installer manually:

$ sudo /mnt/VBoxLinuxAdditions.run

A last hope: 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

Removing type: "nfs" from homestead.yaml fixed it for me. Win 10, Vagrant 1.9.7, laravel 5.4, homestead.

For me the following commands followed by a reboot of the guest system helped:

cd /opt/VBoxGuestAdditions-*/init
sudo ./vboxadd setup

I found the solution here. Referring to this post you need to stop vboxadd before triggering the commands (I didn't do so since I don't know what vboxadd is).

Installing the vbguest plugin worked in my case with VirtualBox 5.2.6 and Vagrant 2.0.1:

vagrant plugin install vagrant-vbguest

This worked for me... run the following:

vagrant plugin repair

Then

vagrant plugin expunge --reinstall

Then

vagrant reload

For those who land here with almost the same problem as me, below is the solution

TLDR

  • VirtualBox guest fail because of system is currently not set up to build kernel modules
  • Solution is uninstall kernel-headers.x86_64 0:3.10.0-862.9.1.el7
  • Then install kernel-devel-3.10.0-327.el7.x86_64

Solution

  1. vagrant ssh

  2. sudo rpm -e kernel-devel-3.10.0-862.9.1.el7.x86_64

  3. sudo wget ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/7.0/x86_64/updates/security/kernel-devel-3.10.0-327.el7.x86_64.rpm //download the file

  4. sudo rpm -Uvh kernel-devel-3.10.0-327.el7.x86_64.rpm //use the file downloaded on step 3

  5. exit

  6. vagrant reload

Details: Problem

  1. Do vagrant up but fail with similar error except

The error output from the command was:

/sbin/mount.vboxsf: mounting failed with the error: No such device

  1. Do further reading of the logs and I notice below key words

Installing Virtualbox Guest Additions 5.2.16 - guest version is 5.1.10

An error occurred during installation of VirtualBox Guest Additions

This system is currently not set up to build kernel modules.

Please install the Linux kernel "header" files matching the current kernel

packages containing the headers are probably: kernel-devel kernel-devel-3.10.0-327.el7.x86_64

  1. Read logs further

Package kernel-headers.x86_64 0:3.10.0-862.9.1.el7 will be installed

No package kernel-devel-3.10.0-327.el7.x86_64 available.

  1. My guest is I need kernel-devel-3.10.0-327.el7.x86_64 to works

Details: My environment

  • bento/centos-7.2
  • vagrant version: 2.0.4
  • virtual box version: 5.2.16

Sources

For me, the problem was fixed under the following conditions:

Environment:

  • VirtualBox version 6.0.4r128413
  • Vagrant version 2.2.3

Steps:

Go to your project directory from the terminal or command line (cd) and run the following commands:

  1. vagrant plugin install vagrant-vbguest to install the Vagrant VB Guest Plugin

  2. vagrant up

If you get an error regarding vboxsf not being available. Then maybe your VirtualBox Guest Additions are not installed properly. Hopefully, the commands below will fix your problem.

vagrant ssh
sudo yum -y install kernel-devel
sudo yum update -y
exit
vagrant halt
vagrant up --provision

What I had to do was run the following command to add nfs to windows

vagrant plugin install vagrant-winnfsd

Source: https://peshmerge.io/how-to-speed-up-vagrant-on-windows-10-using-nfs/

The accepted did not worked on my case.

My issue was:
Virtualhost guest addition (on guest machine) installed using command (on host machine):

vagrant plugin install vagrant-vbguest

was not matching the installed version of virtualbox on host machine and I kept getting this error.

enter image description here

This command (on host machine) helped me to understand more clearly:

vagrant vbguest --status

It will verify if guest additions on both host and guest machine are consistent. If you get, Guest additions did not match warning then SSH into your virtual machine and run the below command first to install the guest additions inside your machine:

sudo apt-get install virtualbox-guest-x11

Then, you can force to install the correct version of guest additions on both host and guest using below command:

vagrant vbguest --do install

You have to reload the virtual machine after that:

vagrant reload

Now you can confirm if they match using below command again:

vagrant vbguest --status

References 1
References 2

Run this command:

 vagrant vbguest --do install --no-cleanup

It is possible that you have the answer (An error occurred during installation of VirtualBox Guest Additions x.x.x. Some functionality may not work as intended. In most cases it is OK that the "Window System drivers" installation failed.)

Don't worry, it will work.

My solution is for centos7 boxes. The vbguest additions folder was not being mounted. This is related to the outdated kernel in the box you are using.

Add the following line to your vm definitions:

config.vm.define "centos7" do |box|
box.vbguest.installer_options = { allow_kernel_upgrade: true }

Update your vagrant vm:

vagrant up --provision

This way the kernel will be updated, and the guest additions mounted and installed. You will see a reboot in the process. Source: https://www.puppeteers.net/blog/fixing-vagrant-vbguest-for-the-centos-7-base-box/