Friday, April 11, 2014

Vagrant can't mount shared folder in VirtualBox 4.3.10 Fix

Setting up Virtualbox/Vagrant today on a new Windows 7 PC and ran into this problem while that my host directory wouldn't mount /vagrant during vagrant up.

jbisbee@jbisbeewin7:~/vagrant/test$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'hashicorp/precise64' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
GuestAdditions seems to be installed (4.3.10) correctly, but not running.
stdin: is not a tty
Starting the VirtualBox Guest Additions ...done.
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => C:/cygwin64/home/jbisbee/vagrant/test
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

First thing I did was ssh to the vm and run the commands:

vagrant@precise64:~$ sudo mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` /vagrant /vagrant
mount: Protocol error
vagrant@precise64:~$ sudo mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` /vagrant /vagrant
mount: Protocol error

After just getting "Protocol error", I looked at the syslog and seeing "sf_read_super_aux err=-71".

Apr 11 17:56:40 precise64 kernel: [   18.253255] sf_read_super_aux err=-71
Apr 11 17:56:40 precise64 kernel: [   18.344137] sf_read_super_aux err=-71

Now googling this error, I found Vagrant Bug #3341 from 15 days ago and the missing symlink that caused it all

vagrant@precise64:~$ sudo ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions

Success! :)

jbisbee@jbisbeewin7:~/vagrant/test$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'hashicorp/precise64' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
GuestAdditions 4.3.10 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => C:/cygwin64/home/jbisbee/vagrant/test
==> default: VM already provisioned. Run `vagrant provision` or use `--provision` to force it



8 comments:

  1. Replies
    1. This comment is the exact reason I wrote this blog post. Cheers!

      Delete
    2. the problem is that for every new box that i will need to set up i will have to to do this?

      Delete
    3. Look at packing your box from this post. http://www.skoblenick.com/vagrant/creating-a-custom-box-from-scratch/. I think you can get the box, apt-get update/dist-upgrade, fix the symlink, then create a new box image you can use going forward.

      Delete
  2. Don't work for me with this box: https://vagrantcloud.com/nrel/CentOS-6.5-x86_64 (version 1.2.0)
    Has, some idea to fix it?

    Thank's!

    ReplyDelete
    Replies
    1. Yeah, no idea there. I only was using the precise64 box.

      Delete