ドルヲタ系インフラエンジニア じーふーの備忘録

クラウドをメインに扱うインフラエンジニアが書くメモやら雑感、たまにドルヲタ的活動記録残します。最近の推しはAzureのData Factory(V2)です。

【vagrant】 Vagrant up時に ゲストOSのGuest Additions moduleビルドに失敗する

vagrant up時にプラグインvagrant-vbguest」をインストールしておくと、ゲストOSのVirtualBox Guest Additionsのバージョンチェック&更新をしてくれる。
しかし、利用しているBoxイメージによってはkernelのversionが古いためにGuest Additions moduleのビルドに失敗する様子。

そのため、この状態では共有ディレクトリのマウントに失敗します。
対応方法をいろんな人が同じような記事を書いていますが自分もメモ。

環境

実行時のログ

C:\Users\hoge\03.development\201505_redmine>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos_6.5'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: 201505_redmine_default_1430182361123_21382
==> 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: 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: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
GuestAdditions versions on your host (4.3.26) and guest (4.3.6) do not match.
Loaded plugins: fastestmirror, versionlock
Determining fastest mirrors
 * base: ftp.nara.wide.ad.jp
 * epel: mirrors.vinahost.vn
 * extras: ftp.nara.wide.ad.jp
 * updates: ftp.nara.wide.ad.jp
http://mirrors.vinahost.vn/epel/6/x86_64/repodata/cfcca6b966c751e691f3d49fed9be85b67cda7962b4a9b20666ce98d640263ab-primary.sqlite.bz2: [Errno 12] Timeout on http://mirrors.vinahost.vn/epel/6/x86_64/re
podata/cfcca6b966c751e691f3d49fed9be85b67cda7962b4a9b20666ce98d640263ab-primary.sqlite.bz2: (28, 'Operation too slow. Less than 1 bytes/sec transfered the last 30 seconds')
Trying other mirror.
Setting up Install Process
No package kernel-devel-2.6.32-431.3.1.el6.x86_64 available.
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
--> Processing Dependency: gcc = 4.4.7-4.el6 for package: gcc-gfortran-4.4.7-4.el6.x86_64
--> Processing Dependency: gcc = 4.4.7-4.el6 for package: gcc-c++-4.4.7-4.el6.x86_64
---> 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
--> Processing Dependency: cpp = 4.4.7-11.el6 for package: gcc-4.4.7-11.el6.x86_64
--> Processing Dependency: libgcc >= 4.4.7-11.el6 for package: gcc-4.4.7-11.el6.x86_64
---> Package perl.x86_64 4:5.10.1-136.el6 will be updated
--> Processing Dependency: perl = 4:5.10.1-136.el6 for package: 1:perl-Pod-Simple-3.13-136.el6.x86_64
--> Processing Dependency: perl = 4:5.10.1-136.el6 for package: 3:perl-version-0.77-136.el6.x86_64
--> Processing Dependency: perl = 4:5.10.1-136.el6 for package: 1:perl-Module-Pluggable-3.90-136.el6.x86_64
--> Processing Dependency: perl = 4:5.10.1-136.el6 for package: 1:perl-Pod-Escapes-1.04-136.el6.x86_64
--> Processing Dependency: perl = 4:5.10.1-136.el6 for package: 4:perl-libs-5.10.1-136.el6.x86_64
---> Package perl.x86_64 4:5.10.1-136.el6_6.1 will be an update
--> Running transaction check
---> Package cpp.x86_64 0:4.4.7-4.el6 will be updated
---> Package cpp.x86_64 0:4.4.7-11.el6 will be an update
---> Package gcc-c++.x86_64 0:4.4.7-4.el6 will be updated
---> Package gcc-c++.x86_64 0:4.4.7-11.el6 will be an update
--> Processing Dependency: libstdc++-devel = 4.4.7-11.el6 for package: gcc-c++-4.4.7-11.el6.x86_64
--> Processing Dependency: libstdc++ = 4.4.7-11.el6 for package: gcc-c++-4.4.7-11.el6.x86_64
---> Package gcc-gfortran.x86_64 0:4.4.7-4.el6 will be updated
---> Package gcc-gfortran.x86_64 0:4.4.7-11.el6 will be an update
--> Processing Dependency: libgfortran = 4.4.7-11.el6 for package: gcc-gfortran-4.4.7-11.el6.x86_64
---> Package libgcc.x86_64 0:4.4.7-4.el6 will be updated
---> Package libgcc.x86_64 0:4.4.7-11.el6 will be an update
---> Package libgomp.x86_64 0:4.4.7-4.el6 will be updated
---> Package libgomp.x86_64 0:4.4.7-11.el6 will be an update
---> Package perl-Module-Pluggable.x86_64 1:3.90-136.el6 will be updated
---> Package perl-Module-Pluggable.x86_64 1:3.90-136.el6_6.1 will be an update
---> Package perl-Pod-Escapes.x86_64 1:1.04-136.el6 will be updated
---> Package perl-Pod-Escapes.x86_64 1:1.04-136.el6_6.1 will be an update
---> Package perl-Pod-Simple.x86_64 1:3.13-136.el6 will be updated
---> Package perl-Pod-Simple.x86_64 1:3.13-136.el6_6.1 will be an update
---> Package perl-libs.x86_64 4:5.10.1-136.el6 will be updated
---> Package perl-libs.x86_64 4:5.10.1-136.el6_6.1 will be an update
---> Package perl-version.x86_64 3:0.77-136.el6 will be updated
---> Package perl-version.x86_64 3:0.77-136.el6_6.1 will be an update
--> Running transaction check
---> Package libgfortran.x86_64 0:4.4.7-4.el6 will be updated
---> Package libgfortran.x86_64 0:4.4.7-11.el6 will be an update
---> Package libstdc++.x86_64 0:4.4.7-4.el6 will be updated
---> Package libstdc++.x86_64 0:4.4.7-11.el6 will be an update
---> Package libstdc++-devel.x86_64 0:4.4.7-4.el6 will be updated
---> Package libstdc++-devel.x86_64 0:4.4.7-11.el6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                  Arch      Version                    Repository  Size
================================================================================
Updating:
 gcc                      x86_64    4.4.7-11.el6               base        10 M
 perl                     x86_64    4:5.10.1-136.el6_6.1       updates     10 M
