[Vagrant]GuestAdditionsとvboxadd関連のエラー対応

スポンサーリンク

■背景

Vagrantで作っていたVirtualBoxのイメージを誤って消して環境を作り直しました。
vagrantfileがあるので、以下のコマンドですぐに行けるかなと思ったのですが、つまづきました。

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Available bridged network interfaces:
〜〜〜〜〜省略〜〜〜〜〜
==> default: Machine booted and ready!
[default] GuestAdditions versions on your host (5.0.26) and guest (5.0.14) do not match.
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: ftp.jaist.ac.jp
 * epel: mirror.premi.st
 * extras: ftp.jaist.ac.jp
 * ius: hkg.mirror.rackspace.com
 * updates: ftp.jaist.ac.jp
No package kernel-devel-2.6.32-573.el6.x86_64 available.
Package gcc-4.4.7-17.el6.x86_64 already installed and latest version
Package binutils-2.20.51.0.2-5.44.el6.x86_64 already installed and latest version
Package 1:make-3.81-23.el6.x86_64 already installed and latest version
Package 4:perl-5.10.1-141.el6_7.1.x86_64 already installed and latest version
Package bzip2-1.0.5-7.el6_0.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 5.0.26 - guest version is 5.0.14
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.26 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 5.0.26 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  ]
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /Users/user/work
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attemped was:
set -e
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 command was:
/sbin/mount.vboxsf: mounting failed with the error: No such device

■ポイント

  • Virtualbox Guest Additions のバージョンが合っていない
  • vboxsfが利用できない(壊れている??)
    エラーがでているけど、ssh接続はできるまでは起動できている
    sshでログインして、クライアント側で、対処する

■やったこと

  1. kernel headersのインストール

    The headers for the current running kernel were not found.

    →kernel headersがないっぽいので、インストールする

    # yum -y update kernel
    # yum -y install kernel-devel kernel-headers dkms gcc gcc-c++

    参考

    CentOSへGuest Additionsをインストールしたときのエラー対処方法
    CentOS 5.5へGuest Additionsをインストールしたときの内容です。 VirtualBoxのバージョンは4.3.10です。 エラーの内容 Guest AdditionsのCDイメージを挿入後、次のコマンドでマウントします。

    ★注意
    ログに表示されている通りに以下のコマンドをやっても、「〜〜〜573.el6.x86_64」がなくて、インストールされなかった

    # yum install kernel-devel-2.6.32-573.el6.x86_64
    
  2. vagrantの再起動
    ★これ重要!!!

  3. vboxadd setup を再実行

    $ sudo /etc/init.d/vboxadd setup
    Removing existing VirtualBox DKMS kernel modulesError! There are no instances of module: vboxguest
    5.0.26 located in the DKMS tree.
                                                           [  OK  ]
    Removing existing VirtualBox non-DKMS kernel modules       [  OK  ]
    Building the VirtualBox Guest Additions kernel modules     [  OK  ]
    Doing non-kernel setup of the Guest Additions              [  OK  ]
    You should restart your guest to make sure the new modules are actually used

    1行目は気にしなくていいのかな。

参考

https://qiita.com/murachi1208/items/1dea1416ec5729d03632

コメント

タイトルとURLをコピーしました