北京SEO

linux 编译内核时网卡驱动丢失如何解决

2019/10/10/17:45:18  阅读:2134  来源:谷歌SEO算法  标签: Dropbox

Linux在编译内核期间遇到了网卡驱动丢失问题,看看下面我是如何把网卡找回的,有出现类似问题的朋友可以参考一下,我的系统 OS version:Centos 5.9 kernel:2.6.18-402 更新内核版本:2.6.20.

由于 yum 里面的内核头文件和卡发包并没有过多的源码 .c 文件,所以只能从 www.kernel.org 下载相近的版本,有人肯定说了下你还不下个最新的内核版本,答:如内核版本跨度比较大,本人担心会出现各种问题,很多老的编译选项新版内核不支持.

首先先下载 原系统的 开发包和头文件:

  1. shell$>yuminstallkernel-develkernel-headers
  2. 解压2.6.20内核压缩包,开始编译内核
  3. shell$>mvlinux-2.6.20.tar.bz2/usr/src/
  4. shell$>cd/usr/src/
  5. shell$>tarjxvflinux-2.6.20.tar.bz2
  6. shell$>cdlinux-2.6.20
  7. #修改源码更改自己需要的,我修改了tun相关的源码文件。
  8. shell$>makemrproper
  9. #选择需要的选项和修改的选项,删除多余的选项
  10. shell$>makemenuconfig
  11. shell$>make-j12
  12. shell$>makemodules_install
  13. shell$>makeinstall
  14. #修改grub.conf用新内核启动后发现网卡驱动并未发现!但是驱动加载了
  15. 2.6.20shell$>lsmod|greptg3
  16. #查看日志:
  17. 2.6.20shell$>vim/var/log/message
  18. #查找tg3相关日志:
  19. Feb2611:02:01localhostkernel:input:PCSpeakeras/class/input/input1
  20. Feb2611:02:01localhostkernel:tg3:Unknownsymbolpci_channel_offline
  21. Feb2611:02:01localhostkernel:intel_rng:Firmwarespaceislockedread-only.Ifyoucan'tor
  22. Feb2611:02:01localhostkernel:intel_rng:don'twanttodisablethisinfirmwaresetup,andif
  23. Feb2611:02:01localhostkernel:intel_rng:youarecertainthatyoursystemhasafunctional
  24. Feb2611:02:01localhostkernel:intel_rng:RNG,tryusingthe'no_fwh_detect'option.
  25. #看到了pci_channel_offline
  26. #下载对应网卡的驱动,编译安装看是否有错:
  27. shell$>wgethttp://www.broadcom.com/support/license.php?file=570x/linux-3.136h.zip
  28. shell$>reboot
  29. 2.6.20shell$>unziplinux-3.137h.zip
  30. 2.6.20shell$>tarzxvftg3-3.136h.tar.gz
  31. 2.6.20shell$>cdtg3-3.136h
  32. 2.6.20shell$>make
  33. #并没有报错,但是有警告:
  34. shmakeflags.sh/lib/modules/2.6.20/source>tg3_flags.h
  35. make-C/lib/modules/2.6.20/buildSUBDIRS=/data1/software/tg3-3.136hmodules
  36. make[1]:Enteringdirectory`/data1/software/linux-2.6.20'
  37. CC[M]/data1/software/tg3-3.136h/tg3.o
  38. /data1/software/tg3-3.136h/tg3.c:Infunction‘tg3_ape_lock’:
  39. /data1/software/tg3-3.136h/tg3.c:845:警告:隐式声明函数‘pci_channel_offline’
  40. Buildingmodules,stage2.
  41. MODPOST1modules
  42. WARNING:"pci_channel_offline"[/data1/software/tg3-3.136h/tg3.ko]undefined!
  43. CC/data1/software/tg3-3.136h/tg3.mod.o
  44. LD[M]/data1/software/tg3-3.136h/tg3.ko
  45. make[1]:Leavingdirectory`/data1/software/linux-2.6.20'
  46. #按照常规,警告我们是可以忽略的,那么我们更新这个驱动应该就没问题了,我跟你想的一样可是他还是有问题的
  47. 2.6.20shell$>makeinstall
  48. 2.6.20shell$>rmmodtg3
  49. 2.6.20shell$>modprobetg3
  50. #还是报错了,看日志还是Unknownsymbolpci_channel_offline
  51. #然后我就想,那我在老内核里编译看出错吗?结果在老内核里没有报错,我就在看老内核里的pci.h文件,找到了pci_channel_offline方法:
  52. staticinlineintpci_channel_offline(structpci_dev*pdev)
  53. {
  54. return(pdev->error_state!=pci_channel_io_normal);
  55. }
  56. #那么好,我把这段复制到2.6.20内核里的pci.h里面
  57. 2.6.20shell$>vim/usr/src/linux-2.6.20/include/linux/pci.h
  58. #加在183行下面,在从新编译网卡驱动
  59. 2.6.20shell$>makeclean
  60. 2.6.20shell$>make
  61. #这次make没错了
  62. 2.6.20shell$>makeinstall
  63. 2.6.20shell$>rmmodtg3
  64. 2.6.20shell$>modprobetg3
  65. #重启网卡
  66. 2.6.20shell$>/etc/init.d/networkrestart
  67. //phpfensi.com
  68. #至此解决!

