环境
[[email protected]_64#] cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[[email protected]_64#] uname -a
Linux VM-24-7-centos 3.10.0-1160.49.1.el7.x86_64 #1 SMP Tue Nov 30 15:51:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
对应的源码rpm安装包: https://vault.centos.org/7.9.2009/updates/Source/SPackages/kernel-3.10.0-1160.49.1.el7.src.rpm
源码安装教程
参考 https://wiki.centos.org/HowTos/I_need_the_Kernel_Source
按照下步逐步执行
yum install -y kernel-devel
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros
yum install -y asciidoc audit-libs-devel bash bc binutils binutils-devel bison diffutils elfutils
yum install -y elfutils-devel elfutils-libelf-devel findutils flex gawk gcc gettext gzip hmaccalc hostname java-devel
yum install -y m4 make module-init-tools ncurses-devel net-tools newt-devel numactl-devel openssl
yum install -y patch pciutils-devel perl perl-ExtUtils-Embed pesign python-devel python-docutils redhat-rpm-config
yum install -y rpm-build sh-utils tar xmlto xz zlib-devel
rpm -ivp https://vault.centos.org/7.9.2009/updates/Source/SPackages/kernel-3.10.0-1160.49.1.el7.src.rpm
#如果网络延迟,可以先将rpm下载下来, 直接用 rpm -ivp kernel-3.10.0-1160.49.1.el7.src.rpm 即可
#如果再出错的话 warning: group mockbuild does not exist - using root, 执行以下两个指令
yum install mock
useradd -s /sbin/nologin mockbuild
cd ~/rpmbuild/SPECS
rpmbuild -bp --target=$(uname -m) kernel.spec
# 查看源码的目录
cd ~/rpmbuild/BUILD/kernel*/linux*/
安装完之后
[[email protected]_64#] pwd
/root/rpmbuild/BUILD/kernel-3.10.0-1160.49.1.el7/linux-3.10.0-1160.49.1.el7.x86_64
[[email protected]_64#] ls
arch COPYING Documentation fs ipc kernel Makefile net samples sound virt
block CREDITS drivers include Kbuild lib Makefile.qlock README scripts tools
configs crypto firmware init Kconfig MAINTAINERS mm REPORTING-BUGS security usr
标签:1160.49,Centos,3.10,devel,源码,64,linux,rpm,el7
From: https://www.cnblogs.com/han-guang-xue/p/16968708.html