Vagrant使用NFS共享文件夹

/ 0评 / 3

windows下默认虚拟机共享文件夹的方式因为磁盘IO效率太低,打开网站都需要好几秒,可以让windows支持NFS方式共享文件夹给vagrant虚拟机来解决问题

安装vagrant插件

  1. <span class="pln">$vagrant plugin install vagrant</span><span class="pun">-</span><span class="pln">winnfsd</span>

会报错提示缺少childprocess-0.5.8.gem,直接下载

  1. <span class="pln">https</span><span class="pun">:</span><span class="com">//rubygems.org/gems/childprocess-0.5.8.gem</span>
  2. <span class="pln">https</span><span class="pun">:</span><span class="com">//rubygems.org/gems/vagrant-winnfsd-1.1.0.gem</span>

安装:

  1. <span class="pln">$vagrant plugin install childprocess</span><span class="pun">-</span><span class="lit">0.5</span><span class="pun">.</span><span class="lit">8.gem</span>
  2. <span class="pln">$vagrant plugin install vagrant</span><span class="pun">-</span><span class="pln">winnfsd</span><span class="pun">-</span><span class="lit">1.1</span><span class="pun">.</span><span class="lit">0.gem</span>

查看插件

  1. <span class="pln">$vagrant plugin list</span>
  2. <span class="pln">childprocess </span><span class="pun">(</span><span class="lit">0.5</span><span class="pun">.</span><span class="lit">8</span><span class="pun">)</span>
  3. <span class="pln"> </span><span class="pun">-</span><span class="pln"> </span><span class="typ">Version</span><span class="pln"> </span><span class="typ">Constraint</span><span class="pun">:</span><span class="pln"> </span><span class="lit">0.5</span><span class="pun">.</span><span class="lit">8</span>
  4. <span class="pln">vagrant</span><span class="pun">-</span><span class="pln">share </span><span class="pun">(</span><span class="lit">1.1</span><span class="pun">.</span><span class="lit">5</span><span class="pun">,</span><span class="pln"> system</span><span class="pun">)</span>
  5. <span class="pln">vagrant</span><span class="pun">-</span><span class="pln">winnfsd </span><span class="pun">(</span><span class="lit">1.1</span><span class="pun">.</span><span class="lit">0</span><span class="pun">)</span>
  6. <span class="pln"> </span><span class="pun">-</span><span class="pln"> </span><span class="typ">Version</span><span class="pln"> </span><span class="typ">Constraint</span><span class="pun">:</span><span class="pln"> </span><span class="lit">1.1</span><span class="pun">.</span><span class="lit">0</span>

配置

  1. <span class="pln">config</span><span class="pun">.</span><span class="pln">vm</span><span class="pun">.</span><span class="pln">network </span><span class="str">"private_network"</span><span class="pun">,</span><span class="pln"> ip</span><span class="pun">:</span><span class="pln"> </span><span class="str">"192.168.8.8"</span>
  2. <span class="pln">config</span><span class="pun">.</span><span class="pln">vm</span><span class="pun">.</span><span class="pln">synced_folder </span><span class="str">"/"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"/vagrant"</span><span class="pun">,</span><span class="pln"> type</span><span class="pun">:</span><span class="pln"> </span><span class="str">"nfs"</span>
来自为知笔记(Wiz)