Introduction
We explained how to install VirtualBox on a Centos 7 machine in an earlier article wherein we ran into an issue during the install itself and were unable to start the service. In this article, we will share the diagnostic steps and the consequent resolution after which we were finally able to start the service and use the VirtualBox application.
Issue
On installing VirtualBox from Oracles’ official repository we received the following message
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-123.el7.x86_64 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-123.el7.x86_64
I tried to start the vboxdrv service but the startup failed and given below is the systemctl status output
[root@linuxnix ~]# systemctl status vboxdrv.service vboxdrv.service - VirtualBox Linux kernel module Loaded: loaded (/usr/lib/virtualbox/vboxdrv.sh; enabled) Active: failed (Result: exit-code) since Wed 2018-09-19 12:25:08 EDT; 10s ago Process: 58858 ExecStart=/usr/lib/virtualbox/vboxdrv.sh start (code=exited, status=1/FAILURE) Sep 19 12:25:08 linuxnix vboxdrv.sh[58858]: vboxdrv.sh: Starting VirtualBox services. Sep 19 12:25:08 linuxnix vboxdrv.sh[58858]: vboxdrv.sh: Building VirtualBox kernel modules. Sep 19 12:25:08 linuxnix vboxdrv.sh[58858]: This system is currently not set up to build kernel modules. Sep 19 12:25:08 linuxnix vboxdrv.sh[58858]: Please install the Linux kernel "header" files matching the current kernel Sep 19 12:25:08 linuxnix vboxdrv.sh[58858]: for adding new hardware support to the system. Sep 19 12:25:08 linuxnix vboxdrv.sh[58858]: The distribution packages containing the headers are probably: Sep 19 12:25:08 linuxnix vboxdrv.sh[58858]: kernel-devel kernel-devel-3.10.0-123.el7.x86_64 Sep 19 12:25:08 linuxnix systemd[1]: vboxdrv.service: control process exited, code=exited status=1 Sep 19 12:25:08 linuxnix systemd[1]: Failed to start VirtualBox Linux kernel module. Sep 19 12:25:08 linuxnix systemd[1]: Unit vboxdrv.service entered failed state. [root@linuxnix ~]#
I tried to load the vboxdrv kernel module manually but still no luck.
[root@linuxnix ~]# modprobe -v vboxdrv modprobe: FATAL: Module vboxdrv not found. [root@linuxnix ~]# /usr/lib/virtualbox/vboxdrv.sh setup 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-123.el7.x86_64 [root@linuxnix ~]#
Diagnostics and resolution
I looked for the kernel-devel package and foudn that it was already installed on the system. On further checking I found out that the kernel package and the kernel-devel had different versions. [root@linuxnix ~]# uname -r 3.10.0-123.el7.x86_64 [root@linuxnix ~]# yum list kernel-devel* Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirror.nbrc.ac.in * extras: mirrors.nhanhoa.com * updates: mirrors.viethosting.com Installed Packages kernel-devel.x86_64 3.10.0-862.11.6.el7 @updates [root@linuxnix ~]# yum install kernel-devel.x86_64 -y Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirror.nbrc.ac.in * extras: mirrors.nhanhoa.com * updates: mirrors.viethosting.com Package kernel-devel-3.10.0-862.11.6.el7.x86_64 already installed and latest version Nothing to do
Due to this our VirtualBox installation was failing. You might also face this scenario in case you have not installed the development tools rpms. To rectify this I updated my operating system kernel using the following command:
yum update kernel -y
After this I rebooted my system to boot it up with the new kernel. Once the kernel and the kernel-devel packages had the same version I executed the vboxdrv.sh script which started VirtualBox flawlessly.
[root@linuxnix ~]# /usr/lib/virtualbox/vboxdrv.sh setup vboxdrv.sh: Stopping VirtualBox services. vboxdrv.sh: Starting VirtualBox services. vboxdrv.sh: Building VirtualBox kernel modules. [root@linuxnix ~]#
Conclusion
In this article we explained the resolution of one of the common errors that users face while installing VirtualBox on Linux. We hope that you found this article to be useful and we look forward towards your suggestions and feedback.
Sahil Suri
Latest posts by Sahil Suri (see all)
- Google Cloud basics: Activate Cloud Shell - May 19, 2021
- Create persistent swap partition on Azure Linux VM - May 18, 2021
- DNF, YUM and RPM package manager comparison - May 17, 2021
- Introduction to the aptitude package manager for Ubuntu - March 26, 2021
- zypper package management tool examples for managing packages on SUSE Linux - March 26, 2021