centos 7.1 中默認的內核源碼路徑為 /usr/src/uname -r
,但是它不包含源碼,只包含了Kconfig 和 Makefile
uname -r //查看系統內核cat /etc/redhat-release //操作系統版本
輸出結果 內核版本:3.10.0-229.el7.x86_64 操作系統版本:CentOS Linux release 7.1.1503 (Core)
下載的地址http://vault.centos.org/ 找到相應的系統版本號,進入 例如:7.1.1503 在網頁http://vault.centos.org/7.1.1503/updates/Source/SPackages/ 下載對應版本內核源碼包:kernel-3.10.0-229.20.1.el7.src.rpm
1.首先安裝(升級)一些依賴包
sudo yum install rpm-build redhat-rpm-config asciidoc hmaccalc perl-ExtUtils-Embed pesign xmltosudo yum install audit-libs-devel binutils-devel elfutils-devel elfutils-libelf-develsudo yum install ncurses-devel newt-devel numactl-devel pciutils-devel python-devel zlib-devel bison
2.創建源碼的編譯目錄樹,目的源碼存放地址
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros
3 安裝到編譯目錄 在kernel-3.10.0-229.20.1.el7.src.rpm所在的目錄下
rpm -i kernel-3.10.0-229.20.1.el7.src.rpm 2>&1 | grep -v existcd ~/rpmbuild/SPECSrpmbuild -bp --target=$(uname -m) kernel.spec
最終的內核源碼應該在下面的目錄下
~/rpmbuild/BUILD/kernel-*/linux-*/
http://xxxxxx/Linuxjc/1137396.html TechArticle