gpt4 book ai didi

centos - 如何通过 Vagrant 在 CentOS 中确保 HGFS?

转载 作者:行者123 更新时间:2023-12-04 19:37:28 24 4
gpt4 key购买 nike

我将 Vagrant (1.7.4) 与 VMware Fusion 提供程序一起使用。

我从 centos/7 盒子创建了一个新的虚拟机,并在我的 Vagrantfile 中配置了共享文件夹。

启动时,我收到消息

HGFS was never found on the running virtual machine. This must be installed either through VMware tools or Open VM Tools. HGFS is required for shared folders to work properly. Please install either the VMware tools or Open VM Tools and try again.



过了一会儿,系统启动了,但没有安装共享卷。

我尝试安装 Open VM 工具,使用
sudo yum -y install open-vm-tools

在我的 Vagrant Provisioner 内联 shell 脚本中
 config.vm.provision "shell", inline: <<-SHELL
sudo yum -y update
sudo yum -y install open-vm-tools
SHELL

但是,我仍然在启动时收到消息,并且看不到已安装的共享。

我有一个几乎相同的 Ubuntu 盒子(精确/64),它似乎工作得很好。

最佳答案

我查了一下盒子https://atlas.hashicorp.com/centos/boxes/7并来自 release notes他们清楚地提到没有安装虚拟盒子客人

The VirtualBox Guest Additions are not preinstalled; if you need them for shared folders, please install the vagrant-vbguest plugin. We recommend using NFS instead of VirtualBox shared folders if possible.



我认为他们应该提到的是他们也没有安装 VMWare 工具,因此与 VMWare 的默认共享文件夹不起作用。

如何为 VM 安装 VMWare 工具
  • 确保安装 cd

  • 打开 VMWare Fusion 并确保 VM 已关闭 - 打开 VM 设置,选择硬盘驱动器并添加设备,选择 CDRom。

    从 VM 菜单启动 VM 选择安装 VMWare 工具
  • 安装 VMWare 工具

  • 登录到 VM(从 VMWare 或使用 vagrant ssh 打开一个 ssh session )
  • 安装先决条件并更新内核(至少我必须运行才能在 VMWare fusion 8.0 上成功安装 VMWare 工具 - 请参阅 here)
    sudo yum install perl gcc gcc-c++ make binutils
    sudo yum update kernel

  • 重新启动并再次运行以下命令
    sudo yum install kernel-headers kernel-PAE-devel
  • 挂载 VMWare 工具

  • 这是从 VMWare doc 中找到的- 确保使用 root 运行以下命令或添加 sudo
    要创建挂载点,请运行:
    mkdir /mnt/cdrom

    要安装 CDROM,请运行:
    mount /dev/cdrom /mnt/cdrom

    要将 Compiler gzip tar 文件复制到临时本地目录,请运行:
    cp /mnt/cdrom/VMwareTools-<version>.tar.gz /tmp/

    其中 version 是 VMware Tools 软件包版本。要确定 VMware 工具的版本,请运行:
    ls /mnt/cdrom

    您会看到类似于以下内容的输出:
    VMwareTools-5.0.0-12124.tar.gz

    要切换到 tmp 目录并将 tar 文件的内容提取到名为 vmware-tools-distrib 的新目录中,请运行:
    cd /tmp
    tar -zxvf VMwareTools-version.tar.gz

    将目录更改为 vmware-tools-distrib 并运行 vmware-install.pl PERL 脚本安装 VMware Tools,运行:
    cd vmware-tools-distrib
    ./vmware-install.pl

    毕竟,工具已安装并且共享文件夹正常工作。

    作为旁注,我可以说用 packer 构建一个盒子要容易得多。并直接从 install 安装工具。 github 上有大量适用于所有版本的 centos 的打包程序模板。

    关于centos - 如何通过 Vagrant 在 CentOS 中确保 HGFS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39662731/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com