linux 内核更新(V2.4.*-->V2.6.10)

一、内核更新准备工作

1)下载一份内核源代码linux-2.6.10.tar.bz2,可在如下地址下载它或者是更新的版本http://www.kernel.org/pub/linux/kernel/v2.6/
   

2) 下载最新版本的module-init-tools-3.4.tar.gz 和 modutils-2.4.26-1.src.rpm用于生成initrd文件
http://www.kernel.org/pub/linux/kernel/people/jcm/module-init-tools/attic/module-init-tools-3.4.tar.gz
http://www.kernel.org/pub/linux/utils/kernel/modutils/v2.4/modutils-2.4.26-1.src.rpm
   

3)安装module-init-tools. 它会替代depmod [/sbin/depmod]和其他工具.
       tar -zxvf module-init-tools-3.0.tar.gz
       cd module-init-tools-3.0
       ./configure --prefix=/sbin
       make
       make install
       ./generate-modprobe.conf /etc/modprobe.conf
   

4)安装modutils-2.4.26-1.src.rpm. 可能会看到"user rusty and group rusty not existing"的警告. 没关系,你只需强制安装就是了.如果你不对Redhat 9和Redhat 8做这几步, 你将会在"make modules_install"这一步时出现问题.
       rpm -i modutils-2.4.26-1.src.rpm
       rpmbuild -bb /usr/src/redhat/SPECS/modutils.spec
       rpm -Fi /usr/src/redhat/RPMS/i386/modutils-2.4.26-1.i386.rpm
   

5)解压缩内核源代码.把下载的源代码包放到目录/usr/src下,然后
       cd /usr/src
       tar xvfj linux-2.6.10.tar.bz2
       cd linux-2.6.10

 

二、配置内核

  cd linux-2.6.10(进入到/usr/src/linux-2.6.10目录下)
      make mrproper  (该命令可确保源代码目录下没有不正确的.o文件)
      make menuconfig(配置内核各选项)

此时会出现一个图形界面,列出了所有的内核配置选项,有的选项下还有子选项,你可以用方向键来选择,用Y键来确定。经过我多次试验,大多数选项默认就行,以下几个选项必
须选择(请认真核对下面每一个选项,否则编译很有可能前功尽弃):

(1)Loadable Module support选项中,选上"<*>Module unloading"和"<*>Automatic kernel module loading"这两项;
    (2)Device Drivers--->Block Devices中选上"

  <*>Loopback device support"

  <*>Initial RAM disk(initrd) Support
     Device Drivers--->Multi-device support(RAID and LVM)处要选上"<*>device mapper  support"
     Device Drivers--->Graphics support一定要选上"<*>Support for buffer devices"
     Device Drivers--->USB support--->选上"<*>USB Mass Storage support"(如果是在实环境中,想要更多USB支持,就全选吧。我的是在虚拟机中,用不着了)
     Device Drivers--->Network device support--->Ethernet(10 or 100Mbit)---><*>AMD PCnet32 PCI support
    (3)File system--->(以下9个选项是关于ext2和ext3文件系统配置,全部选上)(注:文件系统中的选项最好都编译到内核中,所以选择时,选择<*>)
     Second extended fs support
     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
     File system--->DOS/FAT/NT Filesystems--->选上"<*>NTFS file system support"

(4)如果你在vmware下编译内核,硬盘用的是scsi的,以下三个选项必选:
     Device Drivers ---><*>SCSI device support(此项不选的话,下面两项就选择不上)
     Device Drivers ---><*>SCSI device support---><*>SCSI disk support
     Device Drivers---><8>SCSI device support--->SCSI low-level drivers---><*>BusLogic SCSI support

 

三、编译内核

在/usr/src/linux-2.6.10目录下,执行以下命令即可编译

make dep(建立编译时所需的从属文件。注意:如果内核从未编译过,此步可跳过)

make clean(清除内核编译的目标文件。注意:如果内核从未编译过,此步可跳过)

make bzImage(注意大小写。这一步才是真正编译内核)
   

内核编译成功后,会在/usr/src/linux/arch/i386/boot目录中生成一个新内核的映像文件bzImage。如果用make  zImage编译,内核很大的话,系统会提示你使用make bzImage命令来编译,所以我直接用make bzImage来编译。

make modules(编译可加载模块)

make modules_install(安装可加载模块)

安装成功后,系统会在/lib/modules目录下生成一个2.6.10子目录,里面存放着新内核的所有可加载模块。

make install(安装新内核)

 

四、启动新内核

1、将新内核和System.map文件拷贝到/boot目录下,依次执行以下命令:

cp  /usr/src/linux-2.6.10/arch/i386/boot/bzImage   /boot/vmlinuz-2.6.10    

cp  /usr/src/linux-2.6.10/System.map   /boot/System.map-2.6.10    

cd  /boot  (进入boot目录)

rm –rf  System.map  (删除原来的连接)    

ln –s System.map-2.6.10  System.map   (重新建立连接)

 

2、修改Grub启动管理器

在/boot目录下,执行以下命令:

new-kernel-pkg --mkinitrd --depmod --install 2.6.10 这时候你的/boot下会生成一个initrd-2.6.10.img,并且你的grub.conf文件也作了相应更改。如果没有出现该文件,则需要以下操作

cp /usr/src/linux-2.6.10/drivers/scsi/BusLogic.o  /lib/modules/2.6.10/kernel/drivers/scsi
复制过后再执行一下make install。然后再拷贝新内核和System.map文件,最后再执行new-kernel-pkg --mkinitrd --depmod --install 2.6.10,便可以生成initrd文件。

 

可以用df命令查看根目录分区,以便于修改grub.conf中新内核启动目录。

vi /etc/grub.conf(修改grub.conf)
    进入grub.conf文件,找到如下信息
default=1
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Linux (2.6.10)
        root (hd0,0)
        kernel /vmlinuz-2.6.10 ro root= LABEL=/5
        initrd /initrd-2.6.10.img
做两处修改:
(1) 将default=1改为default=0(不改的话也可以,只不过重启之后会默认进入2.4内核)
(2) 将kernel行的“LABEL=/”换成根目录所在的分区(上一步查看的就是)
此步很重要,修改错误将可能导致进不去系统,我把我修改后的grub.conf文件列出来,不明之处,可以对照修改:
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Linux (2.6.10)
        root (hd0,0)
        kernel /vmlinuz-2.6.10 ro root=/dev/hda2
        initrd /initrd-2.6.10.img
title Red Hat Linux (2.4.20-8)
        root (hd0,0)
        kernel /vmlinuz-2.4.20-8 ro root=LABEL=/
        initrd /initrd-2.4.20-8.img

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值