To check for kernel headers and install them if necessary on CentOS, RHEL, Oracle RHCK, or Amazon Linux systems, perform the following steps.
When they are properly installed, the required kernel headers are located under
/usr/src/kernels/$(uname -r)/include/.
Procedure
- To determine whether kernel headers are installed, run the following command:
$ sudo yum list installed kernel-devel-$(uname -r)
If the package is installed, the output will be similar to the following:
Installed Packages
kernel-devel.x86_64 <version>
- To determine whether the kernel headers are available to install, run the following command:
$ sudo yum list available kernel-devel-$(uname -r)
If the package is available, the output will be similar to the following:
Available Packages
kernel-devel.x86_64 <version> baseos
- To install any necessary available kernel headers, run the following command:
$ sudo yum install -y kernel-devel-$(uname -r)
- If the kernel headers packages are not installed and are not available, update the kernel to a supported version and install the matching kernel headers.
Note: This action requires a reboot.
- To list the available kernel and kernel header packages and find matching versions, run the following command:
$ sudo yum list available kernel kernel-devel
If newer packages are available, the output will be similar to the following:
Available Packages
kernel.x86_64 <newer-version> baseos
...
kernel-devel.x86_64 <newer-version> baseos
- To install a newer supported kernel and kernel header packages with matching versions, run the following command:
% sudo yum install -y kernel-<newer-version> kernel-devel-<newer-version>
- Reboot into the new kernel.