CentOS下如何编译使用新内核
笔者尝试的方法有三种:
附:kernel-2.6.32-279.9.1.tb1.el5.nosrc.rpm.zip
二、用Redhat/CentOS提供的内核源码包,进行定制、编译、安装。
附:kernel-2.6.32-358.6.4.el6.nosrc.rpm.zip
三、用原生linux内核进行定制、编译、安装。
附:kernel-ml-3.9.7-1.el6.nosrc.rpm.zip
千言万语,不如直接装上附的源码包看吧。以CentOS的源码包编译为例(nosrc.rpm需要自己去下载内核源码):
# 安装编译所依赖的工具包 yum -y install @development-tools fedora-packager kernel-devel rpm-build redhat-rpm-config asciidoc hmaccalc binutils-devel elfutils-libelf-devel newt-devel zlib-devel xmlto python-devel perl-ExtUtils-Embed # 生成目录:~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} 和文件 ~/.rpmmacros rpmdev-setuptree # CentOS 6 对应源码目录: http://ftp.redhat.com/redhat/linux/enterprise/6Server/en/os/SRPMS cd ~/rpmbuild/SRPMS/ # CentOS 6 当下最新,以下以此为例 wget http://ftp.redhat.com/redhat/linux/enterprise/6Server/en/os/SRPMS/kernel-2.6.32-279.19.1.el6.src.rpm # 安装内核源码包 rpm -ivh ~/rpmbuild/SRPMS/kernel-2.6.32-279.19.1.el6.src.rpm # 使用rpmbuild就可以一键编出你的内核到 ~/rpmbuild/RPMS/ 目录中了 rpmbuild -bb --with baseonly --with firmware --without debuginfo ~/rpmbuild/SPECS/kernel.spec #编译过程会用到大量随机种子,遇到 waiting for lock on `./random_seed'... 提示时请执行 rngd -r /dev/urandom #编译完成会有如下提示: # Wrote: ~/rpmbuild/RPMS/x86_64/kernel-2.6.32-279.19.2.el6.x86_64.rpm # Wrote: ~/rpmbuild/RPMS/x86_64/kernel-headers-2.6.32-279.19.2.el6.x86_64.rpm # Wrote: ~/rpmbuild/RPMS/x86_64/kernel-firmware-2.6.32-279.19.2.el6.x86_64.rpm # Wrote: ~/rpmbuild/RPMS/x86_64/perf-2.6.32-279.19.2.el6.x86_64.rpm # Wrote: ~/rpmbuild/RPMS/x86_64/python-perf-2.6.32-279.19.2.el6.x86_64.rpm # Wrote: ~/rpmbuild/RPMS/x86_64/kernel-devel-2.6.32-279.19.2.el6.x86_64.rpm #保守起键,先安装kernel-firmware再更新内核: rpm -ivh ~/rpmbuild/RPMS/x86_64/kernel-firmware-2.6.32-279.19.2.el6.x86_64.rpm rpm -ivh ~/rpmbuild/RPMS/x86_64/kernel-2.6.32-279.19.2.el6.x86_64.rpm #验证安装正确性,检查/etc/grub.conf文件,默认启动的应该是我们新编的内核版本号 title CentOS (2.6.32-279.19.2.el6.x86_64) #好吧,检查一下grub的启动顺利,一切正常就重启吧。 reboot # 重启完成后检查一下最新内核是否生效 uname -a