Centos7 VBoxGuestAdditions cannot find kernel-devel

I saw the silliest reason ever for the VBoxGuestAdditions being unable to find the correct kernel headers.

The story normally goes that you try to compile these things inside your virtual machine, the VBoxLinuxAdditions.run file will tell you to install kernel-devel, you do so and everything’s fine. Not today, though! Today the header files were undiscoverable.

I poked around for a while with no success and eventually just asked myself what the simplest possible problem could be. On a hunch I did:

ls /usr/src/kernels



uname -r


So the output of uname -r doesn’t contain one of the patchlevels that’s recorded in /usr/src/kernel.

This is because the following command installs the latest kernel-devel available in the rpm repos

sudo dnf install kernel-devel

But an older kernel is installed on the running system. I had to upgrade my running kernel

sudo dnf upgrade