centos中默认的内核源码路径为 /usr/src/`uname -r`,但是它不包含源码,只包含了Kconfig 和 Makefile
按照centos的wiki整理一份完整源码获取办法
1. 首先安装(升级)一些依赖包:
sudo yum install rpm-build redhat-rpm-config asciidoc hmaccalc perl-ExtUtils-Embed pesign xmlto
sudo yum install audit-libs-devel binutils-devel elfutils-devel elfutils-libelf-devel
sudo yum install ncurses-devel newt-devel numactl-devel pciutils-devel python-devel zlib-devel
2. 创建源码的编译目录树,目的源码存放地址
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros
3. 找到你的centos对应的内核源码包
可用 cat /etc/redhat-release 得到centos版本是7.1.1503
然后从centos的官网上下载7.1.1503版本的内核源码包
kernel-3.10.0-229.20.1.el7.src.rpm
4. 安装到编译目录
rpm -i kernel-3.10.0-229.20.1.el7.src.rpm 2>&1 | grep -v exist
cd ~/rpmbuild/SPECS
rpmbuild -bp --target=$(uname -m) kernel.spec
最终的内核源码应该在
~/rpmbuild/BUILD/kernel-*/linux-*/
阅读(16383) | 评论(0) | 转发(0) |