Vagrant
nfs

Vagrant synced_folder で nfs を使用する

More than 3 years have passed since last update.

Host OS: osx 10.11.3

Guest OS: CentOS5.9

VirtualBox 5.0.14


HostOS 側 /etc/exports に sudo NOPASS で編集できるようにする

下記を追記する

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


GuestOS側で nfs client をインストールする

sudo yum -y install nfs-utils nfs-utils-lib

下記の様にエラーログがでるので、ゲスト側に nfs-utils nfs-utils-lib をインストールする

The following SSH command responded with a non-zero exit status.

Vagrant assumes that this means the command failed!

yum -y install nfs-utils nfs-utils-lib

Stdout from the command:

Loaded plugins: fastestmirror, priorities
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=os error was
[Errno 4] IOError: <urlopen error (101, 'Network is unreachable')>

Stderr from the command:

Error: Cannot find a valid baseurl for repo: base


ホストとゲスト側の通信を StaticIPにする

config.vm.network "private_network", ip: "192.168.33.10"

下記の様なエラーログが出るので、private_network を有効にする

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