Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Background:

I created a sandbox VM with VirtualBox on my macOS. It correctly spins up a VM (with CentOS7 running on it) on which I can access to.

Inside this sandbox vm, I want to spin up several vms in order to test Ansible Playbooks with Kitchen CI & Vagrant, thus I installed VirtualBox by downloading it from the following link: https://download.virtualbox.org/virtualbox/5.2.8/VirtualBox-5.2-5.2.8_121009_el7-1.x86_64.rpm

After the installation I executed the command:

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

It returned:

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

I installed the Development tools, but I keep getting the same issue.

I don't think I need to recompile any kernel module. Any idea?

Thanks in advance for your help.

like image 350
Davide Martorana Avatar asked Sep 12 '25 01:09

Davide Martorana


1 Answers

So, after searching on the internet, and not just on the VirtualBox website, I found the solution, and I was right: I did not need to compile any module. The following is the reference to the CentOS wiki page:

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

In a few words, I had to install dkms and kernel-devel packages. In order to do so, I needed to install EPEL repository; but personally I prefer to install and enable the IUS repository.

The following are the set of commands that worked for me:

yum groupinstall "Development tools"

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

yum install dkms

yum install kernel-devel

reboot

After the machine had rebooted, I was able to get VirtualBox working fine.

I verified by the command line:

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

And it returned the correct value:

5.2.8r121009

like image 85
Davide Martorana Avatar answered Sep 16 '25 07:09

Davide Martorana