Vagrant BoxのGuest Additonsのアップデート方法


[Vagrantbox.es](http://www.vagrantbox.es/)からCentOSのBoxをダウンロードし、
`vagrant up`
を行ったら以下のようなエラーが表示された。

```
GuestAdditions versions on your host (4.3.6) and guest (4.3.4) do not match.
...
[default] Attempting graceful shutdown of VM...
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Mounting shared folders...
[default] -- /vagrant
Failed to mount folders in Linux guest. This is usually beacuse
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly.
...
```
これだと共有フォルダが使えないので、早速ググってみると。
[VagrantのboxのGuest Additionsのアップデート方法](http://qiita.com/isaoshimizu/items/e217008b8f6e79eccc85)
というのを見つけたので早速その通りに

```
$ vagrant plugin install vagrant-vbguest
$ vagrant vbguest
```
を実行。
しかし、結果は

```
$ vagrant vbguest
GuestAdditions versions on your host (4.3.6) and guest (4.3.4) do not match.
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
Setting up Install Process
No package kernel-devel-2.6.32-431.el6.x86_64 available.
Package gcc-4.4.7-4.el6.x86_64 already installed and latest version
Package 1:make-3.81-20.el6.x86_64 already installed and latest version
Package 4:perl-5.10.1-136.el6.x86_64 already installed and latest version
Nothing to do
Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Installing Virtualbox Guest Additions 4.3.6 - guest version is 4.3.4
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.6 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 4.3.6 of VirtualBox Guest Additions...
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-431.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  ]
Installing the Window System drivers[FAILED]
(Could not find the X.Org or XFree86 Window System.)
An error occurred during installation of VirtualBox Guest Additions 4.3.6. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
```
となりエラーになってしまう。
どうも
`yum install kernel-devel-2.6.32-431.el6.x86_64`
でkernelがインストールできないのが問題のよう。
試しに
`vagrant ssh`
でゲストOSに接続し
`sudo yum install kernel-devel-2.6.32-431.el6.x86_64`
を実行すると。

```
$ sudo yum install kernel-devel-2.6.32-431.el6.x86_64
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
Setting up Install Process
No package kernel-devel-2.6.32-431.el6.x86_64 available.
Error: Nothing to do
```
となってしまう。
ここからログの確認やいろいろググってみて最終的に行き着いた結果が以下のサイトである。
[Linux - Yum Install GCC - Missing Kernel-headers - Stackoverflow](http://stackoverflow.com/questions/6513731/linux-yum-install-gcc-missing-kernel-headers)
この回答のように設定の変更を行う。
まず
`$ vagrant ssh`
でゲストOSに接続し

`$ sudo vi /etc/yum.conf`
を実行
`exclude=kernel*`
を
`#exclude=kernel*`
に変更保存し、
`$ exit`
でゲストOSとの接続を切断する。
そして

```
$ vagrant halt
$ vagrant up
```
で再起動すると

```
GuestAdditions versions on your host (4.3.6) and guest (4.3.4) do not match.
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.kddilabs.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
Setting up Install Process
Package gcc-4.4.7-4.el6.x86_64 already installed and latest version
Package 1:make-3.81-20.el6.x86_64 already installed and latest version
Package 4:perl-5.10.1-136.el6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package kernel-devel.x86_64 0:2.6.32-431.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package              Arch           Version                 Repository    Size
================================================================================
Installing:
 kernel-devel         x86_64         2.6.32-431.el6          base         8.7 M

Transaction Summary
================================================================================
Install       1 Package(s)

Total download size: 8.7 M
Installed size: 24 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : kernel-devel-2.6.32-431.el6.x86_64                           1/1
  Verifying  : kernel-devel-2.6.32-431.el6.x86_64                           1/1

Installed:
  kernel-devel.x86_64 0:2.6.32-431.el6

Complete!
Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Installing Virtualbox Guest Additions 4.3.6 - guest version is 4.3.4
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.6 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 4.3.6 of VirtualBox Guest Additions...
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 OpenGL support module[FAILED]
(Look at /var/log/vboxadd-install.log to find out what went wrong)
Doing non-kernel setup of the Guest Additions[  OK  ]
Installing the Window System drivers[FAILED]
(Could not find the X.Org or XFree86 Window System.)
An error occurred during installation of VirtualBox Guest Additions 4.3.6. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
[default] Mounting shared folders...
[default] -- /vagrant
```
とでてアップデートができた。