Vagrant upでVirtualBox Guest Additions: Kernel headers not found for target kernel Error

Vagrant UPするといきなりエラー発生。



The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

/usr/sbin/rcvboxadd setup

Stdout from the command:

VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel 
modules.  This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup  < version > 
VirtualBox Guest Additions: or
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Kernel headers not found for target kernel 
3.10.0-1127.13.1.el7.x86_64. Please install them and execute
  /sbin/rcvboxadd setup
Stderr from the command:
modprobe vboxguest failed
The log file /var/log/vboxadd-setup.log may contain further information.
まず、記載されているKernelをInstallする。
「Kernel headers not found for target kernel 3.10.0-1127.13.1.el7.x86_64.」これですね。
$ yum -y install kernel-3.10.0-1127.13.1.el7.x86_64
$ yum -y install kernel-headers-3.10.0-1127.13.1.el7.x86_64
$ yum -y install kernel-devel-3.10.0-1127.13.1.el7.x86_64

# そしてリブート
$ reboot

しばらくして $ vagrant sshでログインする。
そして、Guest Additionsセットアップ!
$ /sbin/rcvboxadd setup
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel 
modules.  This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup < version >
VirtualBox Guest Additions: or
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Building the modules for kernel 
3.10.0-1127.13.1.el7.x86_64.

This system is currently not set up to build kernel modules.
Please install the gcc make perl packages from your distribution.
modprobe vboxguest failed
The log file /var/log/vboxadd-setup.log may contain further information.

またエラーです。
今度は、「Please install the gcc make perl packages from your distribution.」なのでインストールしてあげます。
$ yum install bzip2 gcc make perl kernel-devel
# そしてリトライ!
$ /sbin/rcvboxadd setup
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel 
modules.  This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup < version >
VirtualBox Guest Additions: or
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Building the modules for kernel 
3.10.0-1127.13.1.el7.x86_64.
おおー、いけた!
そして、一度抜けて、ホスト側よりvagrant upしてみる。
$ vagrant up

# CentOSバージョン
$ cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)

# Kernel Version
$ cat /proc/version
Linux version 3.10.0-1127.13.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) ) #1 SMP Tue Jun 23 15:46:38 UTC 2020
ちゃんと、BuildしたKernelがあたってますね。

コメント

このブログの人気の投稿

ソリューション構成ごとにconfigファイルを作成する

C++の古いプロジェクトのビルドでerror MIDL2311 : statements outside library block are illegal in mktyplib compatability mode

web.config debug/releaseの内容を変換構文を使って切り替える