Linux 内核编译,解决网卡驱动缺少的问题.

>//Linux 内核编译,解决网卡驱动缺少的问题,使用更新的内核来完善驱动.

准备工作:整理出系统硬件、文件系统类型、网络协议.

  1. uname-r//查看系统版本号,如果系统与编译的内核一样,需要将/lib/modules下内容备份,因为将来makemodules-install步骤会覆盖整个路径下的内容.
  2. {下载linux内核,地址为:http://www.kernel.org/pub/linux/kernel/,假设名称为linux-x-y-z.tar.gz.
  3. 如果内核已经安装,在/usr/src/目录有linux子目录,在光驱中找到kernel-source-2.xx.xx.rpm文件,如RedHatlinuxdeRPm目录,是/redhat/RPMS/目录,使用rpm-ivhkernel-source-2.xx.xx.rpm安装内核}
  4. cd/usr/src/linux//清除编译内核时残留的.o文件以及不必要的关联
  5. makemrproper//如果你是下载的内核代码,并且是第一次编译,就没有必要执行这一个步骤
  6. makexconfig//图形界面下使用,配置内核
  7. {makemenyconfig//字符界面下使用}
  8. makedep//设置关联文件
  9. makeclean//清理不必要的文件
  10. makebzImage//编译大内核(比如需要SCSI支持)
  11. {makezImage//编译校内核}
  12. makemodules//编译模块,可加载模块,内核选项中为M的选项,编译时间跟M选项的数量有关
  13. makemodules_install//把编译好的modules拷贝到/lib/modules下
  14. A:mv/usr/src/linuxX.X.X/system.map/boot/system.map
  15. B:mv/usr/src/linuxX.X.X/archi/i386/boot/bzImage/boot/vmlinuz//使用新内核
  16. /etc/lilo.conf//修改/etc/lilo.conf加一个启动选项,使用新内核bzimageorzimage启动
  17. boot=/dev/hda
  18. map=/boot/map
  19. install=/boot/boot.b
  20. prompt
  21. timeout=50
  22. linear
  23. default=linux-new###告诉lilo缺省使用新内核启动linux###
  24. append="mem=256M"
  25. image=/boot/vmlinuz-2.2.14-5.0
  26. label=linux
  27. read-only
  28. root=/dev/hda5
  29. image=/boot/bzImage(zImage)
  30. label=linux-new
  31. read-only
  32. root=/dev/hda5
  33. //方法二:修改grup.conf文件
  34. A:mv/usr/src/linuxX.X.X/system.map/boot/system.map
  35. B:mv/usr/src/linuxX.X.X/archi/i386/boot/bzimage/boot/vmlinuz//更换内核
  36. //修改grub,/etc/grup.conf
  37. image=/boot/vmlinuz-2.2.14-5.0
  38. label=linux
  39. read-only
  40. root=/dev/hda5
  41. image=/boot/bzImage(zImage)
  42. label=linux-new
  43. read-only
  44. root=/dev/hda5
  45. //方法三:修改启动配置文件/boot/grub/grub.conf
  46. /*格式如下:
  47. title显示在启动菜单上的名称
  48. root根文件系统挂载分区
  49. kernel压缩过的内核文件名
  50. initrd根文件系统文件名
  51. 如:
  52. titleMynewkernel
  53. root(hd0,2)
  54. kernel/boot/vmlinuz-x.y.z
  55. initrd/boot/initrd-x.y.z.img
  56. */
  57. //mkinitrdinitrd-内核版本号内核版本号命令重新生成ram磁盘文件
  58. mkinitrdinitrd-2.2.14-5.02.2.14-5.0
  59. initrd=/boot/initrd-2.2.14-5.0//把/etc/lilo.conf中的initrd指向新生成的initrd-2.2.14-5.0文件

广告内容

linux 编译内核时网卡驱动丢失如何解决 linux 编译内核时网卡驱动丢失如何解决 linux 编译内核时网卡驱动丢失如何解决

相关阅读

热门评论

小浪SEO博客 小浪SEO博客

专注SEO优化思维、SEO技术的实战分享类博客~

总篇数183

精选文章

RMAN中catalog和nocatalog区别介绍 小技巧:为Linux下的文件分配多个权限 zimbra8.5.1安装第三方签名ssl证书的步骤 解决mysql不能远程连接数据库方法 windows服务器mysql增量备份批处理数据库 mysql中slow query log慢日志查询分析 JavaScript跨域问题总结 Linux下负载均衡软件LVS配置(VS/DR)教程 mysql中权限参数说明 MYSQL(错误1053)无法正常启动

SEO最新算法