112

Current setup: Virtualbox 5.1.20 with Vagrant 1.9.3

Previous working setup: Virtualbox 5.1.18 with Vagrant 1.9.3

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

The error output from the command was:

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.

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.

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

Alireza Noorali
  • 3,129
  • 2
  • 33
  • 80
edwardmlyte
  • 15,937
  • 23
  • 58
  • 83
  • This can also happen if you have an old box cached on your host that doesn't support the version of the vbguest plugin you have installed on your computer. [More details here](https://stackoverflow.com/a/51408047/26510) – Brad Parks Jul 18 '18 at 17:55

12 Answers12

161

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
Valdrinium
  • 1,398
  • 1
  • 13
  • 28
Daviz
  • 1,736
  • 1
  • 11
  • 12
  • Solved the identical issue (incl. versions) for me too, thanks for keeping my downtime this morning to a minimum! – Neobyte Apr 20 '17 at 07:31
  • 9
    As an FYI, here is the ticket tracking the fix of this bug https://www.virtualbox.org/ticket/16670 – edwardmlyte Apr 21 '17 at 07:14
  • 1
    This seems to be a temporary fix. I got the error again after `vagrant reload` – Frank Henard Apr 21 '17 at 15:44
  • @FrankHenard have you looked for the symlink in the VM again? Is it broken again? And does /opt/VBoxGuestAdditions-5.1.20/ exists inside the VM? – Daviz Apr 21 '17 at 16:23
  • 6
    After the reoccurence, I downgraded to 5.1.18 - problem solved ;) – Frank Henard Apr 21 '17 at 17:17
  • Solved my issues as well. Thanks. My environment: VirtualBox 5.1.20, Vagrant 1.8.7 and vagrant-vbguest 0.13.0. – Rui Marques Apr 24 '17 at 10:44
  • Thank you! How do you diagnose these guest addition problems, in general? It seems that these break quite often, and I'm left to praying that Google and SO provide some obscure answer. – kevinmm Apr 25 '17 at 20:00
  • I wish I could upvote this a billion times. Looked all day for such a simple answer. – tgig Apr 26 '17 at 04:05
  • Thanks for all the thanks and upvotes! @kevinmm I use Vagrant and VirtualBox daily since a few years. This was my first problem with the guest additions. But i use also the Vagrant plugin vbguest which does a great job with updating the guest additions inside a VM when i have updated VirtualBox. But VirtualBox has caused me pain often, with breaking compatibility with Vagrant or on OS/filesystem level. So i try updating VirtualBox not to quickly when there is a new version. ;-) – Daviz Apr 26 '17 at 06:49
  • Thank you Daviz. I wish I could send you some $$$ Locating this answer saved me during a crisis!! – Thom Parkin Apr 26 '17 at 15:20
  • Thanks @ThomParkin! Better give the $$$ to doctorswithoutborders.org or another useful NGO. – Daviz Apr 26 '17 at 16:21
  • Sadly, It didnt work for me, I got ls -lh /sbin/mount.vboxsf lrwxrwxrwx. 1 root root 42 Nov 4 2015 /sbin/mount.vboxsf -> /usr/lib64/VBoxGuestAdditions/mount.vboxsf. I reloaded but the error persists. I also upgrade to 5.1.21 following virtualbox.org/ticket/16670 because they said is fixed but the error persists. I guess I will have to downgrade to 5.1.18. – Kimy BF Apr 27 '17 at 21:07
  • @KimberlyBF, does the directory /opt/VBoxGuestAdditions-5.1.20/lib/VBoxGuestAdditions/ exist inside your VM? Replace the 5.1.20 with the version of the guest additions which you have installed inside your VM. – Daviz Apr 29 '17 at 12:07
  • 2
    have the same issue for VirtualBox 5.1.22 r115126 and Vagrant 1.9.7 – Alexiuscrow Jul 13 '17 at 11:15
  • 2
    I have the same issue with 5.1.26 – Kirill Aug 08 '17 at 05:22
  • Had the same issue in 5.2.2, but running the installer manually on VB guest additions fixed it. – tom f Dec 17 '17 at 00:30
  • Same issue in 5.2.10.. the link seems to be fine `/sbin/mount.vboxsf -> /opt/VBoxGuestAdditions-5.2.10/other/mount.vboxsf` – radtek Apr 30 '18 at 18:13
  • @radtek have you checked the link target?: `ls -alh /opt/VBoxGuestAdditions-5.2.10/other/` Does it exist and are the permissions correct? – Daviz May 02 '18 at 08:00
  • @Daviz yes the file was there, not sure about permissions. I destroyed the vm and rebuilt it to fix. – radtek May 02 '18 at 17:12
