Vagrant 文件订购供应器问题

Vagrant 文件订购供应器问题,vagrant,vagrantfile,vagrant-provision,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",

我有以下流浪汉档案:

# -*- 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
在我的安装脚本中,我有vagrant安装虚拟箱来宾添加,这是让同步文件夹功能为vagrant工作的一个要求

不幸的是,即使我将同步文件夹的行放在Vagrant文件的末尾,它仍然会首先尝试执行该任务,从而导致错误:

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'

我知道我需要首先安装虚拟机。还有其他人遇到过这个问题吗?你们是如何解决这个问题的?

这是一个有趣的问题。我用同一个基本盒旋转了一个CentOS 7虚拟机,就像这样

vagrant init centos/7
vagrant up
…并且来宾添加安装失败。这是流浪汉的相关输出

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
base框中创建了一个新的ubuntuvm,并且没有任何问题地安装了Guest Additions。正如您可能猜到的,Ubuntu中已经安装了
bzip2

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


当然,这目前对您没有帮助,但幸运的是您已经这样做了,我希望他们中的大多数不会受到此问题的影响。

要解决我的问题,我只加载了Centos框。 然后,我继续安装虚拟箱来宾添加 然后我开始重新包装这个盒子

这就解决了我的问题。

我使用了luvejo tip on,它对我也很有效:

您还可以安装vagrant vbguest插件,以便它添加 为您添加VirtualBox来宾

 vagrant plugin install vagrant-vbguest 

 vagrant destroy && vagrant up
这对我很有用


一种可能(不是很聪明)是使用并执行类似于
config.vbguest.auto_update=false config.vm.provision“shell”、inline config.trigger.after:up do run“vagrant vbguest--auto reboot--no provision”的操作。我认为这是一个好主意,应该可以工作。实际上,我还没有听说过“流浪触发器”插件。谢谢你的提醒!