# Homestead 开启 NFS 后启动需要密码

# Homestead 开启 NFS

在 Homestead 中配置 NFS




 

folders:
    - map: ~/code
      to: /home/vagrant/code
      type: "nfs"

使用 vagrant reload --provision 重启 Homestead,此时终端提示需要密码。

根据 Vagrant 文档 NFS - Synced Folders | Vagrant by HashiCorp 赋予 ROOT 权限

# 赋予 ROOT 权限

对于 OS X

vim /etc/sudoers.d/vagrant-syncedfolders
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports
%admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE

# 参考