内核源码安装
redhat维护的内核源码rpm包下载地址:Index of /http://vault.centos.org/
rpm 包中的源码提取方式:zh/HowTos/I_need_the_Kernel_Source - CentOS Wikihttps://wiki.centos.org/zh/HowTos/I_need_the_Kernel_Source
解压源码包,copy /boot/config.xx.xx 文件,到解压目前
make mrproper
make menuconfig,选择load 拷贝过来的config文件,然后save
make -j X
make modules_install
make install
CentOS 内核源码安装zh/HowTos - CentOS Wikihttps://wiki.centos.org/zh/HowToszh/HowTos/I_need_the_Kernel_Source - CentOS Wiki
https://wiki.centos.org/zh/HowTos/I_need_the_Kernel_Source
到valut.centos.org找到SRPM并下载,确认需要安装的内核版本号, 下载对应的SRPM包
例如:kernel-2.6.32-573.26.1.el6.src.rpm
注意事项
确认是否用了plus版本的内核, 是的话SRPM在/centosplus/Source/SPackages/
非plus版在以下两个目录: /updates/Source/SPackages, /os/Source/SPackages
安装SRPM以及相关RPM工具
rpm -ivh kernel-2.6.32-358.14.1.el6.src.rpm
错误提示:
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
执行下面两个命令:
# groupadd mockbuild
# useradd mockbuild -g mockbuild
安装相关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文件,如果不需要修改内核源码忽略3、4步骤。
生成内核源码
cd ~/rpmbuild/SPECS
rpmbuild -bp kernel.spec
修改并生成diff文件
cd ~/rpmbuild/BUILD
cp -r kernel-2.6.32-573.26.1.el6 kernel-2.6.32-573.26.1.el6.mine
diff -urpN kernel-2.6.32-573.26.1.el6 kernel-2.6.32-573.26.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-573.26.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<yourname@company.com> [2.6.32-573.26.1.el6.centos]
- [XXX] path to fix that bug
打patch参考:打补丁patch 命令使用 - lovemu - 博客园http://www.cnblogs.com/huanghuang/archive/2011/07/14/2106402.html
打包生成新的内核RPM包
执行SPEC, 生成过程很长请耐心等待.
执行前, 请仔细review上述步骤, 避免出错重来
rpmbuila -ba kernel.spec
#################################################
卡住gpg: keyring `./pubring.gpg' created不动了
解决办法:
执行一下命令:
rngd -r /dev/urandom
##################################################
会生成若干个RPM包, 其中最关键的如下, 使用rpm -ivh安装即可
kernel-2.6.32-573.26.1.el6.x86_64.rpm
kernel-devel-2.6.32-573.26.1.el6.x86_64.rpm
kernel-headers-2.6.32-573.26.1.el6.x86_64.rpm
参考文档:https://segmentfault.com/q/1010000000394104https://segmentfault.com/q/1010000000394104
centos6 安装 centos7 内核方法
下载centos 7相应 kernel rpm 包, 例如:kernel-3.10.0-327.36.3.el7.x86_64.rpm
cp /sbin/new-kernel-pkg /usr/sbin/
rpm -ivh kernel-3.10.0-327.36.3.el7.x86_64.rpm --nodeps --force