本文共 1766 字,大约阅读时间需要 5 分钟。
确认当前内核版本号, 下载对应的SRPM包
#确认当前版本号
uname -r
# 到valut.centos.org找到SRPM并下载
# 注意事项
# (1) 确认是否用了plus版本的内核, 是的话SRPM在/centosplus/Source/SPackages/
# (2) 非plus版在以下两个目录: /updates/Source/SPackages, /os/Source/SPackages
wget http://vault.centos.org/6.4/updates/Source/SPackages/kernel-2.6.32-358.14.1.el6.src.rpm
安装SRPM以及相关RPM工具
# 安装SRPM
rpm -ivh kernel-2.6.32-358.14.1.el6.src.rpm
# 安装相关RPM工具
yum install rpm-build redhat-rpm-config patchutils xmlto asciidoc elfutils-libelf-devel zlib-devel binutils-devel newt-devel python-devel perl-ExtUtils-Embed hmaccalc rng-tools kernel-firmware
# 启动rngd服务, 提供足够的熵值
cat /dev/null >/etc/sysconfig/rngd
echo ‘EXTRAOPTIONS=”–rng-device /dev/urandom”’ >/etc/sysconfig/rngd
service rngd start
生成内核源码, 使用diff生成patch文件
# 生成内核源码
cd ~/rpmbuild/SPECS
rpmbuild -bp kernel.spec
# 修改并生成diff文件
cd ~/rpmbuild/BUILD
cp -r kernel-2.6.32-358.14.1.el6 kernel-2.6.32-358.14.1.el6.mine
diff -urpN kernel-2.6.32-358.14.1.el6 kernel-2.6.32-358.14.1.el6.mine > this-patch-to-fix-that-bug.patch
# 将patch拷贝到SOURCES下
cp this-patch-to-fix-that-bug.patch ~/rpmbuild/SOURCES
# 清理
rm -rf ~/rpmbuild/BUILD/kernel-2.6.32-358.14.1.el6*
修改SPEC文件, 生成新的内核RPM包
# 找到以下几行, 再后面添加一行
# Source84: config-s390x-generic-rhel
# Source85: config-powerpc64-debug-rhel
# Source86: config-s390x-debug-rhel
# 新添加行
Source87: this-patch-to-fix-that-bug.patch
Patch001: this-patch-to-fix-that-bug.patch
# (可选) 修改changelog, 找到%changelog这行, 再后插入行:
* Tue Aug 03 2013 Your Name [2.6.32-358.14.1.el6.centos]
- [XXX] path to fix that bug
打包生成新的内核RPM包
# 执行SPEC, 生成过程很长请耐心等待.
# 执行前, 请仔细review上述步骤, 避免出错重来
rpmbuila -ba kernel.spec
# 会生成若干个RPM包, 其中最关键的如下, 使用rpm -ivh安装即可
# kernel-2.6.32-358.14.1.el6.x86_64.rpm
# kernel-devel-2.6.32-358.14.1.el6.x86_64.rpm
# kernel-headers-2.6.32-358.14.1.el6.x86_64.rpm
转载地址:http://nmdnv.baihongyu.com/