升级2.6.18到2.6.34.1

最新内核下载地址:http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.34.tar.bz2

首先我们的准备好要用的工具,有如下四个

module-init-tools

mkinitrd

lvm2

device-mapper

可以用rpm -qa *来查询,如果系统没有的话请自己到网上搜索并安装上

系统环境

# uname -r

2.6.18-128.el5

编译安装新内核

# tar -jxvf linux-2.6.34.1.tar.bz2 -C /usr/src/

# ln -s linux-2.6.34.1 linux

# cd linux

# cp /boot/config-2.6.18-128.el5 ./.config

# vim .config

CONFIG_SYSFS_DEPRECATED_V2=y #默认该选项为not set,

否则重启后报错

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!

+++++++++++++++++++

一定要作不然重启会报错,你会后悔的,~~要知道重新编译一次得多长时间,60多M的内核啊^^

+++++++++++++++++++

# make mrproper

# make menuconfig

(1)Loadable Module support选项中,选上“Module unloading”和“Automatic kernel module loading”这两项;

(2)Device Drivers--->Block Devices中选上“Loopback device support”;

Device Drivers--->Multi-device support(RAID and LVM)处要选上“device mapper support”;

Device Drivers--->Graphics support,一定要选上“ Support for frame buffer devices”;

Device Drivers --->USB support --->选上“USB Mass Storage support”(如果是在实环境中,想要更多USB支持,就全选吧。我的是在虚拟机中,用不着了)

Device Drivers ---&gt;;Network device support ---&gt;Ethernet (10 or 100Mbit) ---&gt;<*> AMD PCnet32 PCI support

(3)File system---&gt;(以下9个选项是关于ext2和ext3文件系统配置,全部选上,要直接编译进内核,就是要按Y来选择,)

Second extended fs support(注意:此处默认是编译成模块,在此要按Y键)

Ext2 extended attributes

Ext2 POSIX Access Control Lists

Ext2 Security Labels

Ext3 journalling file system support

Ext3 extended attributes

Ext3 POSIX Access Control Lists

Ext3 Security Labels

JBB (ext3) debugging support

Device Drivers ---&gt;<*>SCSI device support (此项不选的话,下面两项就选择不上)

Device Drivers ---&gt;<*>SCSI device support ---&gt;<*>SCSI disk support

Device Drivers---&gt;<8>SCSI device support---&gt;SCSI low-level drivers---&gt;<*>; BusLogic SCSI support

# make bzImage

# make modules

# make modules_install

# make install

此时会出现3个警告,没有关系,是没有对系统打补丁造成的

可参考https://bugzilla.redhat.com/show_bug.cgi?id=488991 对内核打相应补丁

sh /usr/src/linux-2.6.34/arch/x86/boot/install.sh 2.6.34 arch/x86/boot/bzImage System.map "/boot"

WARNING: No module dm-mem-cache found for kernel 2.6.27, continuing anyway

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

WARNING: No module dm-raid45 found for kernel 2.6.27, continuing anyway

下面这几个步骤一定要做,可省君不少时间呵,

否则重启报错

insmod: error inserting ‘/lib/dm-region-hash.ko’: –1 File exits

+++++++++++++++++++++++++++++++

1.解压initrd

# cp /boot/initrd-2.6.34.img /tmp

# cd /tmp/

# ls

initrd-2.6.34.img

# mkdir newinitrd

# cd newinitrd/

# zcat ../initrd-2.6.34.img |cpio -i

11537 blocks

# ls

bin dev etc init lib proc sbin sys sysroot

2.编辑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

3.重新打包initrd

# find .|cpio -c -o &gt; ../initrd

11538 blocks

# cd ..

# gzip -9 < initrd > initrd-2.6.34.img

# ls

initrd-2.6.34.img initrd newinitrd

initrd-2.6.34.img就是重新打包的initrd了,然后把initrd.img拷贝到/boot,就可以了,再reboot,就不会有之前的错误了.

将init文件的第二行“setquiet” 去掉,boot时就可以打印出initrd在做什么,功能类似于 sh –x init

这个应该是某个地方配置的有问题,所以才出现了重复加载的问题,没时间去细究原因,代价是每次make install后都需要按照上面的步骤修改initrd.img

+++++++++++++++++++++++++++++++

# vim /boot/grub/grub.conf

将default=1改为default=0(不改的话也可以,只不过重启之后会默认进入2.6.18内核)

重启查看我们新安装好的内核

# uname -r

2.6.34

# service iptables start
Unloading iptables modules:                                [  OK  ]
Applying iptables firewall rules: iptables-restore v1.3.5: iptables-restore: unable to initializetable 'nat'

Error occurred at line: 2
Try `iptables-restore -h' or 'iptables-restore --help' for more information.
                                                           [FAILED]

# service iptables save
Saving firewall rules to /etc/sysconfig/iptables:          [  OK  ]
# service iptables start
Flushing firewall rules:                                   [  OK  ]
Setting chains to policy ACCEPT: filter                    [  OK  ]
Unloading iptables modules:                                [  OK  ]
Applying iptables firewall rules:                          [  OK  ]
Loading additional iptables modules: ip_conntrack_netbios_n[FAILED]
# service iptables start
Flushing firewall rules:                                   [  OK  ]
Setting chains to policy ACCEPT: filter                    [  OK  ]
Unloading iptables modules:                                [  OK  ]
Applying iptables firewall rules:                          [  OK  ]
Loading additional iptables modules: ip_conntrack_netbios_n[FAILED]

# vim /etc/sysconfig/iptables-config

IPTABLES_MODULES=”ip_conntrack_netbios_ns”     =====注释掉

# service iptables start
Flushing firewall rules:                                   [  OK  ]
Setting chains to policy ACCEPT: filter                    [  OK  ]
Unloading iptables modules:                                [  OK  ]
Applying iptables firewall rules:                          [  OK  ]
[root@song linux]# service iptables restart
Flushing firewall rules:                                   [  OK  ]
Setting chains to policy ACCEPT: filter                    [  OK  ]
Unloading iptables modules:                                [  OK  ]
Applying iptables firewall rules:                          [  OK  ]

 

Ok