ホストとゲストのGuestAdditionsのバージョンが異なる際に、ゲストマシンにインストールされている Guest Additionsのバージョンをアップデートしてくれるvbguestプラグイン。
ですが
vagrant vbguet
が中々実行できなかったので対応を記載します。
実行環境
OSX El Capitan 10.11.5
vagrant 1.7.4(centos6.7)
VirtualBox 5.0.28
状況
vagrant upを行おうとした際に下記のようにゲストとホストのバージョンが異なるという旨のエラーが発生しました。
vagrant up
(略)
GuestAdditions versions on your host (5.x.x) and guest (5.x.x) do not match.
(略)
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant
The error output from the last command was:
/sbin/mount.vboxsf: mounting failed with the error: No such device
これに対してvagrant vbguestを行うのは定石ですが、以下のようにエラーが発生します。
vagrant vbguest
(略)
No package kernel-devel-2.6.32-573.el6.x86_64 available.
(略)
VirtualBox Guest Additions installer
Removing installed version 5.0.28 of VirtualBox Guest Additions...
Stopping VirtualBox Additions [ OK ]
Removing existing VirtualBox non-DKMS kernel modules[ OK ]
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox non-DKMS kernel modules[ OK ]
Building the VirtualBox Guest Additions kernel modules
The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.
The missing package can be probably installed with
yum install kernel-devel-2.6.32-573.el6.x86_64
Building the main Guest Additions module[FAILED]
(Look at /var/log/vboxadd-install.log to find out what went wrong)
Doing non-kernel setup of the Guest Additions[ OK ]
対応
この場合No package kernel-devel-2.6.32-573.el6.x86_64 available.となっているパッケージをvagrantにインストールしてあげると問題が解決します。
vagrant ssh
注意して欲しい点としては普通に下記のようにkernel-develをインストールしてもバージョンが異なり解決にならないことです。パッケージを直接指定してインストールすることになります。
sudo yum -y install kernel-devel
またパッケージですがvagrantのOSにもよりますが、たとえばCentOSであれば下記リンクでインストール可能です。http://rpm.pbone.net/index.php3/stat/4/idpl/30517256/dir/scientific_linux_6/com/kernel-devel-2.6.32-573.el6.x86_64.rpm.html
(バージョン等異なると思うので適宜自分の環境にあわせて探してみて下さい。)
sudo yum -y install ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/6.6/x86_64/updates/security/kernel-devel-2.6.32-573.el6.x86_64.rpm
インストール後再びvbguest実行すると
VirtualBox Guest Additions installer
Removing installed version 5.0.28 of VirtualBox Guest Additions...
Stopping VirtualBox Additions [ OK ]
Removing existing VirtualBox non-DKMS kernel modules[ OK ]
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox non-DKMS kernel modules[ OK ]
Building the VirtualBox Guest Additions kernel modules
Building the main Guest Additions module[ OK ]
Building the shared folder support module[ OK ]
Building the graphics driver module[ OK ]
Doing non-kernel setup of the Guest Additions[ OK ]
Starting the VirtualBox Guest Additions Installing the Window System drivers
Could not find the X.Org or XFree86 Window System, skipping.
[ OK ]
成功しました!
参考になれば幸いです。