本文共 4128 字,大约阅读时间需要 13 分钟。
=================================================================== 联系方式:Author:300second QQ:84287030 Blog:运维交流群:80068448(欢迎广大朋友一起交流windows/linux/unix技术)
文档信息: 文档版本:Version 1.0 修改记录:2012-3-25 系统环境:CentOS 5.5(适合32bit and 64bit) 格式约定: 灰色底:输入的系统命令 黄色底:输入的系统命令返回的信息或者配置文件文本信息 绿色底:技巧或需要注意的地方 红色底:需要特别注意的地方 蓝色字:内容注释 =================================================================== CentOS 5.5所带的内核还是比较老(2.6.18版),所以本次编译升级了性能比较好的2.6.35.X系列稳定内核2.6.35.13版,并做以下笔录! 1)下载新内核从官方网站下载2.6.35.13版本:http://www.kernel.org/pub/linux/kernel/v2.6/longterm/v2.6.35/linux-2.6.35.13.tar.bz2,然后通过 Filezilla上传至/usr/src/kernels目录 [root@server ~]# cd /usr/src/kernels/[root@server kernels]# ls linux-2.6.35.13.tar.bz2 [root@server kernels]# tar jxvf linux-2.6.35.13.tar.bz2 3)开始编译内核 [root@server kernels]# cd linux-2.6.35.13 [root@server linux-2.6.35.13]# make mrproper [root@server linux-2.6.35.13]# make menuconfig HOSTCC scripts/basic/fixdep HOSTCC scripts/basic/docproc HOSTCC scripts/basic/hash HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/kxgettext.o *** Unable to find the ncurses libraries or the *** required header files. *** 'make menuconfig' requires the ncurses libraries. *** *** Install ncurses (ncurses-devel) and try again. *** make[1]: *** [scripts/kconfig/dochecklxdialog] 错误 1 make: *** [menuconfig] 错误 2[root@server linux-2.6.35.13]# yum -y install ncurses-devel [root@server linux-2.6.35.13]# make menuconfig [root@server linux-2.6.35.13]# make all [root@server linux-2.6.35.13]# make modules 此时出现“ WARING:modpost:Found 2 section mismatch(es). ”错误提示,如下: 那么重新敲入:make CONFIG_DEBUG_SECTION_MISMATCH=y 编译 [root@server linux-2.6.35.13]# make CONFIG_DEBUG_SECTION_MISMATCH=y 编译完成后,再重新编译内核模块 [root@server linux-2.6.35.13]# make modules [root@server linux-2.6.35.13]# make modules_install [root@server linux-2.6.35.13]# make install sh /usr/src/kernels/linux-2.6.35.13/arch/x86/boot/install.sh 2.6.35.13 arch/x86/boot/bzImage \ System.map "/boot" 如果只是按上述步骤完成编译,重启加载新内核启动会报如下类似错误: 经过搜索后,发现此类问题多集中在逻辑卷管理的情况,具体原因是在编译升级内核时没有加载一些逻辑卷,因此在执行完“ make all ”之后“ linux-2.6.35.13 ”文件夹下会生成配置文件“ .config ”, 要先编辑此文件: 改“ #CONFIG_SYSFS_DEPRECATED_V2 is not set ”为“ CONFIG_SYSFS_DEPRECATED_V2=y ” 或者直接用下面 sed 命令更改: [root@server linux-2.6.35.13]# sed -i 's/# CONFIG_SYSFS_DEPRECATED_V2 is not set/CONFIG_SYSFS_DEPRECATED_V2=y/' .config 修改完此配置文件后再次“ make all ”以及完成后续步骤。 [root@server linux-2.6.35.13]# make all [root@server linux-2.6.35.13]# make CONFIG_DEBUG_SECTION_MISMATCH=y [root@server linux-2.6.35.13]# make modules [root@server linux-2.6.35.13]# make modules_install [root@server linux-2.6.35.13]# make install 4)解压initrd文件 [root@server linux-2.6.35.13]# cp /boot/initrd-2.6.35.13.img /tmp [root@server linux-2.6.35.13]# cd /tmp/ [root@server tmp]# mkdir newinitrd [root@server tmp]# cd newinitrd/ [root@server newinitrd]# zcat ../initrd-2.6.35.13.img |cpio -i [root@server newinitrd]# vi init # 删掉重复的两行其中一行 echo "Loading dm-region-hash.ko module" insmod /lib/dm-region-hash.ko echo "Loading dm-region-hash.ko module" insmod /lib/dm-region-hash.ko 5)重新打包initrd文件[root@server newinitrd]# find .|cpio -c -o > ../initrd 11286 blocks [root@server newinitrd]# cd ../ [root@server tmp]# gzip -9 < initrd > initrd-2.6.35.13.img [root@server tmp]# rm -rf /boot/initrd-2.6.35.13.img [root@server tmp]# cp initrd-2.6.35.13.img /boot 6)修改默认以新的内核启动 [root@server tmp]# less /etc/grub.conf # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/hdd3 # initrd /initrd-version.img #boot=/dev/hdd default=1 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title CentOS (2.6.35.13) root (hd0,0) kernel /vmlinuz-2.6.35.13 ro root=LABEL=/ rhgb quiet initrd /initrd-2.6.35.13.img title CentOS (2.6.18-194.el5) root (hd0,0) kernel /vmlinuz-2.6.18-194.el5 ro root=LABEL=/ rhgb quiet initrd /initrd-2.6.18-194.el5.img [root@server tmp]# vi /boot/grub/grub.conf 把 default=1 改为 default=0 ,然后重新启动系统 [root@server tmp]# reboot 7)重启后验证内核版本
转载地址:http://aybxl.baihongyu.com/