错误:无法找到当前运行的内核的内核源代码树 - CentOS/RHEL/AlmaLinux
本文将为您介绍如何在 CentOS/RHEL Linux 系统上安装内核源代码。或者,如果您已经安装了内核源代码/标头并且仍然收到以下错误消息,它将指导您完成简单的故障排除过程:
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.
在本教程中您将学习:
如何安装内核头文件
如何安装内核开发
如何检查内核版本
如何检查已安装的内核开发版本
CentOS/RHEL 上的错误:无法找到当前运行的内核的内核源代码树
错误消息
如何在 CentOS/RHEL 上安装内核头文件和内核开发的分步说明
您可以单独安装内核头文件和内核开发,也可以将两者作为
开发工具
包的一部分安装。建议安装整个Development Tools
组包:# dnf groupinstall "Development Tools"
或者单独安装
kernel-devel
和/或kernel-headers
软件包:检查您的安装并确认
kernel-devel
和/或kernel-headers
软件包与您当前加载的内核版本匹配。这是一个例子。首先检查你的Linux内核版本:$ 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
记下内核版本并将其与 kernel-devel 和/或 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
使用 dnf 命令同步您的系统以确保您正在运行最新的软件包:
# dnf distro-sync