Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant was unable to mount VirtualBox shared folders

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?

like image 511
edwardmlyte Avatar asked Apr 19 '17 09:04

edwardmlyte


2 Answers

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 
like image 156
Daviz Avatar answered Sep 19 '22 11:09

Daviz


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

vagrant plugin install vagrant-vbguest

like image 41
Miguel Angel Mendoza Avatar answered Sep 18 '22 11:09

Miguel Angel Mendoza