81

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

vagrant plugin install vagrant-vbguest

  • 2
    Thanks that worked! `VirtualBox 5.2.6` & `Vagrant 2.0.2` gives `GuestAdditions 5.2.6 running --- OK.` now – baikho Feb 06 '18 at 22:20
  • This question was for a specific version of virtualbox and vagrant and already stated that for those particular versions the `vagrant-vbguest` plugin did not work. – edwardmlyte Feb 13 '18 at 09:28
  • 5
    Should be the best answer. – Abdennour TOUMI Feb 14 '18 at 03:20
  • It works for me with `virtualbox 5.2.8` & `vagrant 2.0.2`. `GuestAdditions 5.2.8` installed. – Max Peng Mar 11 '18 at 13:44
  • This worked for me too - interestingly enough I already had GuestAdditions installed, but after upgrading from Vagrant v1.8 to v2.0 and VirtualBox from 5.1 to 5.2, I started getting the mount error. EVEN after `vagrant plugin update`. Re-installing the plugin this way fixed it for me. – Scott Byers Mar 28 '18 at 14:31
  • This worked for me `MacOS 10.13.4` `Virtualbox 5.2.12 and `Vagrant 2.1.1` – Jitendra Vyas May 25 '18 at 09:39
  • This worked for me. `Windows 10`, `Vagrant 2.2.5`, `Virtualbox 5.2.32`, `Geerlingguy/CentOS7`. – Cale Sweeney Jul 22 '19 at 14:30
  • This fixed my issue with Virtualbox 6.0.14, and macOS Catalina. – Arda Oct 22 '19 at 12:33
  • Yes, it works, but please explain more details. Why you did it and what that do etc – kanlukasz Feb 13 '20 at 11:58
  • I got `timed out (https://gems.hashicorp.com/specs.4.8.gz)` error. – Naeem Khoshnevis Feb 13 '21 at 22:38
  • 1
    When you already use this plugin sometimes you have to update it after a Virtualbox update: `vagrant plugin update vagrant-vbguest` – Daviz Feb 11 '22 at 14:48
  • And when the `vagrant vbguest --do install` doesn't work update packages inside the box (`vagrant ssh`) first: `sudo apt-get update && sudo apt-get upgrade`. – Daviz Mar 23 '22 at 15:08
10

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
Arif I.
  • 1,993
  • 1
  • 16
  • 14
5

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

4

This worked for me... run the following:

vagrant plugin repair

Then

vagrant plugin expunge --reinstall

Then

vagrant reload
raffi
  • 139
  • 1
  • 9
2

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).

siddhartino
  • 341
  • 3
  • 8
2

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/

mushood badulla
  • 1,043
  • 1
  • 12
  • 19
1

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

Yevgeniy Afanasyev
  • 37,872
  • 26
  • 173
  • 191
1

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.

1

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/

0

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

Community
  • 1
  • 1
Asip Asipo
  • 59
  • 1
  • 2
0

Try to use vbguest before loading the machine e after reinstalling the plugin:

vagrant plugin uninstall vagrant-vbguest
vagrant plugin install vagrant-vbguest
vagrant vbguest
vagrant up / vagrant reload
alboforlizo
  • 170
  • 1
  • 6