Updating for dependencies:
 cpp                      x86_64    4.4.7-11.el6               base       3.7 M
 gcc-c++                  x86_64    4.4.7-11.el6               base       4.7 M
 gcc-gfortran             x86_64    4.4.7-11.el6               base       4.7 M
 libgcc                   x86_64    4.4.7-11.el6               base       102 k
 libgfortran              x86_64    4.4.7-11.el6               base       267 k
 libgomp                  x86_64    4.4.7-11.el6               base       133 k
 libstdc++                x86_64    4.4.7-11.el6               base       294 k
 libstdc++-devel          x86_64    4.4.7-11.el6               base       1.6 M
 perl-Module-Pluggable    x86_64    1:3.90-136.el6_6.1         updates     40 k
 perl-Pod-Escapes         x86_64    1:1.04-136.el6_6.1         updates     32 k
 perl-Pod-Simple          x86_64    1:3.13-136.el6_6.1         updates    212 k
 perl-libs                x86_64    4:5.10.1-136.el6_6.1       updates    578 k
 perl-version             x86_64    3:0.77-136.el6_6.1         updates     51 k

Transaction Summary
================================================================================
Upgrade      15 Package(s)

Total download size: 37 M
Downloading Packages:
--------------------------------------------------------------------------------
Total                                           219 kB/s |  37 MB     02:51
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : libgcc-4.4.7-11.el6.x86_64                                  1/30
  Updating   : libstdc++-4.4.7-11.el6.x86_64                               2/30
  Updating   : libstdc++-devel-4.4.7-11.el6.x86_64                         3/30
  Updating   : 1:perl-Pod-Escapes-1.04-136.el6_6.1.x86_64                  4/30
  Updating   : 3:perl-version-0.77-136.el6_6.1.x86_64                      5/30
  Updating   : 4:perl-libs-5.10.1-136.el6_6.1.x86_64                       6/30
  Updating   : 1:perl-Module-Pluggable-3.90-136.el6_6.1.x86_64             7/30
  Updating   : 1:perl-Pod-Simple-3.13-136.el6_6.1.x86_64                   8/30
  Updating   : 4:perl-5.10.1-136.el6_6.1.x86_64                            9/30
  Updating   : cpp-4.4.7-11.el6.x86_64                                    10/30
  Updating   : libgfortran-4.4.7-11.el6.x86_64                            11/30
  Updating   : libgomp-4.4.7-11.el6.x86_64                                12/30
  Updating   : gcc-4.4.7-11.el6.x86_64                                    13/30
  Updating   : gcc-c++-4.4.7-11.el6.x86_64                                14/30
  Updating   : gcc-gfortran-4.4.7-11.el6.x86_64                           15/30
  Cleanup    : gcc-c++-4.4.7-4.el6.x86_64                                 16/30
  Cleanup    : gcc-gfortran-4.4.7-4.el6.x86_64                            17/30
  Cleanup    : libstdc++-devel-4.4.7-4.el6.x86_64                         18/30
  Cleanup    : 1:perl-Module-Pluggable-3.90-136.el6.x86_64                19/30
  Cleanup    : 1:perl-Pod-Simple-3.13-136.el6.x86_64                      20/30
  Cleanup    : 1:perl-Pod-Escapes-1.04-136.el6.x86_64                     21/30
  Cleanup    : 3:perl-version-0.77-136.el6.x86_64                         22/30
  Cleanup    : 4:perl-libs-5.10.1-136.el6.x86_64                          23/30
  Cleanup    : 4:perl-5.10.1-136.el6.x86_64                               24/30
  Cleanup    : gcc-4.4.7-4.el6.x86_64                                     25/30
  Cleanup    : libstdc++-4.4.7-4.el6.x86_64                               26/30
  Cleanup    : libgcc-4.4.7-4.el6.x86_64                                  27/30
  Cleanup    : cpp-4.4.7-4.el6.x86_64                                     28/30
  Cleanup    : libgomp-4.4.7-4.el6.x86_64                                 29/30
  Cleanup    : libgfortran-4.4.7-4.el6.x86_64                             30/30
  Verifying  : libstdc++-4.4.7-11.el6.x86_64                               1/30
  Verifying  : libgcc-4.4.7-11.el6.x86_64                                  2/30
  Verifying  : libstdc++-devel-4.4.7-11.el6.x86_64                         3/30
  Verifying  : 1:perl-Pod-Escapes-1.04-136.el6_6.1.x86_64                  4/30
  Verifying  : 3:perl-version-0.77-136.el6_6.1.x86_64                      5/30
  Verifying  : libgomp-4.4.7-11.el6.x86_64                                 6/30
  Verifying  : 4:perl-libs-5.10.1-136.el6_6.1.x86_64                       7/30
  Verifying  : gcc-c++-4.4.7-11.el6.x86_64                                 8/30
  Verifying  : 1:perl-Module-Pluggable-3.90-136.el6_6.1.x86_64             9/30
  Verifying  : 4:perl-5.10.1-136.el6_6.1.x86_64                           10/30
  Verifying  : gcc-4.4.7-11.el6.x86_64                                    11/30
  Verifying  : 1:perl-Pod-Simple-3.13-136.el6_6.1.x86_64                  12/30
  Verifying  : libgfortran-4.4.7-11.el6.x86_64                            13/30
  Verifying  : cpp-4.4.7-11.el6.x86_64                                    14/30
  Verifying  : gcc-gfortran-4.4.7-11.el6.x86_64                           15/30
  Verifying  : 1:perl-Module-Pluggable-3.90-136.el6.x86_64                16/30
  Verifying  : gcc-gfortran-4.4.7-4.el6.x86_64                            17/30
  Verifying  : 4:perl-5.10.1-136.el6.x86_64                               18/30
  Verifying  : libstdc++-4.4.7-4.el6.x86_64                               19/30
  Verifying  : libstdc++-devel-4.4.7-4.el6.x86_64                         20/30
  Verifying  : cpp-4.4.7-4.el6.x86_64                                     21/30
  Verifying  : 1:perl-Pod-Simple-3.13-136.el6.x86_64                      22/30
  Verifying  : libgfortran-4.4.7-4.el6.x86_64                             23/30
  Verifying  : gcc-c++-4.4.7-4.el6.x86_64                                 24/30
  Verifying  : libgomp-4.4.7-4.el6.x86_64                                 25/30
  Verifying  : gcc-4.4.7-4.el6.x86_64                                     26/30
  Verifying  : 3:perl-version-0.77-136.el6.x86_64                         27/30
  Verifying  : 1:perl-Pod-Escapes-1.04-136.el6.x86_64                     28/30
  Verifying  : 4:perl-libs-5.10.1-136.el6.x86_64                          29/30
  Verifying  : libgcc-4.4.7-4.el6.x86_64                                  30/30

