[Vagrant & VirtualBox] Vagrant: synced_folder を nfs マウントする
Mac OS X のみです。
[markdown]
準備をしていないと、`vagrant up` 時にこんなエラーが表示されます。
“`prettyprinted
It appears your machine doesn’t support NFS, or there is not an
adapter to enable NFS on this machine for Vagrant. Please verify
that `nfsd` is installed on your machine, and try again. If you’re
on Windows, NFS isn’t supported. If the problem persists, please
contact Vagrant support.
“`
> * [NFS – Synced Folders – Vagrant Documentation](https://docs.vagrantup.com/v2/synced-folders/nfs.html)
“`prettyprinted
% vagrant –version
Vagrant 1.6.2
% virtualbox –help
Oracle VM VirtualBox Manager 4.3.12
(C) 2005-2014 Oracle Corporation
All rights reserved.
“`
## 設定
nfsd が立ち上がっているかを確認します。
“`prettyprinted
% sudo /sbin/nfsd status
nfsd service is enabled
nfsd is not running
“`
Vagrant がディフォルトで利用する /etc/exports を作成します。
“`prettyprinted
% sudo touch /etc/exports
“`
## Vagrantfile
synced_folder に NFS の設定を加える。
この場合は、Vagrantfile よりひとつ上の /dist フォルダが、/var/www/html としてマウントされます。
“`ruby:Vagrantfile
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = “chef/centos-6.5”
config.vm.provision :shell, :path => “provision.sh”
config.vm.network :private_network, ip: “192.168.33.10”
# synced_folder for Mac OS X
# config.vm.synced_folder “../dist”, “/var/www/html/wordpress/wp-content/themes/wptheme”, :nfs => true
config.vm.synced_folder “../dist”, “/var/www/html/”, type: “nfs”
end
“`
あとは `vagrant up` すればOK。
同じエラーが出る場合は、terminal.app を再起動するとうまくいくかも。
## 補遺
> * [Vagrant + VirtualBox で nfs を使って、synced_folder を速くする – Shin x blog](http://www.1×1.jp/blog/2013/08/vagrant_synced_folder_with_nfs.html)
> * [Vagrant+VirtualBox+nfsを使ってsynced_folderを設定する – Qiita](http://qiita.com/EaleLove777/items/b7a7d1a671106cd1a78a)
[/markdown]