5
5

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.

OSX + Vagrant 1.7.3 + CentOS 7.1 で Synced Folder をNFSにすると失敗した話

Last updated at Posted at 2015-07-14

ということなんですよ奥さん。

後述するけどたぶんこれは上書きインストール時のライブラリ類がちゃんと更新できなかった問題に近いと思う。バージョンアップ時にはご注意ください。

経緯

利用した Box は boxcutter/centos71 です。

タイトルの通りなんですが、Synced Folder を type => "nfs" で指定すると以下のように失敗します。


...


GuestAdditions 5.0.0 running --- OK.
==> dev: Checking for guest additions in VM...
==> dev: Configuring and enabling network interfaces...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

/etc/init.d/rpcbind restart; /etc/init.d/nfs restart

Stdout from the command:



Stderr from the command:

bash: line 2: /etc/init.d/rpcbind: No such file or directory
bash: line 2: /etc/init.d/nfs: No such file or directory

共有ディレクトリにコード置いてMacでコード書いてVM上でサーバ立ててってやりたかったのに、Vagrant デフォルトの Synced Folder設定では激重で使い物にならない。bundle exec rake unicorn:start でデーモン起動に数分かかるレベルである。「よろしい、ならばNFSだ」というわけでNFSにしてみたらうまくいかなかった。

原因

よくわからなかったが、問題の箇所は特定できた。

sudo vi /opt/vagrant/embedded/gems/gems/vagrant-1.7.3/plugins/guests/redhat/cap/nfs_client.rb

こいつの systemd? メソッドによる判定に失敗しているのだ。

         def self.systemd?
           `ps -o comm= 1`.chomp == 'systemd'
         end

うーん???? これVM上で実行してちゃんと ps -o comm= 1 の結果は systemd 帰ってくるけどなぁ???

って本家をみたら https://github.com/mitchellh/vagrant/blob/master/plugins/guests/redhat/cap/nfs_client.rb ・・・一瞬何が違うのかどうかわからなかったが、これはよーするにあれか。VMの中で実行しなきゃいけないコードをローカルで実行しちゃってるってことかな。そりゃ、うまくいかないよ。うん。

まあよし。お前はこうしてやる。俺が用があるのはCentOS7だけだ。つまり、systemd かどうかはお前が判定する必要はなく俺が知っているということだ。

         def self.systemd?
           true
         end

直したら動いた

よかったよかった。

...


==> dev: Machine booted and ready!
GuestAdditions 5.0.0 running --- OK.
==> dev: Checking for guest additions in VM...
==> dev: Configuring and enabling network interfaces...
==> dev: Exporting NFS shared folders...
==> dev: Preparing to edit /etc/exports. Administrator privileges will be required...
==> dev: Mounting NFS shared folders...
==> dev: Mounting shared folders...
    dev: /vagrant => /Users/ma2saka/vagrant

教訓

バージョン番号が一致しているからといってコードまでちゃんと最新化されているとは限らない。

$ vagrant --version
Vagrant 1.7.3

たぶん、https://www.vagrantup.com から Mac OS X 用のバイナリを落としてきてバージョンアップしたときに、このあたりのファイルが上書きされずに古いの残ってたんじゃないかなーと想像する。が、確認するのも面倒くさいので脳内ではクローズ。とりあえず「バージョンアップには注意しましょう」ということでひとつ。

5
5
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
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?