Updated:
  gcc.x86_64 0:4.4.7-11.el6           perl.x86_64 4:5.10.1-136.el6_6.1

Dependency Updated:
  cpp.x86_64 0:4.4.7-11.el6
  gcc-c++.x86_64 0:4.4.7-11.el6
  gcc-gfortran.x86_64 0:4.4.7-11.el6
  libgcc.x86_64 0:4.4.7-11.el6
  libgfortran.x86_64 0:4.4.7-11.el6
  libgomp.x86_64 0:4.4.7-11.el6
  libstdc++.x86_64 0:4.4.7-11.el6
  libstdc++-devel.x86_64 0:4.4.7-11.el6
  perl-Module-Pluggable.x86_64 1:3.90-136.el6_6.1
  perl-Pod-Escapes.x86_64 1:1.04-136.el6_6.1
  perl-Pod-Simple.x86_64 1:3.13-136.el6_6.1
  perl-libs.x86_64 4:5.10.1-136.el6_6.1
  perl-version.x86_64 3:0.77-136.el6_6.1

Complete!
Copy iso file C:\Program Files/Oracle/VirtualBox/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Installing Virtualbox Guest Additions 4.3.26 - guest version is 4.3.6
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.26 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.3.1.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
Could not find the X.Org or XFree86 Window System, skipping.
An error occurred during installation of VirtualBox Guest Additions 4.3.26. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
Restarting VM to apply changes...
==> default: Attempting graceful shutdown of VM...
==> 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: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/keisuke.fujikawa/03.development/201505_redmine
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

