编译Linux内核(菜鸟级)

    技术2022-05-11  56

    编译Linux内核 2.4.20-8到2.4.21   RedHat9的内核是2.4.20-8,现在要编译2.4.21的内核。   一、下载相关内核 到 http://www.kernel.org/pub/linux/kernel/v2.4下载相关内核 此处需要下载的文件为linux-2.4.21.tar.bz2(大小为27M)或者linux-2.4.21.tar.gz(大小为34M). 将下载的内核放在/usr/src/下面,此文件夹下有原来的内核的文件夹名为linux-2.4.20-8,还有一个linux的文件夹,是linux-2.4.20-8链接。   1.将linux文件夹删除。 2.解压新的内核. tar jxvf linux-2.4.21.tar.bz2或者tar zxvf linux-2.4.21.tar.gz 解压后生成的文件夹名为linux-2.4.21 3.用ln-s linux-2.4.21 linux建立一个链接。   二、配置内核 在目录/usr/src/linux下用命令make xconfig 配置内核,配置内核的文章多多。贴几个较好的链接看看吧。 http://www.magiclinux.org/people/kde/web/article252.htm http://blog.csdn.net/_document/archive/2005/07/11/421050.aspx http://www.uplinux.com/www/sys/02/187.shtml   据说2.4升级到2.6的话还要同时升级 module-init-tools 软件包,这里因为都是 2.4 ,所以就不用了。   按照以上链接所介绍的配置,基本没什么问题,只是有一点,是我在编译时遇到的提一下。就是关于 scsi 接口硬盘的配置。除了 scsi support 中要选中外,还需要在 scsi support low-level 中选取中 BusLogic. 要不然总是提示 cannot find file… 什么的,然后就启不起来了。   三、 编译内核 据说 2.6 的内核现在编译起来可方便了,只要 make 一下即可。但是 2.4 的还是需要几步走的 : make dep make clean ( 我也不确定啥时候需要这一步 , 不过好像用一下也没什么关系 ) make bzImage(创建新内核) make modules(编译模块,一般配置时总会有一些配置成模块的,所以一般用得着这两步) make modules_install   四、安装新内核 #pwd /usr/src/linux #cp arch/i386/boot/bzImage /boot/vmlinuz-2.4.21 #cp System.map /boot/System.map-2.4.21 #cd /boot #rm System.map #ln –s System.map-2.4.21 System.map   五、修改grub.conf #vim /boot/grub/grub.conf 其文件如下: default=0 timeout=10 splashimage=(hd0,0)/grub/splash.xpm.gz 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   在下面增加几行: title Red Hat Linux(2.4.21)        root(hd0,0)        kernel /vmlinuz-2.4.21 ro root =/dev/sda2   其中的/dev/sda2确定方法,用命令df可查看.

    最新回复(0)