Saturday, July 8, 2017

vagrant mounting failed with the error: No such device

I was using CentOS 7 with vagrant. Oneday, when I ran "vagrant up", I faced an error like this:


mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant

The error output from the command was:

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

This error means mounting the shared folder failed and you can't use the shared folder for now as written in the error message.

To fix this problem, connect to the virtual machine. (Even though the mounting failed, you can still use ssh connection because vagrant up itself was succeeded. Only mounting failed.)

Then run these commands in the virtual machine with ssh connection:

$ sudo yum -y install kernel-devel kernel-headers dkms gcc gcc-c++ 
$ sudo /etc/init.d/vboxadd setup
$ sudo yum -y update kernel

If you are using CentOS 7, you don't need to run the second one "$ sudo /etc/init.d/vboxadd setup".

Then reload vagrant:

vagrant reload