virtualbox 安装增强功能时报Please install the Linux kernel "header" files的解决办法

在VirtualBox上使用镜像CentOS-7.4-x86_64-DVD-1708.iso创建了一个虚拟机 ,为了使鼠标能够自由地在虚拟机与外在系统中切换,于是安装增强功能,安装时报kernel "header" files文件缺失,如下所示:

[root@localhost VBox_GAs_5.2.2]# sh VBoxLinuxAdditions.run 

Verifying archive integrity... All good.
Uncompressing VirtualBox 5.2.2 Guest Additions for Linux........
VirtualBox Guest Additions installer
Removing installed version 5.2.2 of VirtualBox Guest Additions...
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.
This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
kernel-devel kernel-devel-3.10.0-693.el7.x86_64
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.

于是使用yum安装kernel-devel kernel-devel-3.10.0-693.el7.x86_64包,但是报找不到此包。
使用yum search kernel-devel找到的包不是693版本。
查看当前运行内核版本:

[root@localhost VBox_GAs_5.2.2]# uname -a

Linux localhost 3.10.0-715.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

说明当前内核版本并非所需要的693版本,故找不到。
于是,安装所需的内核发行版rpm包,此rpm包网上可以找到下载地址http://vault.centos.org/7.4.1708/os/x86_64/Packages/kernel-devel-3.10.0-693.el7.x86_64.rpm

[root@localhost ~]# mkdir -p /data/software
[root@localhost ~]# cd /data/software
[root@localhost software]# wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/kernel-devel-3.10.0-693.el7.x86_64.rpm

下载完成后,直接解压安装镜像,从安装包文件夹中导入服务器安装即可:

[root@localhost software]# rpm -ivh  ./kernel-devel-3.10.0-693.el7.x86_64.rpm

准备中... ################################# [100%]
正在升级/安装...
1:kernel-devel-3.10.0-693.el7 ################################# [100%]

安装内核完成后,最好先重启一下,再安装增强功能:
[root@localhost VBox_GAs_5.2.2]# sh VBoxLinuxAdditions.run 

Verifying archive integrity... All good.
Uncompressing VirtualBox 5.2.2 Guest Additions for Linux........
VirtualBox Guest Additions installer
Removing installed version 5.2.2 of VirtualBox Guest Additions...
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.
VirtualBox Guest Additions: Running kernel modules will not be replaced until the system is restarted
VirtualBox Guest Additions: Starting.

重启后鼠标即可在虚拟机与主机间自由切换!

最后,把主机组合键占用的热键删除,即可在虚拟机中正常使用Crtl、Shift等键:
virtualbox 安装增强功能时报Please install the Linux kernel
热键设置

查看当前运行内核版本

[root@localhost VBox_GAs_5.2.2]# uname -a

Linux localhost 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

centos7-内核版本升级或降级参考:
http://www.mamicode.com/info-detail-2093542.html

你可能感兴趣的:(virtualbox 安装增强功能时报Please install the Linux kernel "header" files的解决办法)