This article will provide you with an information on how to install kernel source on CentOS/RHEL Linux system. Alternatively it will guide you through a simple troubleshootng process in case you have already installed kernel sources/headers and yest still receiving the bellow error message:
  ERROR: Unable to find the kernel source tree for the currently running kernel.  Please make sure you have installed the kernel     
         source files for your kernel and that they are properly configured; on Red Hat Linux systems, for example, be sure you have 
         the 'kernel-source' or 'kernel-devel' RPM installed.  If you know the correct kernel source files are installed, you may    
         specify the kernel source path with the '--kernel-source-path' command line option.


In this tutorial you will learn:
  • How to kernel-headers
  • How to kernel-devel
  • How to check kernel version
  • How to check for installed kernel-devel version
ERROR: Unable to find the kernel source tree for the currently running kernel error message on CentOS / RHEL
ERROR: Unable to find the kernel source tree for the currently running kernel error message on CentOS / RHEL

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Red Hat Enterprise Linux 8 / CentOS 8
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

How to install kernel headers and kernel devel on CentOS / RHEL step by step instructions

  1. You can either install kernel headers and kernel devel separately or as install both as part of the Development Tools package. The recommended and most likely installation of the entire Development Tools group package:
    # dnf groupinstall "Development Tools"
    
    Alternatively install both the kernel-devel and/or kernel-headers packages separately:
    # dnf install kernel-headers
    # dnf install kernel-devel
    

  2. SUBSCRIBE TO NEWSLETTER
    Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


  3. Check your installation and confirm that both the kernel-devel and/or kernel-headers packages match your currently loaded kernel version. Here is an example. First check your Linux kernel version:
    $ uname -a
    Linux sandbox 4.18.0-80.11.2.el8_0.x86_64 #1 SMP Tue Sep 24 11:32:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
    
    Take a note of the kernel version and compare it with package versions of the kernel-devel and/or kernel-headers:
    # rpm -qa | grep -E "kernel-devel|kernel-headers"
    kernel-headers-4.18.0-80.11.2.el8_0.x86_64
    kernel-devel-4.18.0-80.11.2.el8_0.x86_64
    
    If they all match your are good to go. Otherwise your system might be out of sync. See the next step for a solution.
  4. Using the dnf command synchronise your system to make sure you are running the latest packages:
    # dnf distro-sync
    
  5. Reboot your system and check once again that the kernel version matches the kernel-devel and/or kernel-headers package versions.
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in:



Comments and Discussions