[转载]linux2.6.7内核的升级
<P>信息来源:邪恶八进制信息安全团队(<A href="http://www.eviloctal.com">www.eviloctal.com</A>)<BR></P><STRONG>一 编译前准备</STRONG><SPAN><BR><BR> 1)<A href="http://www.eduz.cn/SiteMap/Soft1.htm"><SPAN><FONT color=#336699>下载</FONT></SPAN></A></SPAN>一份内核源代码<SPAN>,</SPAN>我下的是<SPAN>linux-2.6.7.tar.bz2,</SPAN>你可在如下地址<SPAN><A href="http://www.eduz.cn/SiteMap/Soft1.htm"><SPAN><FONT color=#336699>下载</FONT></SPAN></A></SPAN>它或者是更新的版本<SPAN>.<BR><A href="http://kernel.org/pub/linux/kernel/v2.6/" target=_blank><U><FONT color=#336699>[url]http://kernel.org/pub/linux/kernel/v2.6/[/url]</FONT></U></A><BR><BR> 2) <A href="http://www.eduz.cn/SiteMap/Soft1.htm"><SPAN><FONT color=#336699>下载</FONT></SPAN></A></SPAN>最新版本的<SPAN>module-init-tools( "module-init-tools-3.0.tar.gz" and "modutils-2.4.21-23.src.rpm")<BR><A href="http://www.kernel.org/pub/linux/kernel/people/rusty/modules/module-init-tools-3.0.tar.gz" target=_blank><U><FONT color=#336699>[url]http://www.kernel.org/pub/linux/ker...ools-3.0.tar.gz[/url]</FONT></U></A> <BR><A href="http://www.kernel.org/pub/linux/ker...4.21-23.src.rpm" target=_blank><U><FONT color=#336699>[url]http://www.kernel.org/pub/linux/ker...4.21-23.src.rpm[/url]</FONT></U></A> <BR><BR> 3)</SPAN>安装<SPAN>module-init-tools. </SPAN>它会替代<SPAN>depmod [/sbin/depmod]</SPAN>和其他工具<SPAN>.<BR>tar -zxvf module-init-tools-3.0.tar.gz<BR>cd module-init-tools-3.0<BR>./configure --prefix=/sbin <BR>make<BR>make install <BR>./generate-modprobe.conf /etc/modprobe.conf<BR></SPAN><SPAN>4)</SPAN>安装<SPAN>modutils-2.4.21-23.src.rpm. </SPAN>你可能会看到<SPAN>"user rusty and group rusty not existing"</SPAN>的警告<SPAN>. </SPAN>没关系<SPAN>,</SPAN>你只需强制安装就是了<SPAN>.</SPAN>如果你不对<SPAN>Redhat 9</SPAN>和<SPAN>Redhat 8</SPAN>做这几步<SPAN>, </SPAN>你将会在<SPAN>"make modules_install"</SPAN>这一步时出现问题<SPAN>. <BR>rpm -i modutils-2.4.21-23.src.rpm<BR>rpmbuild -bb /usr/src/redhat/SPECS/modutils.spec<BR>rpm -Fi /usr/src/redhat/RPMS/i386/modutils-2.4.21-23.i386.rpm<BR><BR> 5)</SPAN>解压缩内核源代码<SPAN>.</SPAN>把<SPAN><A href="http://www.eduz.cn/SiteMap/Soft1.htm"><SPAN><FONT color=#336699>下载</FONT></SPAN></A></SPAN>的源代码包放到目录<SPAN>/usr/src</SPAN>下<SPAN>,</SPAN>然后<SPAN><BR>cd /usr/src <BR>tar xvfj linux-2.6.7.tar.bz2 <BR>cd linux-2.6.7 <BR><BR> </SPAN><STRONG>二、</STRONG><STRONG> </STRONG><STRONG>编译配置</STRONG><STRONG><SPAN><BR></SPAN></STRONG><SPAN><BR> </SPAN>在这一部分涉及几个重要模块的配置请<SPAN>,</SPAN>特别注意<SPAN>.</SPAN>一般用<SPAN>"make menuconfig"</SPAN>命令来配置内核<SPAN>.</SPAN>输入以上命令后出现一个菜单界面<SPAN>,</SPAN>用户可以对需要的模块<SPAN>.</SPAN>下面着重讲几个重要的配置。<SPAN><BR><BR> 1)</SPAN>文件系统<SPAN><BR></SPAN>请务必要选中<SPAN>ext3</SPAN>文件系统<SPAN>,<BR>File systems--->[*] Ext3 journalling file system support[*] Ext3 Security Labels[*] JBD (ext3) debugging support<BR></SPAN>以上三项一定要选上<SPAN>,</SPAN>而且要内建<SPAN>(</SPAN>即标<SPAN>*). </SPAN>这个非常重要<SPAN>,</SPAN>在配置完后一定要检查一下<SPAN>.config</SPAN>文件有没有<SPAN>"CONFIG_EXT3_FS=y"</SPAN>这一项<SPAN>. </SPAN>如果不是<SPAN>"CONFIG_EXT3_FS=y"</SPAN>而是<SPAN>"CONFIG_EXT3_FS=m",</SPAN>你在运行内核时就会遇上以下错误<SPAN>: pivotroot: pivot_root(/sysroot,/sysroot/initrd) failed <BR><BR> 2)</SPAN>网卡驱动<SPAN><BR></SPAN>请务必把自己网卡对应的驱动编译进内核<SPAN>,</SPAN>比较普遍的网卡是<SPAN>realtek 8139,</SPAN>以下就是这种网卡的配置<SPAN>,</SPAN>以供参考<SPAN><BR>Device Drivers---><BR>Networking support---><BR>Ethernet (10 or 100Mbit) ---><BR><*> RealTek RTL-8139 C+ PCI Fast Ethernet Adapter support (EXPERIMENTAL)<BR><*> RealTek RTL-8139 PCI Fast Ethernet Adapter support <BR><BR> 3)</SPAN>声卡驱动<SPAN><BR></SPAN>也要选择自己声卡对应的驱动编译进内核<SPAN>,</SPAN>比较普遍的声卡是<SPAN>i810_audio,</SPAN>以下就是这种声卡的配置<SPAN>,</SPAN>以供参考<SPAN><BR>Device Drivers ---><BR>Sound ---><BR><*> Sound card support<BR>Advanced Linux Sound Architecture ---><BR><*> Advanced Linux Sound Architecture<BR><*> Sequencer support<BR>< > Sequencer dummy client<BR><*> OSS Mixer API<BR><*> OSS PCM (digital audio) API[*] OSS Sequencer API<BR><*> RTC Timer support<BR>PCI devices ---><BR><*> Intel i8x0/MX440, SiS 7012; Ali 5455; NForce Audio; AMD768/8111<BR>Open Sound System ---><BR>< > Open Sound System (DEPRECATED)<BR></SPAN>以上三项配置关系到新内核能否正常运行<SPAN>,</SPAN>请备加注意<SPAN>.</SPAN>其他的配置如果不是很了解<SPAN>,</SPAN>大可以按默认的选择<SPAN>.<BR><BR><STRONG> </STRONG></SPAN><STRONG>三、</STRONG><STRONG> </STRONG><STRONG>编译过程</STRONG><STRONG><SPAN><BR></SPAN></STRONG><SPAN><BR></SPAN>按如下命令编译<SPAN>,</SPAN>大概需要一个多小时<SPAN>,</SPAN>大可以好好放松一下<SPAN>:-)<BR>make bzImage <BR>make modules <BR>make modules_install<BR>make install<BR><BR></SPAN>运行新内核之前<SPAN>,</SPAN>请检查一下<SPAN>/boot/grub/grub.conf</SPAN>的内容<SPAN>,</SPAN>下面的配置可作参考<SPAN><BR># grub.conf generated by anaconda<BR>#<BR># Note that you do not have to rerun grub after making changes to this file<BR># NOTICE: You have a /boot partition. This means that<BR># all kernel and initrd paths are relative to /boot/, eg.<BR># root (hd0,0)<BR># kernel /vmlinuz-version ro root=/dev/hdc3<BR># initrd /initrd-version.img<BR>#boot=/dev/hdc<BR>default=1<BR>timeout=10<BR>splashimage=(hd0,0)/grub/splash.xpm.gz<BR>title Red Hat Linux (2.6.7)<BR>root (hd0,0)<BR>kernel /vmlinuz-2.6.7 ro root=LABEL=/<BR>initrd /initrd-2.6.7.img<BR>title Red Hat Linux (2.4.20-8)<BR>root (hd0,0)<BR>kernel /vmlinuz-2.4.20-8 ro root=LABEL=/<BR>initrd /initrd-2.4.20-8.img<BR></SPAN><STRONG>四、</STRONG><STRONG> </STRONG><STRONG>运行内核的常见问题</STRONG><STRONG><SPAN><BR><BR></SPAN></STRONG><SPAN> 1)RPM</SPAN>问题<SPAN><BR><BR></SPAN>进入编译好的内核后,与<SPAN>RPM</SPAN>相关的命令有些不能使用,并出现下列错误:<SPAN><BR><BR>rpmdb: unable to join the environment<BR>error: db4 error(11) from dbenv->open: Resource temporarily unavailable<BR>error: cannot open Packages index using db3 - Resource temporarily unavailable (11)<BR>error: cannot open Packages database in /var/lib/rpm<BR>no packages<BR></SPAN>解决方法是执行<SPAN>“export LD_ASSUME_KERNEL =2.2.25”</SPAN>命令,也可以将其写入<SPAN>/etc/bashrc</SPAN>。<SPAN><BR><BR> 2)Sound</SPAN>问题<SPAN><BR></SPAN>声音部分的模块名也改变了。我的笔记本原来的声卡驱动是<SPAN>i810_audio</SPAN>,现在已改为<SPAN>snd-intel8x0</SPAN>。因此需要把下面的内容添加到<SPAN>/etc/modprobe.conf</SPAN>中:<SPAN><BR><BR>alias char-major-14 soundcore<BR>alias sound snd-intel8x0<BR>alias sound-slot-0 snd-intel8x0<BR>alias snd-card-0 snd-intel8x0<BR>alias sound-service-0-0 snd-mixer-oss<BR>alias sound-service-0-1 snd-seq-oss<BR>alias sound-service-0-3 snd-pcm-oss<BR>alias sound-service-0-8 snd-seq-oss<BR>alias sound-service-0-12 snd-pcm-oss<BR>install snd-intel8x0 /sbin/modprobe --ignore-install sound-slot-0 && <BR>{ /bin/aumix-minimal -f /etc/.aumixrc -L >/dev/null 2>&1; /bin/true; }<BR>remove snd-intel8x0 <BR>{ /bin/aumix-minimal -f /etc/.aumixrc -S >/dev/null 2>&1; /bin/true; };<BR>/sbin/modprobe -r --ignore-remove sound-slot-0<BR></SPAN>然后执行<SPAN>“modprobe sound”</SPAN>加载声音模块,并使用下列命令检验声卡驱动:<SPAN><BR>#cat /proc/asound/cards<BR><BR></SPAN>显示结果如下:<SPAN><BR><BR>0 [SI7012]: ICH - SiS SI7012<BR>SiS SI7012 at 0xdc00, irq 11<BR><BR> 3)VMware</SPAN>问题<SPAN><BR><BR></SPAN>解决方法是:<SPAN><BR><BR></SPAN>◆ 将<SPAN>/usr/bin/vmware-config.pl</SPAN>中所有的<SPAN>“/proc/ksyms”</SPAN>替换为<SPAN>“/proc/kallsyms”</SPAN>。使用<SPAN>“sed”</SPAN>命令可以达到这个目的。<SPAN><BR><BR></SPAN>◆ 重新运行该脚本,使用内核头文件编译新的内核模块。在编译过程中如发生错误,应该进入<SPAN>/usr/lib/vmware/modules/source</SPAN>,使用下面的命令将<SPAN>vmnet.tar</SPAN>解包:<SPAN><BR><BR>#tar xvf vmnet.tar<BR><BR></SPAN>◆ 进入<SPAN>vmnet-only</SPAN>目录修改<SPAN>bridge.c</SPAN>文件。将<SPAN>“atomic_add(skb->truesize, &sk->wmem_alloc);”</SPAN>修改为<SPAN>“atomic_add(skb->truesize, &sk->sk_wmem_alloc);”</SPAN>,并用类似的方式将<SPAN>“protinfo”</SPAN>改为<SPAN>“sk_protinfo”</SPAN>。<SPAN><BR><BR></SPAN>◆ 再次把<SPAN>vmnet-only</SPAN>目录用下面的命令重新打包为<SPAN>vmmon.tar</SPAN>:<SPAN><BR><BR>#tar cvf vmmon.tar vmnet-only</SPAN>。<SPAN><BR><BR></SPAN>如果按照上面的操作依旧失败,另一解决方法是到<A href="http://ftp.cvut.cz/vmware/页:
[1]