MAC开启 NFS 文件系统提升 Vagrant 共享目录的性能

Vagrant虚拟机系统:CentOS6.5

首先要把虚拟机的网络设置成 :private_network 模式。

1、虚拟机安装nfs服务:

centos 5 :

yum -y install nfs-utils portmap

centos 6 :

yum -y install nfs-utils rpcbind

2、MAC OS已经集成nfs,只需要修改/etc/eprots文件,如果没有则新建

sudo vi /etc/exports   保持空文件即可

3、Vagrantfile文件修改

config.vm.synced_folder ".", "/vagrant", type: “nfs"

保存后,使用命令 vagrant reload 重启虚拟机后才会生效,期间会修改MAC OX的 /etc/exports 文件。会提示输入mac账号的密码。输入即可!

2015-02-02最新更新:vagrant官方说明中发现了一段内同

        NFS synced folders have a set of options that can be specified that are unique to NFS. These are listed below. These options can be specified in the final part of theconfig.vm.synced_folder definition, along with the type option.

  • nfs_export (boolean) – If this is false, then Vagrant won’t modify your /etc/exportsautomatically and assumes you’ve done so already.
  • nfs_udp (boolean) – Whether or not to use UDP as the transport. UDP is faster but has some limitations (see the NFS documentation for more details). This defaults to true.
  • nfs_version (string | integer) – The NFS protocol version to use when mounting the folder on the guest. This defaults to 3.

可以设置 nfs_export的属性为true即可忽略文件的修改,会假设已经把文件设置好。

默认采用的是UDP协议。

NFS协议使用的版本:默认为3