adbarads
adbarads

Reputation: 1303

Vagrantfile ordering provisioner issue

I have the following vagrant file:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.box = "centos/7"

  config.vm.provider "virtualbox" do |vb|
    vb.memory = "4096"
    vb.cpus = 4
    #storage
  end

  config.vm.provision "shell",
    path: "vagrant_files/setup_script.sh"

  config.vm.provision :reload

  config.vm.provision "shell",
    path: "vagrant_files/setup_script_2.sh"

  config.vm.provision :reload

  config.vm.provision "shell",
     path: "vagrant_files/setup_script_3.sh"

  config.vm.synced_folder ".", "/vagrant"

end

In my setup setup_script I have vagrant install Virtual Box Guest Additions which is a requirement to get the synced folder feature to work for vagrant.

Unfortunately, even if I put the line to sync the folders at the very end of the Vagrantfile, it still attempts to do that task first resulting in an error:

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:

mount: unknown filesystem type 'vboxsf'

I understand I need to first install the Virtual Box Guest Additions. Anyone else run into this issue? how did you all solve this problem?

Upvotes: 2

Views: 1307

Answers (3)

Tidhar Klein Orbach
Tidhar Klein Orbach

Reputation: 2966

I used luvejo tip on https://github.com/mitchellh/vagrant/issues/6769 and it worked for me as well:

You can also install the vagrant-vbguest plugin so it adds the VirtualBox Guest Additions for you.

 vagrant plugin install vagrant-vbguest 

 vagrant destroy && vagrant up

And that works for me.

Upvotes: 0

adbarads
adbarads

Reputation: 1303

To fix my issue, I just loaded the Centos box. Then I proceeded to install Virtual Box Guest Additions Then I proceeded to repackage the box

That solved my issue.

Upvotes: 0

Patrick Lee
Patrick Lee

Reputation: 2013

This is an interesting issue. I spun up a CentOS 7 VM with the same base box like so...

vagrant init centos/7
vagrant up

...and the Guest Additions installation failed. Here's the relevant output from Vagrant...

Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
mount: /dev/loop0 is write-protected, mounting read-only
Installing Virtualbox Guest Additions 5.0.10 - guest version is
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.10 Guest Additions for Linux............
VirtualBox Guest Additions installer
Copying additional installer modules ...
./install.sh: line 345: bzip2: command not found
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
./install.sh: line 358: bzip2: command not found
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors

So this base box does not have the bzip2 package installed and that causes the failure. Out of curiosity I created a new Ubuntu VM from the ubuntu/trusty64 base box and Guest Additions installed without any problem. As you might guess, the bzip2 package was already installed in Ubuntu.

I would classify this as an issue with the base box itself. The CentOS project should be baking bzip2 into all of their Vagrant base boxes that are used with VirtualBox.

Of course, this doesn't help you right now, but fortunately you have many more options for CentOS base boxes and I would expect that most of them are not affected by this issue.

Upvotes: 0

Related Questions