VirtualBoxとVagrantをバージョンアップする


# VirtualBoxとVagrantをバージョンアップする

|    項目    |      バージョン      |
| :--------- | :------------------- |
| ホストOS   | CentOS 6.5 x86_64    |
| VirtualBox | 4.3.12 → **4.3.20** |
| Vagrant    | 1.6.3 → **1.7.2**   |

## VirtualBoxのバージョンアップ

- VirtualBoxおよびVirtualBox Extension Packをダウンロードしてバージョンアップする
    + <https://www.virtualbox.org/wiki/Downloads>
- VirtualBox Extension Packは`[ファイル]->[環境設定]->[機能拡張]`にインストールする

```shell-session
# rpm -Uvh VirtualBox-4.3-4.3.20_96996_el6-1.x86_64.rpm
警告 VirtualBox-4.3-4.3.20_96996_el6-1.x86_64.rpm: ヘッダ V4 DSA/SHA1 Signature, key ID 98ab5139: NOKEY
準備中...                ########################################### [100%]
   1:VirtualBox-4.3         ########################################### [100%]

Creating group 'vboxusers'. VM users must be member of that group!

No precompiled module for this kernel found -- trying to build one. Messages
emitted during module compilation will be logged to /var/log/vbox-install.log.

Stopping VirtualBox kernel modules [  OK  ]
Recompiling VirtualBox kernel modules [  OK  ]
Starting VirtualBox kernel modules [  OK  ]
#
```

- バージョンの確認

```shell-session
# VBoxManage -v
4.3.20r96996
```

- 仮想マシンに導入されているVirtualBox Guest Additionsをバージョンアップする

```shell-session
# vagrant vbguest --status
GuestAdditions versions on your host (4.3.20) and guest (4.3.12) do not match.
#
# vagrant vbguest --do install
GuestAdditions versions on your host (4.3.20) and guest (4.3.12) do not match.
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Package 1:make-3.81-20.el6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-4.el6 will be updated
---> Package gcc.x86_64 0:4.4.7-11.el6 will be an update
--> Processing Dependency: libgomp = 4.4.7-11.el6 for package: gcc-4.4.7-11.el6.x86_64

（途中省略）

Complete!
Copy iso file /usr/share/virtualbox/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Forcing installation of Virtualbox Guest Additions 4.3.20 - guest version is 4.3.12
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.20 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 4.3.12 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[  OK  ]
Doing non-kernel setup of the Guest Additions[  OK  ]
You should restart your guest to make sure the new modules are actually used

Installing the Window System drivers
Installing X.Org Server 1.13 modules[  OK  ]
Setting up the Window System to use the Guest Additions[  OK  ]
You may need to restart the hal service and the Window System (or just restart
the guest system) to enable the Guest Additions.

Installing graphics libraries and desktop services components[  OK  ]
An error occurred during installation of VirtualBox Guest Additions 4.3.20. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
```

- 仮想マシンのyum設定でリポジトリパスが不正だと以下エラーが出力される

```shell-session
# vagrant vbguest --do install
GuestAdditions versions on your host (4.3.20) and guest (4.3.12) do not match.
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
 * base: ftp.yz.yamagata-u.ac.jp
 * extras: ftp.yz.yamagata-u.ac.jp
 * updates: ftp.yz.yamagata-u.ac.jp
file:///mnt/cdrom/repodata/repomd.xml: [Errno 14] Could not open/read file:///mnt/cdrom/repodata/repomd.xml
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: CentOS-dvd. Please verify its path and try again
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

yum install -y kernel-devel-`uname -r` gcc make perl

Stdout from the command:

Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
 * base: ftp.yz.yamagata-u.ac.jp
 * extras: ftp.yz.yamagata-u.ac.jp
 * updates: ftp.yz.yamagata-u.ac.jp


Stderr from the command:

file:///mnt/cdrom/repodata/repomd.xml: [Errno 14] Could not open/read file:///mnt/cdrom/repodata/repomd.xml
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: CentOS-dvd. Please verify its path and try again
```
## Vagrantのバージョンアップ

- Vagrantをダウンロードしてバージョンアップする
    + <https://www.vagrantup.com/downloads.html>

```shell-session
# rpm -Uvh vagrant_1.7.2_x86_64.rpm
```

- バージョンの確認

```shell-session
# vagrant -v
Vagrant 1.7.2
```

- プラグインをアップデートする

```shell-session
# vagrant plugin update
```

- プラグインのアップデートでエラーが発生した場合は、アンインストールして再インストールする

```shell-session
# vagrant plugin update
Updating installed plugins...
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

Net::HTTPNotFound: No gems found matching "vagrant-vmware-workstation" "3.0.1" nil
# 
# vagrant plugin list
sahara (0.0.17)
vagrant-hostsupdater (0.0.11)
vagrant-share (1.1.3, system)
vagrant-vbguest (0.10.0)
vagrant-vbox-snapshot (0.0.8)
#
# vagrant plugin uninstall sahara
Uninstalling the 'sahara' plugin...
# vagrant plugin uninstall vagrant-vbguest
Uninstalling the 'vagrant-vbguest' plugin...
# vagrant plugin uninstall vagrant-vbox-snapshot
Uninstalling the 'vagrant-vbox-snapshot' plugin...
# 
# vagrant plugin install sahara
Installing the 'sahara' plugin. This can take a few minutes...
Installed the plugin 'sahara (0.0.17)'!
# vagrant plugin install vagrant-vbguest
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vbguest (0.10.0)'!
# vagrant plugin install vagrant-vbox-snapshot
Installing the 'vagrant-vbox-snapshot' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vbox-snapshot (0.0.8)'!
# 
# vagrant plugin update
Updating installed plugins...
All plugins are up to date.
```