如何使用 VirtualBox 在 Vagrant 中启用双向文件夹同步?
How to enable two-way folder sync in Vagrant with VirtualBox?
我已经有一段时间没有在 Linux 上使用 Vagrant 了。当我开始使用新版本 (Vagrant 1.8) 时,我遇到了一个问题:在来宾 VM 中创建的文件没有出现在主机的同步文件夹中。
如何强制 Vagrant 将文件从访客 OS 同步到主机 OS?
根据文档,当未指定 Vagrantfile 中的 type
选项 config.vm.synced_folder
参数时,Vagrant 会尝试选择最佳可用选项:
type
(string) - The type of synced folder. If this is not specified, Vagrant will automatically choose the best synced folder option for your environment. Otherwise, you can specify a specific type such as "nfs".
从版本 1.5 Vagrant introduced 新 "rsync synced folders" 功能开始。
因此在我的例子中自动选择了类型 rsync
,这是一种单向同步:从主机到来宾。
为了使文件夹双向同步,我在我的 Vagrantfile 中添加了显式定义:
config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
当然,这仅适用于 VirtualBox。
双向同步对于工作流很有用,其中应用程序在来宾计算机上创建文件,例如,现代 Web 框架中的数据库迁移文件。
注意:当您的项目包含大量文件时,virtualbox 同步文件夹存在已知的性能问题。
感谢这正是我过去几天一直在寻找的东西!!!!!!!我遇到了 Laravel 5、homestead 和 vagrant 的问题。那里有很多答案,但 none 对我有用。我的 yaml 文件的文件夹部分也有 rsync,我也必须将其删除。在这两个更改之后,文件共享终于在主机和客户端之间为我同步了。
require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')
config.vm.synced_folder ".", "/vagrant", 输入:"virtualbox"
Vagrant.configure(VAGRANTFILE_API_VERSION) 执行 |config|
这是我对 Vagranfile 进行更改的地方。
我已经有一段时间没有在 Linux 上使用 Vagrant 了。当我开始使用新版本 (Vagrant 1.8) 时,我遇到了一个问题:在来宾 VM 中创建的文件没有出现在主机的同步文件夹中。
如何强制 Vagrant 将文件从访客 OS 同步到主机 OS?
根据文档,当未指定 Vagrantfile 中的 type
选项 config.vm.synced_folder
参数时,Vagrant 会尝试选择最佳可用选项:
type
(string) - The type of synced folder. If this is not specified, Vagrant will automatically choose the best synced folder option for your environment. Otherwise, you can specify a specific type such as "nfs".
从版本 1.5 Vagrant introduced 新 "rsync synced folders" 功能开始。
因此在我的例子中自动选择了类型 rsync
,这是一种单向同步:从主机到来宾。
为了使文件夹双向同步,我在我的 Vagrantfile 中添加了显式定义:
config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
当然,这仅适用于 VirtualBox。
双向同步对于工作流很有用,其中应用程序在来宾计算机上创建文件,例如,现代 Web 框架中的数据库迁移文件。
注意:当您的项目包含大量文件时,virtualbox 同步文件夹存在已知的性能问题。
感谢这正是我过去几天一直在寻找的东西!!!!!!!我遇到了 Laravel 5、homestead 和 vagrant 的问题。那里有很多答案,但 none 对我有用。我的 yaml 文件的文件夹部分也有 rsync,我也必须将其删除。在这两个更改之后,文件共享终于在主机和客户端之间为我同步了。
require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')
config.vm.synced_folder ".", "/vagrant", 输入:"virtualbox"
Vagrant.configure(VAGRANTFILE_API_VERSION) 执行 |config|
这是我对 Vagranfile 进行更改的地方。