Chinaunix首页 | 论坛 | 博客
  • 博客访问: 332000
  • 博文数量: 53
  • 博客积分: 2200
  • 博客等级: 大尉
  • 技术积分: 881
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-28 18:00
文章分类

全部博文(53)

文章存档

2010年(12)

2009年(33)

2008年(8)

我的朋友

分类: LINUX

2010-04-09 17:05:35

之前尝试过将系统升级到2.6.31,结果失败了,由于工作太紧张,也没有去继续尝试,最近的时间稍微有些空,就又想起来这事情了。到看了下,最新的内核版本都到2.6.33了,就打算直接升级2.6.33了。

一、环境

使用的Vmware安装装的RedHat5.3,下面都是使用的root用户进行操作

#uname -r

2.6.18-53.el5

二、升级过程

1)         下载内核

升级之前到看看有没有最新的内核,目前为止最新的是2.6.33,下载地址是:

2)         linux-2.6.33.tar.bz2拷贝到/usr/local/src目录下面,使用下面的命令解压,得到文件夹linux-2.6.33

tar xjvf linux-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 an Alternate Configuration File,导入.config文件,更加自己的需要添加功能或者进行精简。

注:内核配置有两种方法,一种是直接置入内核* ;另一种是编成模块M ; 两种方法各有优点;直接编入内核的,比如设备的启动,不再需要加载模块的这一过程了;而编译成模块,则需要加载设备的内核支持的模块;但直接把所有的东西 都编入内核也不是可行的,内核体积会变大,系统负载也会过重。我们编内核时最好把极为重要的编入内核;其它的如果您不明白的,最好用默认[3]

修改完毕选择Save an Alternate Configuration File,然后退出配置。 

6)         修改.config文件

.config文件搜索CONFIG_SYSFS_DEPRECATED_V2,会发现# CONFIG_SYSFS_DEPRECATED_V2 is not set这一行,将该行修改为CONFIG_SYSFS_DEPRECATED_V2=y

假如不修改该行,在升级重新启动后会报如下的错,导致启动失败

Volume group "VolGroup00" not found

Unalbe to access resume device (/dev/VolGroup00/LogVol00)

mount: could not find filesystem '/dev/root'

setuproot:moving /dev failed: No such file or directory

setuproot:error mounting /proc: No such file or directory

setuproot:error mounting /sys: No such file or directory

switchroot: mount failed: No such file or directory

Kernel panic - not syncing:Attempted to kill 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, continuing anyway

WARNING: No module dm-message found for kernel 2.6.33, continuing anyway

WARNING: No module dm-raid45 found 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 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目录下

#cp initrd-2.6.33.img /boot

11)     重新启动

启动成功。

#uname –r

2.6.33

三、待解决问题

1)         Iptables启动失败

操作系统启动过程中出现下面的错误信息:

 

Applying ip6tables firewall rules: ip6tables-restore v1.3.5: ip6tables-restore:unable to initalizetable 'filter'

Error accurred at line: 3

Try "ip6tables-restore -h' or 'ip6tables-restore --help' for more information.

Applying iptables firewall rules: iptables-restore v1.3.5: iptables-restore:unable to initalizetable 'filter'

Error accurred at line: 3

Try "iptables-restore -h' or 'iptables-restore --help' for more information.

启动后尝试手动启动防火墙:

#service iptables status

防火墙已停

#service iptables start

正在卸载 Iiptables 模块:[确定]

应用 iptables 防火墙规则:iptables-restore v1.3.5: iptables-restore: unable to initializetable 'filter'

Error occurred 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

正在启动 hiddCan't open HIDP control socket: Address family not supported by protocol

[失败]

四、说明

本人也是新手,第一次升级内核成功,很多具体的细节还不是很清楚,还有两个问题没 有解决,由于升级过程中遇到不少麻烦,大家可能也会遇到这样的问题,就将这些信息分享出来,希望以上的升级过程能够给大家一些帮助,假如有什么疏漏和错 误,或者大家对上面出现的问题有什么好的解决方法,希望大家不吝赐教。

                   下面的几篇文档给了我很大的帮助,谢谢!

邮箱:haifengwang1987#gmail.com

 

参考资料:

[1] 编译内核2.6.30遇到的问题与解决办法 http://blog.csdn.net/polisan/archive/2009/11/16/4818921.aspx

[2] Centos 升级内核 kernel 2.6.30 http://hi.baidu.com/rhca/blog/item/2be78c01bcf5d9df267fb5e7.html

[3]

阅读(2075) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~