WindowsホストとVagrant上のゲスト間でディレクトリを共有する

  • Vagrantで共有フォルダのマウントに失敗するときの対処方法

http://qiita.com/ozawan/items/9751dcfd9bd4c470cd82

C:\Users\***\Vagrant\ubuntu1604>vagrant plugin install vagrant-vbguest

vagrant upすると、

Building the shared folder support module ...fail!
(Look at /var/log/vboxadd-install.log to find out what went wrong)

と表示されて、ゲスト側の/var/log/vboxadd-install.logをみると

ubuntu@ubuntu-xenial:~$ cat /var/log/vboxadd-install.log
(略)
In file included from /tmp/vbox.0/dirops.c:19:0:
/tmp/vbox.0/dirops.c: In function ‘sf_getdent’:
/tmp/vbox.0/dirops.c:129:29: error: ‘struct file’ has no member named ‘f_dentry’
sf_g = GET_GLOB_INFO(dir->f_dentry->d_inode->i_sb);
^
/tmp/vbox.0/vfsmod.h:144:60: note: in definition of macro ‘GET_GLOB_INFO’
# define GET_GLOB_INFO(sb) ((struct sf_glob_info *) (sb)->s_fs_info)
^
/tmp/vbox.0/dirops.c:135:16: error: ‘struct file’ has no member named ‘f_dentry’
inode = dir->f_dentry->d_inode;
^
scripts/Makefile.build:258: recipe for target '/tmp/vbox.0/dirops.o' failed
make[2]: *** [/tmp/vbox.0/dirops.o] Error 1
Makefile:1420: recipe for target '_module_/tmp/vbox.0' failed
make[1]: *** [_module_/tmp/vbox.0] Error 2
/tmp/vbox.0/Makefile.include.footer:79: recipe for target 'vboxsf' failed
make: *** [vboxsf] Error 2
Creating user for the Guest Additions.
Creating udev rule for the Guest Additions kernel module.

とエラーが出ている。

結論は、

default: Guest Additions Version: 4.3.4
default: VirtualBox Version: 5.1

と、VirtualBoxVirtualBox Guest Additionのバージョンがずれているからであり、
http://download.virtualbox.org/virtualbox/
にある、自分が利用しているVirtualBoxと同じバージョンのVBoxGuestAddition.isoファイルをVagrantfileのフォルダに配置して、VirtualBoxと同じバージョンのVBoxGuestAdditionがインストールされるようにする。

C:\Users\***\Vagrant\ubuntu1604>vagrant vbguest --status
[default] GuestAdditions 5.1.18 running --- OK.

デフォルトで、VagrantfileのあるフォルダがゲストOSの/vagrantにマウントされる。