Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

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

More than 5 years have passed since last update.

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でうまくいった。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away