升级Linux2.4.9内核到2.6.26.3版


近来有时间,将一台DELL6550服务器进行了系统升级,反复忙活了一天,还算顺利,升级成功。

一、环境

主机:DELL POWEREDGE 6650,

CPU:英特尔(R) 至强(TM) 处理器 MP 1400MHZ/512K *2
显卡:ATI RAGE XL,带 8MB 显存
网卡:BROADCOM NETXTREME(TM) GIGABIT *2
SCSI:ULTRA 3 U160 SCSI ADAPTER(R) AIC7892 1
CD-ROM:12/24X TEAC,EIDE

内存:1024MB ECC
RAID卡: LSI megaraid PERC3/DC,128MB(1 INTERNAL/1 EXTERNAL CHANNELS) 1

软件: Red Hat Linux Advanced Server 2.1 (Linux 2.4.9-e.3 smp)

磁盘分区

分区 大小 安装点
/dev/sda1 128M /boot
/dev/sda2 4G /
/dev/sda5 10G /home
/dev/sda6 120G /data1
/dev/sda7 120G /data2
二、预备

1、下载最新稳定版内核源码:

Linux 2.6.26.3

http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.26.3.tar.bz2

2、下载内核编译相关软件:

Linux 2.6.26.3 编译需要相关软件的最低版本如下:

软件名称 最低版本 检查命令

Gnu C 3.2 # gcc --version
Gnu make 3.79.1 # make --version
binutils 2.12 # ld -v
util-linux 2.10o # fdformat --version
module-init-tools 0.9.10 # depmod -V
e2fsprogs 1.29 # tune2fs
jfsutils 1.1.3 # fsck.jfs -V
reiserfsprogs 3.6.3 # reiserfsck -V 2>&1|grep reiserfsprogs
procps 3.2.0 # ps --version
grub 0.93 # grub --version
oprofile 0.9 # oprofiled --version
udev 081 # udevinfo -V
xfsprogs 2.6.0 # xfs_db -V
pcmciautils 004 # pccardctl -V
quota-tools 3.09 # quota -V
PPP 2.4.0 # pppd --version
nfs-utils 1.0.5 # showmount --version
根据我的系统,蓝色部分需要升级,后面的因为用不到,没有下载。可以先到ftp://ftp.gnu.org/gnu 上找找,没有就搜索一下,很容易找到的。

3、规划安装目录

因本次升级较大,需要软件较多,估计磁盘空间需要1G以上,选好自己的安装点,本机选择HOME卷,统一安装在/home/src目录下。

4、安装GCC

在GNU站点ftp://ftp.gnu.org/gnu/下载gcc,现在最新版本是gcc-4.3.2,考虑到内核稳定性,还是选择gcc-3.4.6.tar.bz2,下载到/home/src下:

tar xvIf gcc-3.4.6.tar.bz2

./configure

make

make install

默认是安装在/usr/local/gcc-3.4.6下面。

检查原gcc,用命令 whereis gcc ,发现安装在/usr/bin/gcc,需要建立连接:

cd /usr/bin

mv gcc gcc.old

ln -s /usr/local/gcc-3.4.6/bin/gcc /usr/bin/gcc

完毕后,再检查版本:

gcc -v
Reading specs from /usr/local/gcc-3.4.6/lib/gcc/i686-pc-linux-gnu/3.4.6/specs
Configured with: ./configure --prefix=/usr/local/gcc-3.4.6
Thread model: posix
gcc version 3.4.6

则证明安装完成,搜索路径设置正确。

3、逐一安装其他软件,并检查版本,保证安装正确。
三、升级过程

准备好后,开始进入内核编译阶段。内核编译其实就是内核裁减过程,根据我们的PC配置情况,选择相应的模块,进行编译。linux可以将各种驱动、模块编译到内核中,也可以作为可动态加载模块(modules)存在,考虑到安全和性能,我选择尽量编译入内核,很少用的部分选modules。

1、配置

make menuconfig (我用字符终端,图形模式可选make xconfig)

内部选项非常多,不明白的就看help,原则:尽量少选,看不明白就选默认设置。我调整的设置主要有:

-调整CPU类型- (X) Pentium-4/Celeron(P4-based)/Pentium-4 M/older Xeon

-调整CPU个数- (2) Maximum number of CPUs (2-255)

-选择网卡- <*> Broadcom NetXtremeII support

-选择SCSI卡驱动- <*> Adaptec AIC7xxx Fast -> U160 support (New Driver)

-选择RAID卡驱动- <*> LSI Logic MegaRAID Driver (New Driver)
<*> LSI Logic Legacy MegaRAID Driver

-选择显卡- <*> ATI chipset support

2、编译:

make ##编译内核

make modules ##编译模块

make modules_install ##安装模块,安装到/lib/modules/2.6.26.3

make install ##安装新内核

最后这一步,会将编译好的内核安装的/boot下面,同时自动配置grub启动设置。我执行时,grub配置出现错误,只能手工调整启动菜单,增加一个启动项

# 2.6.26.3Mao2008
title Linux 2.6.26.3-2008.
root (hd0,0)
kernel /vmlinuz-2.6.26.3Mao2008 ro root=/dev/sda2

3、调试

配置完毕,就可以进行启动测试了,很巧合,我启动失败,屏幕启动时无法进入grub菜单,只有GRUB提示就玩完了,经分析,肯定是升级grub造成的,没办法,找出紧急救援磁盘,进入后,将系统mount到/mnt上,启动/mnt/sbin/grub,注意,这是我系统盘的程序,进入grub命令界面:

grub> find /grub/stage1
(hd0,0) #找到启动boot分区

grub> root (hd0,0) #设置启动分区
Filesystem type is ext2fs, partition type 0x83

grub> setup (hd0) #配置MBR和boot分区启动扇区
Checking if "/boot/grub/stage1" exists... no
Checking if "/grub/stage1" exists... yes
Checking if "/grub/stage2" exists... yes
Checking if "/grub/e2fs_stage1_5" exists... yes
Running "embed /grub/e2fs_stage1_5 (hd0)"... 16 sectors are embedded.
succeeded
Running "install /grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/grub/stage2 /grub/menu
.1st"... succeeded
Done.

grub>

重新启动,正常进入,系统:

# uname -a
Linux *** 2.6.26.3 #1 SMP Tue Sep 2 15:32:37 CST 2008 i686

相关内容