環境
- macOS High Sierra 10.13.4
- Vagrant 2.0.1
- CentOS 6.9
症状
特に macOS も vagrant もアップグレードしたわけでもないのに、mac を再起動して vagrant up したら、急に以下のエラーが出て vagrant 上と mac で sync してたフォルダがマウント出来ないと言われた。
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'bento/centos-6.9' is up to date...
==> default: A newer version of the box 'bento/centos-6.9' is available! You currently
==> default: have version '201710.25.0'. The latest is version '201805.15.0'. Run
==> default: `vagrant box update` to update.
.
.
(省略)
.
.
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Mounting shared folders...
default: /vagrant => /Users/minako/centos69_php71
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:
mount -t vboxsf -o uid=500,gid=500 vagrant /vagrant
The error output from the command was:
/sbin/mount.vboxsf: mounting failed with the error: No such device
んんん?mac 再起動前は問題なく動いていたのに……?
原因と解決策
どうやらホストOSとゲストOSのカーネルのバージョンが食い違うために起こる、らしい?いつの間に食い違ったの……?
参考サイトの通り、プラグインを入れて解決してもらうことにしました。
$ vagrant plugin install vagrant-vbguest
とすると、
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Fetching: vagrant-share-1.1.9.gem (100%)
Fetching: micromachine-2.0.0.gem (100%)
Fetching: vagrant-vbguest-0.15.2.gem (100%)
Installed the plugin 'vagrant-vbguest (0.15.2)'!
おお、なんか入ったっぽい。
んで、vagrant reload すると予期に計らってくれたようです。
$ vagrant reload
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box 'bento/centos-6.9' is up to date...
==> default: A newer version of the box 'bento/centos-6.9' is available! You currently
==> default: have version '201710.25.0'. The latest is version '201805.15.0'. Run
==> default: `vagrant box update` to update.
.
.
(省略)
.
.
==> default: Machine booted and ready!
[default] No installation found.
Loaded plugins: fastestmirror
Setting up Install Process
Determining fastest mirrors
* base: ftp.nara.wide.ad.jp
* extras: ftp.nara.wide.ad.jp
* remi-safe: mirrors.mediatemple.net
* updates: ftp.nara.wide.ad.jp
Package gcc-4.4.7-18.el6_9.2.x86_64 already installed and latest version
Package binutils-2.20.51.0.2-5.47.el6_9.1.x86_64 already installed and latest version
Package 1:make-3.81-23.el6.x86_64 already installed and latest version
Package 4:perl-5.10.1-144.el6.x86_64 already installed and latest version
Package bzip2-1.0.5-7.el6_0.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package kernel-devel.x86_64 0:2.6.32-696.30.1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
kernel-devel x86_64 2.6.32-696.30.1.el6 updates 11 M
Transaction Summary
================================================================================
Install 1 Package(s)
Total download size: 11 M
Installed size: 26 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : kernel-devel-2.6.32-696.30.1.el6.x86_64 1/1
Verifying : kernel-devel-2.6.32-696.30.1.el6.x86_64 1/1
Installed:
kernel-devel.x86_64 0:2.6.32-696.30.1.el6
Complete!
Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Mounting Virtualbox Guest Additions ISO to: /mnt
Installing Virtualbox Guest Additions 5.2.2 - guest version is unknown
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.2.2 Guest Additions for Linux........
VirtualBox Guest Additions installer
Removing installed version 5.1.30 of VirtualBox Guest Additions...
vboxadd.sh: Stopping VirtualBox Additions.
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Starting.
/etc/init.d/vboxadd: line 256: : No such file or directory
Unmounting Virtualbox Guest Additions ISO from: /mnt
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Mounting shared folders...
default: /vagrant => /Users/hoge/centos
default: /home/vagrant/common => /Users/hoge/common
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
vagrant 上の同期フォルダを確認すると、無事ディレクトリが表示されました。
参考
vagrantのshared folderのmountに失敗してしまった場合 https://qiita.com/ak-ymst/items/bdc37aaf53f857d37fcc