2

我有以下流浪文件:

# -*- 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 install 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。还有其他人遇到这个问题吗?你们都是怎么解决这个问题的?

4

3 回答 3

0

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

这解决了我的问题。

于 2016-01-20T00:12:08.090 回答
0

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

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

 vagrant plugin install vagrant-vbguest 

 vagrant destroy && vagrant up

这对我有用。

于 2017-02-26T10:10:03.670 回答
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 基础盒子中。

当然,现在这对你没有帮助,但幸运的是你有更多的 CentOS 基础盒选择,我希望它们中的大多数不会受到这个问题的影响。

于 2016-01-12T23:01:42.673 回答