Scientific Linux 7.0 の Docker用ベースイメージをつくろうと思い、
vagrant up
をしたらエラーが発生してうまく行かなかった。人生は厳しい。
おかげで、 /vagrant
がマウントされなかった。
環境
$ vagrant --version
Vagrant 1.7.4
$ VBoxManage --version
4.3.28r100309
忙しい人のための
こんなエラーが出たら
The missing package can be probably installed with
yum install kernel-devel-3.10.0-123.el7.x86_64
Building the main Guest Additions module[FAILED]
こうする。
host $ vagrant ssh
vagrant # sudo yum install -y ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/7.0/x86_64/os/Packages/kernel-devel-3.10.0-123.el7.x86_64.rpm
vagrant # exit
host $ vagrant reload
詳細
エラーは以下のような感じ。
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-3.10.0-123.el7.x86_64
Building the main Guest Additions module[FAILED]
(Look at /var/log/vboxadd-install.log to find out what went wrong)
...
An error occurred during installation of VirtualBox Guest Additions 4.3.28. 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: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => /Users/yoshiki_aoki/work/github.com/ringohub/docker-base-image/sl70-base
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
どうやら、virtual box guest additions のインストールが失敗してる模様。
気になるログはここらへん。
The missing package can be probably installed with
yum install kernel-devel-3.10.0-123.el7.x86_64
Building the main Guest Additions module[FAILED]
(Look at /var/log/vboxadd-install.log to find out what went wrong)
ここでわかるのは、kernel-devel-3.10.0-123.el7.x86_64
をインストールしなきゃいけなさそうっていうのと、/var/log/vboxadd-install.log
のログを見ようってこと。
ログから見てみる。
[root@localhost ~]# cat /var/log/vboxadd-install.log
/tmp/vbox.0/Makefile.include.header:97: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again. Stop.
KERN_DIR
を指定しろよって言ってる。カーネルのディレクトリをしてしようと思って、みてみる。
[root@localhost vagrant]# ls /usr/src/kernels/
[root@localhost vagrant]#
何もなかった。
ここで、yum install -y kernel-devel
でインストールしてしまうと kernel-devel-3.10.0-123.el7.x86_64
が入らない。
なので、ここから rpmを指定バージョンをインストールした。
yum install -y ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/7.0/x86_64/os/Packages/kernel-devel-3.10.0-123.el7.x86_64.rpm
一応確認。
[root@localhost vagrant]# ls /usr/src/kernels/
3.10.0-123.el7.x86_64
KERN_DIR
を指定しなきゃだめかなと思ったんだけど、ためにしログアウトして vagrant reload
したら無事インストールされた。
...
Installing Virtualbox Guest Additions 4.3.28 - guest version is
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.28 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 4.3.28 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 ]
...