본문 바로가기
OS/Linux

Empty kernel directory but kernel-headers are installed

by 신군. 2018. 5. 24.
반응형

Host - Windows 7

Guest - CentOS

I am trying to install kernel-headers using yum since during the installation of vmware-tools I get a message asking for the path to the kernel header files for the 3.10.0-229.7.2.e17.x86_64.

Running yum install kernel-headers returns Package kernel-headers-3.10.0-229.7.2.e17.x86_64 already installed and latest version. But the directory /usr/src/kernels is empty.

Are the kernel headers installed somewhere else? Or should I be asking yum to install something else?

Path provided to vmware-tools for kernel headers

Searching for a valid kernel header path...
The path "" is not a valid path to the 3.10.0-229.7.2.e17.x86_64 kernel headers.
Would you like to change it? [yes]

Providing the path /usr/include/linux gives the same response again but with "" replaced with the path provided.

  • 1
    check the output of rpm -ql kernel-headers; I think it puts files in /usr/include/linux, but I may be out-of-date. It'd be good if you could indicate what path you give to the vmware-tools installer and also what it reports back. – Jeff Schaller Jul 13 '15 at 13:26
up vote 5 down vote accepted

The correct package to install all of the required dependencies for building kernel modules is kernel-devel (see the CentOS documentation for more information).

The headers are not installed in /usr/src/kernels, rather they're installed in a number of directories below /usr/include (the default location for C header files). You can list the contents of the kernel-headers package you installed using:

rpm -ql kernel-headers
  • That was it. I'd got to that page earlier but misread it as "if you do need the full source use kernel-devel". Thanks – Kvothe Jul 13 '15 at 14:00

I had same problem. After much googling, this solution worked for me. It first determines the installed kernel version and then uses that exact version to install the kernel header package.

sudo yum install "kernel-devel-uname-r == $(uname -r)"

I had the same issue and the above solution did not work for me. It could be the build of CentOS 7 I am using.
Here is what solved the problem for me...

install kernel headers

yum -y install kernel-devel

set symbolic link so vmware tools can find version.h

export kernel_headers=`ls -hd /usr/src/kernels/3*`
sudo ln -s ${kernel_headers}/include/generated/uapi/linux/version.h ${kernel_headers}/include/linux/version.h

I've had exactly the same issue.

In my case i just had to remove kernel-dev* et install it again :

yum -y remove kernel-devel*
yum -y install kernel-devel*

I installed the kernel-devel package, but it turns out that the headers were for a different kernel version than the one that was running on my instance. In order to fix the problem, I ran

sudo yum upgrade

and rebooted, and then vmware-tools installed without a fuss.

On CentOS version 7 given below is the path for kernel-headers.

/lib/modules/3.10.0-327.36.2.el7.x86_64/build/include

After running yum install kernel-headers twice (updated to the latest), the problem got fixed. Make sure the running kernel version and the kernel headers version are same. My kernel version is 3.10.0-327.36.2.el7.x86_64


반응형