VirtualBox上のCentOSにGuestAdditionsをインストール時のエラーについて
バージョンは以下のとおり。
VirtualBox:4.3.22
CentOS:7.0.1406
Building the main Guest Additions moduleが失敗するのでログを確認。
/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. 中 止. Creating user for the Guest Additions. Creating udev rule for the Guest Additions kernel module.
kernelソースがないからKERN_DIR
に設定してくれとのこと。
インストールをして設定。
# yum install kernel-devel -y # export KERN_DIR /usr/src/kernels/3.10.0-123.20.1.el7.x86_64
再度実行したが同じエラー。
uname -r
で出力されるバージョンとKERN_DIR
が示すディレクトリが違っているとダメらしいとのこと。
めんどくさいので全部アップデートしてしまう。
# yum -y update # shutdown -r now
再々度実行するがエラー。 もう一回ログを確認する。
grep: /lib/modules/3.10.0-123.20.1.el7.x86_64/build/include/linux/version.h: そのようなファイルやディレクトリはありません make KBUILD_VERBOSE=1 CONFIG_MODULE_SIG= -C /lib/modules/3.10.0-123.20.1.el7.x86_64/build SUBDIRS=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 modules /usr/src/kernels/3.10.0-123.20.1.el7.x86_64/arch/x86/Makefile:96: stack-protector enabled but compiler support broken Makefile:616: Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong not supported by compiler make[1]: gcc: コマンドが見つかりませんでした
gccが無かったようなのでインストール。
# yum install gcc
そして再々々実行。
# sh VBoxLinuxAdditions.run 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 [ OK ] Building the shared folder support module [ OK ] Building the OpenGL support module [ OK ] Doing non-kernel setup of the Guest Additions [ OK ] You should restart your guest to make sure the new modules are actually used Installing the Window System drivers Installing X.Org Server 1.15 modules [ OK ] Setting up the Window System to use the Guest Additions [ OK ] You may need to restart the hal service and the Window System (or just restart the guest system) to enable the Guest Additions. Installing graphics libraries and desktop services componen[ OK ]
正常終了。 再起動して終わり。
下記リンクを参考にしました。