之前尝试过将系统升级到2.6.31,结果失败了,由于工作太紧张,也没有去继续尝试,最近的时间稍微有些空,就又想起来这事情了。到www.kernel.org看了下,最新的内核版本都到2.6.33了,就打算直接升级2.6.33了。
一、环境
使用的Vmware安装装的RedHat5.3,下面都是使用的root用户进行操作
#uname -r
2.6.18-53.el5
二、升级过程
1) 下载内核
升级之前到www.kernel.org看看有没有最新的内核,目前为止最新的是2.6.33,下载地址是:http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.33.tar.bz2
2) 将linux-2.6.33.tar.bz2拷贝到/usr/local/src目录下面,使用下面的命令解压,得到文件夹linux-2.6.33
tar xjvflinux-2.6.33.tar.bz2
3) make distclean
假如是第一次编译,这一步骤可以省掉的。
4) 复制原有的config文件到linux-2.6.33目录
#cd /usr/local/src/linux-2.6.33
# cp/boot/config-2.6.18-53.el5 .config
5) make menuconfig
选择Load anAlternate Configuration File,导入.config文件,更加自己的需要添加功能或者进行精简。
注:内核配置有两种方法,一种是直接置入内核* ;另一种是编成模块M ;两种方法各有优点;直接编入内核的,比如设备的启动,不再需要加载模块的这一过程了;而编译成模块,则需要加载设备的内核支持的模块;但直接把所有的东西都编入内核也不是可行的,内核体积会变大,系统负载也会过重。我们编内核时最好把极为重要的编入内核;其它的如果您不明白的,最好用默认[3]。
修改完毕选择Save an Alternate Configuration File,然后退出配置。
6) 修改.config文件
在.config文件搜索CONFIG_SYSFS_DEPRECATED_V2,会发现# CONFIG_SYSFS_DEPRECATED_V2is not set这一行,将该行修改为CONFIG_SYSFS_DEPRECATED_V2=y
假如不修改该行,在升级重新启动后会报如下的错,导致启动失败
Volume group "VolGroup00" notfound
Unalbe to access resume device(/dev/VolGroup00/LogVol00)
mount: could not find filesystem'/dev/root'
setuproot:moving /dev failed: No suchfile or directory
setuproot:error mounting /proc: No suchfile or directory
setuproot:error mounting /sys: No suchfile or directory
switchroot: mount failed: No such fileor directory
Kernel panic - not syncing:Attempted tokill init!
7) 编译内核
#make all
大概需要半个小时到一个小时的时间。
8) #make modules_install
9) #make install
这时候会出现3个警告[2]
WARNING: No module dm-mem-cache found for kernel 2.6.33, continuinganyway
WARNING: No module dm-message found for kernel 2.6.33, continuinganyway
WARNING: No module dm-raid45found for kernel 2.6.33, continuing anyway
经过测试,这3个警告不会影响内核的升级,参考资料[2]中有相关的说明。
10) 修改initrd文件
假如在升级重启后会报的错误insmod: error inserting ‘/lib/dm-region-hash.ko’: –1 File exits,这是由于initrd里面的init中加载dm-region-hash.ko这个模块重复了,因此需要修改生成的initrd文件(不是所有的机器都会出现这个错),修改的方式如下[1],方法见参考资料1:
a) 解压initrd
#cp /boot/initrd-2.6.33.img /tmp
#cd /tmp/
#ls
initrd-2.6.33.img
#mkdir newinitrd
#cd newinitrd/
#zcat ../initrd-2.6.33.img |cpio -i
#ls
bin dev etc init lib proc sbin sys sysroot
b) 编辑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
c) 重新打包initrd
#find .|cpio -c -o > ../initrd
#cd ..
# gzip -9 <initrd > initrd-2.6.33.img
d) 将initrd重新复制到/boot目录下
#cpinitrd-2.6.33.img /boot
11) 重新启动
启动成功。
#uname –r
2.6.33
三、待解决问题
1) Iptables启动失败
操作系统启动过程中出现下面的错误信息:
Applyingip6tables firewall rules: ip6tables-restore v1.3.5: ip6tables-restore:unable toinitalizetable 'filter'
Erroraccurred at line: 3
Try"ip6tables-restore -h' or 'ip6tables-restore --help' for more information.
Applyingiptables firewall rules: iptables-restore v1.3.5: iptables-restore:unable to initalizetable'filter'
Erroraccurred at line: 3
Try"iptables-restore -h' or 'iptables-restore --help' for more information.
启动后尝试手动启动防火墙:
#service iptables status
防火墙已停
#service iptables start
正在卸载 Iiptables 模块:[确定]
应用 iptables 防火墙规则:iptables-restorev1.3.5: iptables-restore: unable to initializetable 'filter'
Erroroccurred at line: 3
Try`iptables-restore -h' or 'iptables-restore --help' for more information.
[失败]
2) Hidd(Bluetooth HID daemon)启动失败
Starting hidd:Can't open HIDP control socket: Address family not supported by protocol [FAILED]
# service hidd status
hidd 已死,但是 subsys 被锁
# service hidd start
正在启动 hidd:Can't openHIDP control socket: Address family not supported by protocol
[失败]
四、说明
本人也是新手,第一次升级内核成功,很多具体的细节还不是很清楚,还有两个问题没有解决,由于升级过程中遇到不少麻烦,大家可能也会遇到这样的问题,就将这些信息分享出来,希望以上的升级过程能够给大家一些帮助,假如有什么疏漏和错误,或者大家对上面出现的问题有什么好的解决方法,希望大家不吝赐教。
下面的几篇文档给了我很大的帮助,谢谢!
邮箱:haifengwang1987#gmail.com
参考资料:
[1] 编译内核2.6.30遇到的问题与解决办法 http://blog.iyunv.com/polisan/archive/2009/11/16/4818921.aspx
[2]Centos 升级内核 kernel 2.6.30 http://hi.baidu.com/rhca/blog/item/2be78c01bcf5d9df267fb5e7.html
[3] http://linux.iyunv.com/bbs/viewthread.php?tid=1147827&page=1&extra=#pid7171483
版权声明:本文为博主原创文章,未经博主允许不得转载。 |