Question: I am trying to install virtualbox5.2 on a RHEL 7 VM When I try to rebuild kernels modules I get the following error:

```
[root@myserver~]# /usr/lib/virtualbox/vboxdrv.sh setup
vboxdrv.sh: Stopping 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-693.11.1.el7.x86_64

```

I tried install kernet-devel and got success message

```
Installed:
  kernel-devel.x86_64 0:3.10.0-693.21.1.el7                                     

Complete!

```

But still the setup fails.

Any idea what is missing here?

Answer: 
The kernel your were using was kernel-devel-3.10.0-693.**11**.1.el7.x86\_64 is slightly different with the one that you installed kernel-devel.x86\_64 0:3.10.0-693.**21**.1.el7 . In my case, there are several different version installed on my OS, and "sudo yum install kernel-devel" always install the newest one for me. Then I work it out by setting my default kernel version as same as yum installed for me. You can check the kernel you have installed on your OS by following command:

```
sudo awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg

```

Then just set the kernel version you choose to use as same as yum choose for you,by following command:(notice that the number at last is pick up from preceding command result), 

```
sudo grub2-set-default 0

```

generate the grub2 config with 'gurb2-mkconfig' command, and then reboot the server.

```
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
sudo reboot

```
Milan Rakos is right. Your installed kernel-devel must have suffix string exactly the same as the `uname -r` output. Besides, the logs during the vboxdrv.sh setup also shows the wanted version of the kernel-devel.

So to your case, You will run the command:`sudo yum install kernel-devel-3.10.0-693.11.1.el7.x86_64`