Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant mount error after installing Docker

I'm getting a strange error in my vagrant VM. So I created a new ubuntu/trusty64 VM using VirtualBox (on OS X if anyone cares).

All fine there...

Then I installed Docker as per the instructions which basically involves running

wget -qO- https://get.docker.com/ | sh

That works fine too.

Then I go to reboot the VM, I exit the ssh shell, and run vagrant reload and I get this 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:

stdin: is not a tty
/sbin/mount.vboxsf: mounting failed with the error: No such device

Any thoughts?

like image 664
Peter Matev Avatar asked Jul 24 '15 17:07

Peter Matev


1 Answers

I faced similar issues. Looks like Docker (and potentially other tools) when installed will update the kernel version in your Ubuntu/Trusty64 guest. Since the VBox GuestAdditions that came preinstalled in Ubuntu/Trusty64 were specifically built against the original kernel version, the Guest Additions will stop working in the next vagrant up or vagrant reload as that's when the new kernel installed by Docker kicks in. At that point, Vagrant is no longer able to auto-mount /vagrant folder (or any synced folder for the matter) as the Guest Additions were built against a different kernel.

To get them working again you'd have to rebuild the GuestAdditions against the new kernel version that Docker installed.

Luckily, there's a plugin in Vagrant called vagrant-vbguest that takes care of automatically rebuilding the Guest Additions when the plugin detects they need to be rebuilt (i.e. like when the kernel in the guest changes, or you upgraded your VirtualBox version in the host)

So in my case, the easy way to fix it was to:

  • On the host: $ vagrant plugin install vagrant-vbguest
  • On the guest: $ sudo apt-get install linux-headers-$(uname -r)
  • On the host: $ vagrant reload

Thanks to the vagrant-vbguest plugin, new VBox GuestAdditions will be automatically rebuilt against the new version of your kernel (for which you would have downloaded the required headers in the second step above).

Once the GuestAdditions are back in shape, synchronized folders should be working again and the mapping of /vagrant should be successful.

Give it a try.

like image 121
donhector Avatar answered Oct 07 '22 22:10

donhector