diguage
diguage

Reputation: 397

Vagrant error: Failed to mount folders in Linux guest

I have a vagrant error. The log as follows:

vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> 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: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /Users/diguage/box/centos
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

I Google it. StackOverflow had the same question:

Vagrant error : Failed to mount folders in Linux guest

I did it as the top answer: here. The different is that I downloaded the VBoxGuestAdditions_4.3.18.iso. But it did not work.

I try the second answer: here. It also did not work.

So, I have to ask the question.

My environment is :

PS:

I used the box chef / centos-6.5. I first start the box, it was OK. But I sudo yum update,then sudo yum clean, restart the box, export the error.

Upvotes: 4

Views: 2868

Answers (3)

Gilson Araujo
Gilson Araujo

Reputation: 74

I have experienced this using Vagrant 1.8.1, VirtualBox 5.0.18, Chef 12.10.10 host MacOSX El Capitan and guest CentOS7. I tried installing kernel-devel inside the guest, installing the latest GuestAdittions and running yum update, but none of these worked for me, so I changed the mount type for "nfs" in both my custom synced folders and chef temporary folder, and it worked!

In Vagrantfile, my synced folders:

config.vm.synced_folder ".", "/vagrant", type: "nfs"

and my chef_solo config:

chef.cookbooks_path = ["chef/cookbooks/"]
chef.synced_folder_type = "nfs"

Upvotes: 0

zhulinpinyu
zhulinpinyu

Reputation: 629

Use Following is work fine for me.

vagrant plugin install vagrant-vbguest

Upvotes: 6

patrickbarker
patrickbarker

Reputation: 393

I was having the same problem with the same setup, I noticed the problem is only with centos 6.5, so I am using chef/centos-6.6 and it has been working fine. There is very little difference between 6.5 and 6.6, so you shouldn't have any problems migrating your code over. Here's the link to the chef boxes.

EDIT

Ok, I ended up needing a 6.5 box, so I worked through it. The core issue is that the CentOS base repo doesn't include kernel headers(Ubuntu does). You first need to add the appropriate repos to your /etc/yum.repos.d/CentOS-Vault.repo, and you need to enable them. What you append should look something like this:

[C6.5-centosplus]
name=CentOS-6.5 - CentOSPlus
baseurl=http://vault.centos.org/6.5/centosplus/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=1

You also need to check the /etc/yum.conf file and make sure there aren't any exclusions such as:

exclude=kernel*

if so comment this out for the time being, but make sure to uncomment it at the end.

Now, you can install the necessary headers for the kernel. The headers depend on kernel-devel, so lets grab that up first.

yum install kernel-devel-$(uname -r)

Then, grab up the headers

yum install kernel-headers-$(uname -r)

Finally, you'll need the dkms package

yum install dkms

Go back and uncomment the exclusions in yum.conf and you should be good to reboot. With only that installed you could then use:

vagrant package --base MyBase

This will give you a reusable CentOS 6.5 box that you can grab on demand. Hope this wasn't too late for you.

Upvotes: 2

Related Questions