我的同步文件夹工作不正常,它们在启动时被同步一次,但是当我在主机上进行更改时,vagrant不会实时同步它 .
首先是我系统的一些细节:
-
操作系统:Linux Mint 18 Sarah
-
Virtualbox版本:5.0.24-dfsg-0ubuntu1.16.04.1
-
Vagrant版本:1.9.0
-
vagrant-hostmanager(1.8.5)
-
vagrant-share(1.1.6)
-
vagrant-vbguest(0.13.0)
在我们开始讨论之前,我没有使用最新版本的Virtualbox,因为它不在存储库中而且简单的 vagrant up
失败了 .
我的Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "private_network", ip: "192.168.88.88"
config.vm.hostname = "my.centos.dev"
end
vagrant up
给了我this .
现在,当我在主机上创建一个文件时:
falnyr@mint:~/centos-vagrant $ ls
ansible Vagrantfile
falnyr@mint:~/centos-vagrant $ touch file.txt
falnyr@mint:~/centos-vagrant $ ls
ansible file.txt Vagrantfile
和客机上的ssh:
falnyr@mint:~/centos-vagrant $ vagrant ssh
[vagrant@my ~]$ ls /vagrant/
ansible Vagrantfile
如您所见,未创建该文件 . 当我执行 vagrant reload
时,在机器启动期间再次执行同步 .
注意:我不能使用NFS同步,因为我需要跨平台就绪环境 .
有关如何启用实时同步的任何想法?
4 回答
默认情况下,该框的所有者已在同步类型上启用
rsync
. 如果你查看你的盒子的Vagrantfile(在我的情况下是~/.vagrant.d/boxes/centos-VAGRANTSLASH-7/0/vmware_fusion
但你的可能在虚拟机提供者下面),你会看到一个包含内容的Vagrantfile只需从box目录中删除此文件即可 .
请注意,如果您打算使用nfs,则可以更改Vagrantfile中的同步类型
您可以使用
rsync-auto
命令:实际上,当我遇到同步问题时,添加
type: nfs
帮助了我:您可以从文档中阅读更多信息:https://www.vagrantup.com/docs/synced-folders/rsync.html
只需使用
Vagrant.configure("2") do |config| #place here end
内的第2和第3行If Anyone is Facing this issue vbox "Syncing/Mount" just enter the Vagrant ssh where the vagrant file is without vagrant up and run the command "sudo yum upgrade" dat'll Take time once it'll get finished exit the vagrant and hit vagrant up again.Issue will resolved. .. :)
并确保如果您正在使用Centos,请在您的VagrantFile List项目中使用“Bento / Centos”