44
44

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Vagrant+VirtualBox+nfsを使ってsynced_folderを設定する

Last updated at Posted at 2014-03-30

#Vagrant + VirtualBoxでsynced_folderをnfsでマウントした時のメモ

##環境
Mac OS X 10.9.2
Vagrant 1.5.1
VirtualBox 4.3.10

##やること

  • Mac側の設定
  • VagrantFileの設定
  • トラブルシューティング

Mac側の設定

$ sudo nfsd status
nfsd service is enabled
nfsd is running (pid 2140, 8 threads)

立ち上がってない場合は

$ sudo nfsd enable

で、OK。
次に、/etc/exportsが必要なのでこれを作る。

$ sudo touch /etc/exports

VagrantFileの設定

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  ...
  config.vm.synced_folder ".", "/vagrant", type: "nfs"
  ...
end

これでvagrant upすればゲストOSの/vagrantフォルダにホストOSのVagrantFileのあるディレクトリがマウントされる。

トラブルシューティング

vagrant up時に

NFS requires a host-only network to be created.
Please add a host-only network to the machine (with either DHCP or a
static IP) for NFS to work.

って言われたら
VagrantFile

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  ...
  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  config.vm.network "private_network", ip: "192.168.33.10"
  ...
end

ここでprivate_networkを設定すれば良い。
ipは適宜変更で。

よーしvagrant reloadだ。

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o 'vers=3,udp' 192.168.33.1:'/path/to/hoge' /vagrant

Stdout from the command:



Stderr from the command:

mount.nfs: rpc.statd is not running but is required for remote locking.
mount.nfs: Either use '-o nolock' to keep locks local, or start statd.
mount.nfs: an incorrect mount option was specified

と言われる。
このへんでも同様の議論されてる。

とりあえずvagrant reloadでうまくいった。

44
44
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
44
44

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?