Vagrantのプラグインの1つに、vagrant-vbguestプラグインがあります。
これは仮想環境がVirtualBoxの場合、vagrant up
したときに自動的にGuestAdditionsをインストールしてくれるとても便利なプラグインです。
今までは仮想マシンにGuestAdditionsをインストールするのに一つずつ設定をしなければならなかったのでとても助かっています。
ところが、vagrant-vbguest
プラグインをインストールし、vagrant up
したときに以下のようなエラーが発生しました。
$ vagrant up
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
対処方法
ググったところ、こちらの記事がヒットしたのでをこの記事を参考に対応しました。
$ vagrant ssh
[vagrant@centos-test ~]$ sudo /etc/init.d/vboxadd setup
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 ]
さらにエラーが発生したのでググったところ、kernelをyumで更新する必要があるみたいです。
[vagrant@centos-test ~]$ 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: www.ftp.ne.jp
* epel: ftp.riken.jp
* extras: www.ftp.ne.jp
* updates: www.ftp.ne.jp
Setting up Install Process
No package kernel-devel-2.6.32-431.el6.x86_64 available.
Error: Nothing to do
yumでアップデートしたくてもパッケージが無いようです。
さらにググると、こちらの記事がヒットしたので、参考にして対応しました。
$ sudo vim /etc/yum.conf
- exclude=kernel*
+ #exclude=kernel*
$ exit
$ vagrant halt
これで再びvagrant up
すると、正常にGuestAdditionsがインストールされました。
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos65'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: chef_repo_server_default_1400143482917_83865
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Error: Connection timeout. Retrying...
==> default: Machine booted and ready!
GuestAdditions versions on your host (4.3.10) and guest (4.3.6) do not match.
Loaded plugins: fastestmirror, versionlock
Determining fastest mirrors
* base: www.ftp.ne.jp
* epel: ftp.kddilabs.jp
* extras: www.ftp.ne.jp
* updates: www.ftp.ne.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.3.1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
kernel-devel x86_64 2.6.32-431.3.1.el6 updates 8.8 M
Transaction Summary
================================================================================
Install 1 Package(s)
Total download size: 8.8 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.3.1.el6.x86_64 1/1
Verifying : kernel-devel-2.6.32-431.3.1.el6.x86_64 1/1
Installed:
kernel-devel.x86_64 0:2.6.32-431.3.1.el6
Complete!
Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Installing Virtualbox Guest Additions 4.3.10 - guest version is 4.3.6
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.10 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[ 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
Could not find the X.Org or XFree86 Window System, skipping.
An error occurred during installation of VirtualBox Guest Additions 4.3.10. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => /vagrant/centos
なお、
今回事象が発生したのは、vagrant-centosというBoxファイルでしたが、
現在はそのエラーが解消されていますので、同じ現象が起こらないと思います。
Lock in the package versions kernel-* · e7ac773 · 2creatives/vagrant-centos