How to compile drivers for Centos 7 with mainline kernel from @elrepo-kernel

user1955162 asked:

When using CENTOS 7 with Kernel 4.5, I can not yum install kernel-headers with the same kernel version. I am stuck on 3.10, which is what Centos comes with. How can I install Kernel-headers 4.5 and Kernel-devel which is needed for compiling drivers?

The packages are not in a repo with the mainline kernel updates:

[[email protected] tmp]# yum list | grep kernel
kernel-ml.x86_64                        4.5.0-1.el7.elrepo             @elrepo-kernel
abrt-addon-kerneloops.x86_64            2.1.11-36.el7.centos           base     
erlang-kernel.x86_64                    R16B-03.16.el7                 epel     
kernel.x86_64                           3.10.0-327.13.1.el7            updates  
kernel-abi-whitelists.noarch            3.10.0-327.13.1.el7            updates  
kernel-debug.x86_64                     3.10.0-327.13.1.el7            updates  
kernel-debug-devel.x86_64               3.10.0-327.13.1.el7            updates  
kernel-devel.x86_64                     3.10.0-327.13.1.el7            updates  
kernel-doc.noarch                       3.10.0-327.13.1.el7            updates  
kernel-headers.x86_64                   3.10.0-327.13.1.el7            updates  
kernel-tools.x86_64                     3.10.0-327.13.1.el7            updates  
kernel-tools-libs.x86_64                3.10.0-327.13.1.el7            updates  
kernel-tools-libs-devel.x86_64          3.10.0-327.13.1.el7            updates  
libreport-plugin-kerneloops.x86_64      2.1.11-32.el7.centos           base     
lirc-disable-kernel-rc.x86_64           0.9.1a-4.el7                   epel     
php-symfony-http-kernel.noarch          2.7.10-1.el7                   epel     
texlive-l3kernel.noarch                 2:svn29409.SVN_4469-38.el7     base     
texlive-l3kernel-doc.noarch             2:svn29409.SVN_4469-38.el7     base     
[[email protected] tmp]# uname -a
Linux localhost.localdomain 4.5.0-1.el7.elrepo.x86_64 #1 SMP Mon Mar 14 10:24:58 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux
[[email protected] tmp]# 

My answer:

Did you notice that the name of the kernel package you installed was kernel-ml?

Corresponding to that, you need to install kernel-ml-devel to get the corresponding kernel source for compiling drivers against your kernel.

You don’t need to install any kernel headers other than this.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.