Vagrantfile订购供应商问题

时间:2016-01-12 18:18:08

标签: vagrant vagrantfile vagrant-provision

我有以下流浪文件:

# -*- 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

在我的setup_script设置中,我设置了vagrant安装Virtual Box Guest Additions,这是让同步文件夹功能适用于vagrant的要求。

不幸的是,即使我将该行同步到Vagrantfile最末端的文件夹,它仍然会尝试先执行该任务,从而导致错误:

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'

我知道我需要先安装Virtual Box Guest Additions。其他人遇到这个问题?你是怎么解决这个问题的?

3 个答案:

答案 0 :(得分:0)

这是一个有趣的问题。我用相同的基本盒子驱动了一个CentOS 7 VM ......

vagrant init centos/7
vagrant up

...并且Guest Additions安装失败。这是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

因此,此基本框没有安装bzip2软件包,导致失败。出于好奇,我从ubuntu/trusty64基本框创建了一个新的Ubuntu VM,并且安装了Guest Additions没有任何问题。正如您可能猜到的那样,bzip2包已经安装在Ubuntu中。

我会将此归类为基本框本身的问题。 CentOS项目应该将bzip2烘焙到与VirtualBox一起使用的所有Vagrant基本框中。

当然,这对你现在没有帮助,但幸运的是你有many more options for CentOS base boxes,我希望他们中的大部分都不会受到这个问题的影响。

答案 1 :(得分:0)

为了解决我的问题,我刚加载了Centos框。 然后我继续安装Virtual Box Guest Additions 然后我继续重新包装盒子

这解决了我的问题。

答案 2 :(得分:0)

我在https://github.com/mitchellh/vagrant/issues/6769上使用了luvejo提示,它也适用于我:

  

您还可以安装vagrant-vbguest插件,以便添加   VirtualBox Guest Additions for you。

<link type="text/css" rel="stylesheet" href="/components/css/main.css">
     

这对我有用。

相关问题