CentOS 7:VirtualBox 抱怨内核模块未加载

CentOS 7: VirtualBox is complaining that the kernel module is not loaded

背景:

我在我的 macOS 上用 VirtualBox 创建了一个 sandbox 虚拟机。它正确地启动了我可以访问的虚拟机(上面装有 CentOS7 运行)。

在这个沙箱 vm 中,我想启动几个 vms 以测试 Ansible Playbooks with Kitchen CI & Vagrant,因此我通过下载安装了 VirtualBox来自以下 link:https://download.virtualbox.org/virtualbox/5.2.8/VirtualBox-5.2-5.2.8_121009_el7-1.x86_64.rpm

安装完成后我执行了命令:

[david@vmkitchen-env ansible-test]# VBoxManage --version

它返回:

WARNING: The vboxdrv kernel module is not loaded. Either there is no module
         available for the current kernel (3.10.0-693.2.1.el7.x86_64) or it 
         failed to load. Please recompile the kernel module and install it 
         by
           sudo /sbin/vboxconfig

         You will not be able to start VMs until this problem is fixed.
5.2.8r121009

我安装了开发工具,但我总是遇到同样的问题。

我认为我不需要重新编译任何内核模块。有什么想法吗?

在此先感谢您的帮助。

所以,在网上搜索之后,而不仅仅是在 VirtualBox 网站上,我找到了解决方案,我是对的:我不需要编译任何模块。 以下是对 CentOS wiki 页面的引用:

https://wiki.centos.org/HowTos/Virtualization/VirtualBox

简而言之,我必须安装 dkmskernel-devel 包。为此,我需要安装 EPEL 存储库;但我个人更喜欢安装并启用 IUS 存储库。

以下是对我有用的一组命令:

yum groupinstall "Development tools"

yum install https://centos7.iuscommunity.org/ius-release.rpm

yum install dkms

yum install kernel-devel

reboot

机器重启后,我可以让 VirtualBox 正常工作。

我通过命令行验证:

[david@vmkitchen-env ansible-test]# VBoxManage --version

它返回了正确的值:

5.2.8r121009

以下步骤解决了我的问题。

1.sudo /sbin/vboxconfig

vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox 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-957.10.1.el7.x86_64

2.This 网站有内核模块 - website

wget https://linuxsoft.cern.ch/cern/centos/7/updates/x86_64/Packages/kernel-devel-3.10.0-957.10.1.el7.x86_64.rpm

4.yum localinstall kernel-devel-3.10.0-957.10.1.el7.x86_64.rpm -y

5.sudo /sbin/vboxconfig

问题已解决