ネット偽善者でもいいじゃない

悩んでるなら面白いマンガ読もう

VirtualBoxを使ってcentOSに入ろうとするがvagrant upでエラーがおきてしまう

久しぶりに開発環境にログインしようとすると Vagrant upしてcentOSにログインする際にエラーが起きてしまう

VirtualBoxが2015年2月12日にversion 4.3.22にversion up したらしく新しいのをインストールしてしまったのが 原因っぽい・・・

結局仮想開発環境を一旦削除して対応したけどまた環境構築からなのでめんどくさかった(´;ω;`)

ちなみに再び環境を整えようと思ってvagrant up までいったとこで似たようなエラーを吐き出しましたが

vagrant-vbguestプラグインがGuestAdditionsを無効にしてしまう - Qiita

を参考にしたら解決しました

$ 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

The error output from the last command was:

/sbin/mount.vboxsf: mounting failed with the error: No such device

みたいなエラーが出るので、上記リンクを参考にして

$ vagrant ssh -c 'sudo yum update -y kernel'
$ vagrant reload
$ vagrant vbguest --status

としてやると無事

GuestAdditions 4.3.22 running --- OK.

と無事表示されました

ちゃんと出来てるか気になる方は

$ vagrant ssh
$ sudo /etc/init.d/vboxadd setup

してやるとうまくいくか確認出来ます

尚、ここより下は解決前の、仮想開発環境を消す前に色々やってみたけど解決しなかったやつです(´;ω;`)

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

調べてみると、いくつかQiitaさんのところの記事などが見つかるが

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

Vagrant mountエラー - Logicky Blog

どうもこれでも解決しない・・・・ $ vagrant vbguest

のコマンドを実行してみても

GuestAdditions versions on your host (4.3.22) and guest (4.3.8) do not match.
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.nara.wide.ad.jp
 * epel: ftp.cuhk.edu.hk
 * extras: ftp.nara.wide.ad.jp
 * updates: ftp.nara.wide.ad.jp
パッケージ kernel-devel-2.6.32-504.8.1.el6.x86_64 はインストール済みか最新バージョンです
パッケージ gcc-4.4.7-11.el6.x86_64 はインストール済みか最新バージョンです
パッケージ 1:make-3.81-20.el6.x86_64 はインストール済みか最新バージョンです
パッケージ 4:perl-5.10.1-136.el6_6.1.x86_64 はインストール済みか最新バージョンです
何もしません
Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Installing Virtualbox Guest Additions 4.3.22 - guest version is 4.3.8
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.22 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 4.3.22 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[失敗]
(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.22. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.

となってしまうなんだこれ・・・

$ vagrant sshしてみる

とりあえず $ vagrant ssh でゲストマシンにログイン

$ sudo /etc/init.d/vboxadd setup してみると

Removing existing VirtualBox DKMS kernel modules           [  OK  ]
Removing existing VirtualBox non-DKMS kernel modules       [  OK  ]
Building the VirtualBox Guest Additions kernel modules
Building the main Guest Additions module                   [失敗]
(Look at /var/log/vboxadd-install.log to find out what went wrong)
Doing non-kernel setup of the Guest Additions              [  OK  ]

と出る。 Look at /var/log/vboxadd-install.log to find out what went wrong と出ているので見てみる

$ cat /var/log/vboxadd-install.log

Uninstalling modules from DKMS
  removing old DKMS module vboxguest version  4.3.22

------------------------------
Deleting module version: 4.3.22
completely from the DKMS tree.
------------------------------
Done.
Attempting to install using DKMS

Creating symlink /var/lib/dkms/vboxguest/4.3.22/source ->
                 /usr/src/vboxguest-4.3.22

DKMS: add completed.

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...(bad exit status: 2)
make KERNELRELEASE=2.6.32-504.8.1.el6.x86_64 -C /lib/modules/2.6.32-504.8.1.el6.x86_64/build M=/var/lib/dkms/vboxguest/4.3.22/build...(bad exit status: 2)
Error! Bad return status for module build on kernel: 2.6.32-504.8.1.el6.x86_64 (x86_64)
Consult /var/lib/dkms/vboxguest/4.3.22/build/make.log for more information.
Failed to install using DKMS, attempting to install without
make KBUILD_VERBOSE=1 CONFIG_MODULE_SIG= -C /lib/modules/2.6.32-504.8.1.el6.x86_64/build SUBDIRS=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 modules
/usr/src/kernels/2.6.32-504.8.1.el6.x86_64/arch/x86/Makefile:81: stack protector enabled but no compiler support
test -e include/linux/autoconf.h -a -e include/config/auto.conf || (        \
    echo;                               \
    echo "  ERROR: Kernel configuration is invalid.";       \
    echo "         include/linux/autoconf.h or include/config/auto.conf are missing.";  \
    echo "         Run 'make oldconfig && make prepare' on kernel src to fix it.";  \
    echo;                               \
    /bin/false)
mkdir -p /tmp/vbox.0/.tmp_versions ; rm -f /tmp/vbox.0/.tmp_versions/*
make =/tmp/vbox.0
make: *** 空の変数名.  中止.
make[1]: *** [_module_/tmp/vbox.0] エラー 2
make: *** [vboxguest] エラー 2
Creating user for the Guest Additions.
Creating udev rule for the Guest Additions kernel module.

よくわからないが、途中の

test -e include/linux/autoconf.h -a -e include/config/auto.conf || (     \
    echo;                               \
    echo "  ERROR: Kernel configuration is invalid.";       \
    echo "         include/linux/autoconf.h or include/config/auto.conf are missing.";  \
    echo "         Run 'make oldconfig && make prepare' on kernel src to fix it.";  \
    echo;                               \
    /bin/false)

のところにERRORとあるので検索してみる

こちらが見つかる

[Vagrant]共有ディレクトリのマウントが失敗する - Code Life

$ sudo yum install automake autoconf

してみるけど、automakeもautoconfもインストール済みですよって言われる・・・

お手上げ(´;ω;`)