Saturday, May 7, 2016

Virtualbox install fails on centos 7 due to the wrong kernel headers

Installing virtualbox on centos 7 had issues.
$ /sbin/rcvboxdrv setup
Stopping VirtualBox kernel modules                         [  OK  ]
Uninstalling old VirtualBox DKMS kernel modules            [  OK  ]
Trying to register the VirtualBox kernel modules using DKMSError! echo
Your kernel headers for kernel 3.10.0-327.10.1.el7.x86_64 cannot be found at
/lib/modules/3.10.0-327.10.1.el7.x86_64/build or /lib/modules/3.10.0-327.10.1.el7.x86_64/source.
                                                           [FAILED]
  (Failed, trying without DKMS)
Recompiling VirtualBox kernel modules                      [FAILED]

  (Look at /var/log/vbox-install.log to find out what went wrong)

The wrong kernel headers were installed using
yum install kernel-devel

Get the kernel version.
uname -r

Now download the corresponding kernel headers

yum install kernel-devel-3.10.0-327.10.1.el7.x86_64

Rerun:
$ /sbin/rcvboxdrv setup