C:\Users\hoge\03.development\201505_redmine>

問題個所

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.3.1.el6.x86_64

Building the main Guest Additions module[FAILED]
(Look at /var/log/vboxadd-install.log to find out what went wrong)

対策

ずばり、kernel-devel-2.6.32-431.3.1.el6.x86_64インストール

自分は下記サイトからrpm取得。

http://rpm.pbone.net/index.php3?stat=26&dist=43&size=9182560&name=kernel-devel-2.6.32-431.3.1.el6.x86_64.rpm

結果

C:\Users\hoge\03.development\201505_redmine>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> 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: 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: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
GuestAdditions versions on your host (4.3.26) and guest (4.3.6) do not match.
Loaded plugins: fastestmirror, versionlock
Loading mirror speeds from cached hostfile
 * base: ftp.nara.wide.ad.jp
 * epel: mirrors.vinahost.vn
 * extras: ftp.nara.wide.ad.jp
 * updates: ftp.nara.wide.ad.jp
Setting up Install Process
Package gcc-4.4.7-11.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_6.1.x86_64 already installed and latest version
Nothing to do
Copy iso file C:\Program Files/Oracle/VirtualBox/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Installing Virtualbox Guest Additions 4.3.26 - guest version is 4.3.6
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.26 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 4.3.26 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  ]
Starting the VirtualBox Guest Additions [  OK  ]
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.26. 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: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/hoge/03.development/201505_redmine
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: to force provisioning. Provisioners marked to run always will still run.

C:\Users\hoge\03.development\201505_redmine>