有用的网站
https://elixir.bootlin.com :在线查看内核源码
CentOS获取内核源码
参考官方文档:https://wiki.centos.org/zh/HowTos/I_need_the_Kernel_Source
参考步骤: https://www.cnblogs.com/wanpengcoder/p/11768483.html
- 查看系统及内核版本
# cat /etc/redhat-release
CentOS Linux release 8.1.1911 (Core)
# uname -r
4.18.0-147.8.1.el8_1.x86_64
- 下载内核源码
wget http://vault.centos.org/8.1.1911/BaseOS/Source/SPackages/kernel-4.18.0-147.8.1.el8_1.src.rpm
- 安装内核源码包
rpm -ivh kernel-3.10.0-862.el7.src.rpm
Note: 如果报如下错误:
Warning: user mockbuild does not exist. using root
则安装如下缺少包
yum install mock (centos7)
yum install python2-mock.noarch (centos8)
useradd -s /sbin/nologin mockbuild
- 安装内核源码包
cd rpmbuild/SPECS
rpmbuild -bp --target=$(uname -m) kernel.spec
- 提取内核源码包
rpmbuild -bp --target=$(uname -m) kernel.spec
如果缺少组件,则安装组件后再执行
最后在以下目录存放内核源码
/root/rpmbuild/BUILD/kernel-4.18.0-147.8.1.el8_1/linux-4.18.0-147.8.1.el8.x86_64