Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant error "Failed to mount folders in Linux guest" after halt or reload

I'm trying to use a Vagrant box from someone else, and it works fine when I first start it, but after I stop it and restart it with either vagrant halt and vagrant up, or vagrant reload, I get the following error message:

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

Right now, searching for this error message turns up a lot of people having trouble with a bug Virtual Box 4.3.10, but that's not the problem I'm having.

like image 322
Tom Panning Avatar asked Jan 16 '15 20:01

Tom Panning


3 Answers

It turns out, upgrading the Linux kernel will cause the Virtual Box Guest Additions to stop working until they are rebuilt by running the following command in the VM

sudo /etc/init.d/vboxadd setup

I had upgraded the kernel without thinking about it when I ran yum update (similar to apt-get upgrade) to get updates to other software.

Alternatively, if you install the dkms package as described here, then the kernel module should be automatically updated when the kernel is updated.

like image 104
Tom Panning Avatar answered Nov 04 '22 00:11

Tom Panning


To fix this issue virtual box addition has to be installed. For example, I use Centos 7. Firstly download centos 7 minimal and then install guest addition, please see all steps below

  1. Download centos 7

    vagrant init centos/7

    vagrant up

    vagrant ssh

  2. Install Guest addition for virtual box

    yum update

    reboot

    vagrant ssh

    yum update kernel

    reboot

    vagrant ssh

    yum groupinstall "Development tools"

    yum install kernel-devel

    yum install wget

    wget http://download.virtualbox.org/virtualbox/5.0.2/VBoxGuestAdditions_5.0.2.iso

    sudo mkdir /media/VBoxGuestAdditions

    sudo mount -o loop,ro VBoxGuestAdditions_5.0.2.iso /media/VBoxGuestAdditions

    sudo sh /media/VBoxGuestAdditions/VBoxLinuxAdditions.run rm VBoxGuestAdditions_5.0.2.iso

    sudo umount /media/VBoxGuestAdditions

    sudo rmdir /media/VBoxGuestAdditions

    sudo /etc/init.d/vboxadd setup

    sudo chkconfig --add vboxadd

    sudo chkconfig vboxadd on

    exit

  3. Package new box

    vagrant package --base my-virtual-machine

like image 5
Kate Avatar answered Nov 04 '22 00:11

Kate


Hit the same issue, but with a different fix: I already had dkms installed (virtualbox-guest-dkms under Debian Jessie).

The thing was that the module «vboxsf» wasn't loaded automatically, and running mount shared_directory didn't work (No such file or directory error).

But after running modprobe vboxsf, the mounting was fine.

So I edited /etc/modules and appended vboxsf on a new line: problem solved!

Side note: if running modprobe vboxsf ends up on a error, you don't have the vboxsf module installed, so you should install DKMS module first.

like image 2
Yvan Avatar answered Nov 03 '22 23:11

Yvan