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.
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.
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
Download centos 7
vagrant init centos/7
vagrant up
vagrant ssh
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
Package new box
vagrant package --base my-virtual-machine
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With