|
 |
栏目导栏 |
|
| |
|
|
|
|
 |
资料搜索 |
|
| |
|
|
|
|
 |
热门文章 |
|
| |
|
|
|
|
 |
最新文章 |
|
| |
|
|
|
| |
| |
|
|
|
| |
| Linux内核编译过程详解(kernel2.6.7) |
|
花了几天才编译成功kernel2.6.7,其过程真可谓艰辛.古语有云:"苦尽甘来!"现在终于可以乐上一阵了.由于许多朋友对操作的顺序及某些重要的配置知之甚少或知之不详,往往病急乱投医.加之网上的信息多且烦杂,使得编译内核成功率不高,甚至造成原来的系统崩溃的也不在少数.我就是其中一个。uxtLinux联盟 uxtLinux联盟 其实,编译内核并不是一件难事.如果能按照正确的方法来操作,最多花上一个半小时就能搞定.是不是很受鼓舞呀!uxtLinux联盟 uxtLinux联盟 废话少说,现在我们马上开始.我原来的系统是redhat9.0,内核2.4.20-8,编译的内核2.6.7,仅供参考.uxtLinux联盟 uxtLinux联盟 共分为四部分:编译前准备->编译配置->编译过程->运行内核的常见问题uxtLinux联盟 uxtLinux联盟 一 编译前准备uxtLinux联盟 uxtLinux联盟 1)下载一份内核源代码,我下的是linux-2.6.7.tar.bz2,你可在如下地址下载它或者是更新的版本.uxtLinux联盟 uxtLinux联盟 http://kernel.org/pub/linux/kernel/v2.6/uxtLinux联盟 uxtLinux联盟 2) 下载最新版本的module-init-tools( "module-init-tools-3.0.tar.gz" and "modutils-2.4.21-23.src.rpm")uxtLinux联盟 uxtLinux联盟 http://www.kernel.org/pub/linux/kernel/people/rusty/modules/module-init-tools-3.0.tar.gzuxtLinux联盟 uxtLinux联盟 http://www.kernel.org/pub/linux/kernel/people/rusty/modules/modutils-2.4.21-23.src.rpmuxtLinux联盟 uxtLinux联盟 3)安装module-init-tools. 它会替代depmod [/sbin/depmod]和其他工具.uxtLinux联盟 uxtLinux联盟 tar -zxvf module-init-tools-3.0.tar.gzuxtLinux联盟 uxtLinux联盟 cd module-init-tools-3.0uxtLinux联盟 uxtLinux联盟 ./configure --prefix=/sbinuxtLinux联盟 uxtLinux联盟 makeuxtLinux联盟 uxtLinux联盟 make installuxtLinux联盟 uxtLinux联盟 ./generate-modprobe.conf /etc/modprobe.confuxtLinux联盟 uxtLinux联盟 4)安装modutils-2.4.21-23.src.rpm. 你可能会看到"user rusty and group rusty not existing"的警告. 没关系,你只需强制安装就是了.如果你不对Redhat 9和Redhat 8做这几步, 你将会在"make modules_install"这一步时出现问题.uxtLinux联盟 uxtLinux联盟 rpm -i modutils-2.4.21-23.src.rpmuxtLinux联盟 uxtLinux联盟 rpmbuild -bb /usr/src/redhat/SPECS/modutils.specuxtLinux联盟 uxtLinux联盟 rpm -Fi /usr/src/redhat/RPMS/i386/modutils-2.4.21-23.i386.rpmuxtLinux联盟 uxtLinux联盟 5)解压缩内核源代码.把下载的源代码包放到目录/usr/src下,然后uxtLinux联盟 uxtLinux联盟 cd /usr/srcuxtLinux联盟 uxtLinux联盟 tar xvfj linux-2.6.7.tar.bz2uxtLinux联盟 uxtLinux联盟 cd linux-2.6.7uxtLinux联盟 uxtLinux联盟 二 编译配置uxtLinux联盟 uxtLinux联盟 在这一部分涉及几个重要模块的配置请,特别注意.一般用"make menuconfig"命令来配置内核.uxtLinux联盟 uxtLinux联盟 输入以上命令后出现一个菜单界面,用户可以对需要的模块.下面着重讲几个重要的配置uxtLinux联盟 uxtLinux联盟 1)文件系统uxtLinux联盟 uxtLinux联盟 请务必要选中ext3文件系统,uxtLinux联盟 uxtLinux联盟 File systems--->uxtLinux联盟 uxtLinux联盟 Ext3 journalling file system supportuxtLinux联盟 uxtLinux联盟 Ext3 Security LabelsuxtLinux联盟 uxtLinux联盟 JBD (ext3) debugging supportuxtLinux联盟 uxtLinux联盟 以上三项一定要选上,而且要内建(即标*). 这个非常重要,在配置完后一定要检查一下.config文件有没有"CONFIG_EXT3_FS=y"这一项. 如果不是"CONFIG_EXT3_FS=y"而是"CONFIG_EXT3_FS=m",你在运行内核时就会遇上以下错误: pivotroot: pivot_root(/sysroot,/sysroot/initrd) faileduxtLinux联盟 uxtLinux联盟 2)网卡驱动uxtLinux联盟 uxtLinux联盟 请务必把自己网卡对应的驱动编译进内核,比较普遍的网卡是realtek 8139,以下就是这种网卡的配置,以供参考uxtLinux联盟 uxtLinux联盟 Device Drivers--->uxtLinux联盟 uxtLinux联盟 Networking support--->uxtLinux联盟 uxtLinux联盟 Ethernet (10 or 100Mbit) --->uxtLinux联盟 uxtLinux联盟 <*> RealTek RTL-8139 C+ PCI Fast Ethernet Adapter support (EXPERIMENTAL)uxtLinux联盟 uxtLinux联盟 <*> RealTek RTL-8139 PCI Fast Ethernet Adapter supportuxtLinux联盟 uxtLinux联盟 3)声卡驱动uxtLinux联盟 uxtLinux联盟 也要选择自己声卡对应的驱动编译进内核,比较普遍的声卡是i810_audio,以下就是这种声卡的配置,以供参考uxtLinux联盟 uxtLinux联盟 Device Drivers --->uxtLinux联盟 uxtLinux联盟 Sound --->uxtLinux联盟 uxtLinux联盟 <*> Sound card supportuxtLinux联盟 uxtLinux联盟 Advanced Linux Sound Architecture --->uxtLinux联盟 uxtLinux联盟 <*> Advanced Linux Sound ArchitectureuxtLinux联盟 uxtLinux联盟 <*> Sequencer supportuxtLinux联盟 uxtLinux联盟 < > Sequencer dummy clientuxtLinux联盟 uxtLinux联盟 <*> OSS Mixer APIuxtLinux联盟 uxtLinux联盟 <*> OSS PCM (digital audio) API OSS Sequencer APIuxtLinux联盟 uxtLinux联盟 <*> RTC Timer supportuxtLinux联盟 uxtLinux联盟 PCI devices --->uxtLinux联盟 uxtLinux联盟 <*> Intel i8x0/MX440, SiS 7012; Ali 5455; NForce Audio; AMD768/8111uxtLinux联盟 uxtLinux联盟 Open Sound System --->uxtLinux联盟 uxtLinux联盟 < > Open Sound System (DEPRECATED)uxtLinux联盟 uxtLinux联盟 以上三项配置关系到新内核能否正常运行,请备加注意.其他的配置如果不是很了解,大可以按默认的选择.uxtLinux联盟 uxtLinux联盟 三 编译 uxtLinux联盟 uxtLinux联盟 按如下命令编译,大概需要一个多小时,大可以好好放松一下uxtLinux联盟 uxtLinux联盟 make bzImageuxtLinux联盟 uxtLinux联盟 make modulesuxtLinux联盟 uxtLinux联盟 make modules_installuxtLinux联盟 uxtLinux联盟 make installuxtLinux联盟 uxtLinux联盟 运行新内核之前,请检查一下/boot/grub/grub.conf的内容,下面的配置可作参考uxtLinux联盟 uxtLinux联盟 # grub.conf generated by anacondauxtLinux联盟 uxtLinux联盟 #uxtLinux联盟 uxtLinux联盟 # Note that you do not have to rerun grub after making changes to this fileuxtLinux联盟 uxtLinux联盟 # NOTICE: You have a /boot partition. This means thatuxtLinux联盟 uxtLinux联盟 # all kernel and initrd paths are relative to /boot/, eg.uxtLinux联盟 uxtLinux联盟 # root (hd0,0)uxtLinux联盟 uxtLinux联盟 # kernel /vmlinuz-version ro root=/dev/hdc3uxtLinux联盟 uxtLinux联盟 # initrd /initrd-version.imguxtLinux联盟 uxtLinux联盟 #boot=/dev/hdcuxtLinux联盟 uxtLinux联盟 default=1uxtLinux联盟 uxtLinux联盟 timeout=10uxtLinux联盟 uxtLinux联盟 splashimage=(hd0,0)/grub/splash.xpm.gzuxtLinux联盟 uxtLinux联盟 title Red Hat Linux (2.6.7)uxtLinux联盟 uxtLinux联盟 root (hd0,0)uxtLinux联盟 uxtLinux联盟 kernel /vmlinuz-2.6.7 ro root=LABEL=/uxtLinux联盟 uxtLinux联盟 initrd /initrd-2.6.7.imguxtLinux联盟 uxtLinux联盟 title Red Hat LinuxuxtLinux联盟 uxtLinux联盟 root (hd0,0)uxtLinux联盟 uxtLinux联盟 kernel /vmlinuz-2.4.20-8 ro root=LABEL=/uxtLinux联盟 uxtLinux联盟 initrd /initrd-2.4.20-8.imguxtLinux联盟 uxtLinux联盟 四 运行内核的常见问题uxtLinux联盟 uxtLinux联盟 1)RPM问题uxtLinux联盟 uxtLinux联盟 进入编译好的内核后,与RPM相关的命令有些不能使用,并出现下列错误:uxtLinux联盟 uxtLinux联盟 rpmdb: unable to join the environmentuxtLinux联盟 uxtLinux联盟 error: db4 error(11) from dbenv->open: Resource temporarily unavailableuxtLinux联盟 uxtLinux联盟 error: cannot open Packages index using db3 - Resource temporarily unavailable (11)uxtLinux联盟 uxtLinux联盟 error: cannot open Packages database in /var/lib/rpmuxtLinux联盟 uxtLinux联盟 no packagesuxtLinux联盟 uxtLinux联盟 解决方法是执行“export LD_ASSUME_KERNEL =2.2.25”命令,也可以将其写入/etc/bashrc。uxtLinux联盟 uxtLinux联盟 2)Sound问题uxtLinux联盟 uxtLinux联盟 声音部分的模块名也改变了。我的笔记本原来的声卡驱动是i810_audio,现在已改为snd-intel8x0。因此需要把下面的内容添加到/etc/modprobe.conf中:uxtLinux联盟 uxtLinux联盟 alias char-major-14 soundcoreuxtLinux联盟 uxtLinux联盟 alias sound snd-intel8x0uxtLinux联盟 uxtLinux联盟 alias sound-slot-0 snd-intel8x0uxtLinux联盟 uxtLinux联盟 alias snd-card-0 snd-intel8x0uxtLinux联盟 uxtLinux联盟 alias sound-service-0-0 snd-mixer-ossuxtLinux联盟 uxtLinux联盟 alias sound-service-0-1 snd-seq-ossuxtLinux联盟 uxtLinux联盟 alias sound-service-0-3 snd-pcm-ossuxtLinux联盟 uxtLinux联盟 alias sound-service-0-8 snd-seq-ossuxtLinux联盟 uxtLinux联盟 alias sound-service-0-12 snd-pcm-ossuxtLinux联盟 uxtLinux联盟 install snd-intel8x0 /sbin/modprobe --ignore-install sound-slot-0 &&uxtLinux联盟 uxtLinux联盟 { /bin/aumix-minimal -f /etc/.aumixrc -L >/dev/null 2>&1; /bin/true; }uxtLinux联盟 uxtLinux联盟 remove snd-intel8x0uxtLinux联盟 uxtLinux联盟 { /bin/aumix-minimal -f /etc/.aumixrc -S >/dev/null 2>&1; /bin/true; };uxtLinux联盟 uxtLinux联盟 /sbin/modprobe -r --ignore-remove sound-slot-0uxtLinux联盟 uxtLinux联盟 然后执行“modprobe sound”加载声音模块,并使用下列命令检验声卡驱动:uxtLinux联盟 uxtLinux联盟 #cat /proc/asound/cardsuxtLinux联盟 uxtLinux联盟 显示结果如下:uxtLinux联盟 uxtLinux联盟 0 [SI7012]: ICH - SiS SI7012uxtLinux联盟 uxtLinux联盟 SiS SI7012 at 0xdc00, irq 11uxtLinux联盟 uxtLinux联盟 3)VMware问题uxtLinux联盟 uxtLinux联盟 解决方法是:uxtLinux联盟 uxtLinux联盟 ◆ 将/usr/bin/vmware-config.pl中所有的“/proc/ksyms”替换为“/proc/kallsyms”。使用“sed”命令可以达到这个目的。uxtLinux联盟 uxtLinux联盟 ◆ 重新运行该脚本,使用内核头文件编译新的内核模块。在编译过程中如发生错误,应该进入/usr/lib/vmware/modules/source,使用下面的命令将vmnet.tar解包:uxtLinux联盟 uxtLinux联盟 #tar xvf vmnet.taruxtLinux联盟 uxtLinux联盟 ◆ 进入vmnet-only目录修改bridge.c文件。将“atomic_add(skb->truesize, &sk->wmem_alloc);”修改为“atomic_add(skb->truesize, &sk->sk_wmem_alloc);”,并用类似的方式将“protinfo”改为“sk_protinfo”。uxtLinux联盟 uxtLinux联盟 ◆ 再次把vmnet-only目录用下面的命令重新打包为vmmon.tar:uxtLinux联盟 uxtLinux联盟 #tar cvf vmmon.tar vuxtLinux联盟
Linux联盟收集整理 ,转贴请标明原始链接,如有任何疑问欢迎来本站Linux论坛讨论 |
|
|
|
|
|