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

我的系统 OS version : Centos 5.9 kernel : 2.6.18-402 更新内核版本: 2.6.20

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

首先先下载 原系统的 开发包和头文件:
shell $> yum install kernel-devel kernel-headers
解压 2.6.20 内核压缩包,开始编译内核
shell $> mv linux-2.6.20.tar.bz2 /usr/src/
shell $> cd /usr/src/
shell $> tar jxvf linux-2.6.20.tar.bz2
shell $> cd linux-2.6.20
# 修改源码 更改自己需要的,我修改了 tun 相关的 源码文件。
shell $> make mrproper
# 选择需要的选项和修改的选项,删除多余的选项
shell $> make menuconfig
shell $> make -j 12
shell $> make modules_install
shell $> make install

# 修改 grub.conf 用新内核启动后发现网卡驱动并未发现!但是驱动加载了
2.6.20 shell $> lsmod |grep tg3
# 查看日志:
2.6.20 shell $> vim /var/log/message
# 查找tg3 相关日志:

Feb 26 11:02:01 localhost kernel: input: PC Speaker as /class/input/input1
Feb 26 11:02:01 localhost kernel: tg3: Unknown symbol pci_channel_offline
Feb 26 11:02:01 localhost kernel: intel_rng: Firmware space is locked read-only. If you can't or
Feb 26 11:02:01 localhost kernel: intel_rng: don't want to disable this in firmware setup, and if
Feb 26 11:02:01 localhost kernel: intel_rng: you are certain that your system has a functional
Feb 26 11:02:01 localhost kernel: intel_rng: RNG, try using the 'no_fwh_detect' option.

# 看到了 pci_channel_offline
# 下载对应网卡的驱动,编译安装看是否有错:
shell $> wget http://www.broadcom.com/support/license.php?file=570x/linux-3.136h.zip
shell $> reboot
2.6.20 shell $> unzip linux-3.137h.zip
2.6.20 shell $> tar zxvf tg3-3.136h.tar.gz
2.6.20 shell $> cd tg3-3.136h
2.6.20 shell $> make
# 并没有报错,但是有警告:

sh makeflags.sh /lib/modules/2.6.20/source  > tg3_flags.h
make -C /lib/modules/2.6.20/build SUBDIRS=/data1/software/tg3-3.136h modules
make[1]: Entering directory `/data1/software/linux-2.6.20'
  CC [M]  /data1/software/tg3-3.136h/tg3.o
/data1/software/tg3-3.136h/tg3.c: In function ‘tg3_ape_lock’:
/data1/software/tg3-3.136h/tg3.c:845: 警告:隐式声明函数 ‘pci_channel_offline’
  Building modules, stage 2.
  MODPOST 1 modules
WARNING: "pci_channel_offline" [/data1/software/tg3-3.136h/tg3.ko] undefined!
  CC      /data1/software/tg3-3.136h/tg3.mod.o
  LD [M]  /data1/software/tg3-3.136h/tg3.ko
make[1]: Leaving directory `/data1/software/linux-2.6.20'

# 按照常规,警告我们是可以忽略的,那么我们更新这个驱动应该就没问题了,我跟你想的一样可是他还是有问题的
2.6.20 shell $> make install
2.6.20 shell $> rmmod tg3
2.6.20 shell $> modprobe tg3
# 还是报错了,看日志还是 Unknown symbol pci_channel_offline
# 然后我就想 ,那我在老内核里编译看出错吗?结果在老内核里没有报错,我就在看老内核里 的 pci.h 文件,找到了 pci_channel_offline 方法:

static inline int pci_channel_offline(struct pci_dev *pdev)
{
        return (pdev->error_state != pci_channel_io_normal);
}

# 那么好,我把这段 复制到 2.6.20 内核里的 pci.h 里面
2.6.20 shell $> vim /usr/src/linux-2.6.20/include/linux/pci.h
# 加在 183行下面,在从新编译 网卡驱动
2.6.20 shell $> make clean
2.6.20 shell $> make
# 这次 make 没错了
2.6.20 shell $> make install
2.6.20 shell $> rmmod tg3
2.6.20 shell $> modprobe tg3
# 重启网卡
2.6.20 shell $> /etc/init.d/network restart

# 至此解决!

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

>//Linux 内核编译,解决网卡驱动缺少的问题,使用更新的内核来完善驱动
准备工作
整理出系统硬件、文件系统类型、网络协议
uname -r //查看系统版本号,如果系统与编译的内核一样,需要将/lib/modules 下内容备份
因为将来make modules-install步骤会覆盖整个路径下的内容
{下载linux内核,地址为:http://www.kernel.org/pub/linux/kernel/ ,假设名称为linux-x-y-z.tar.gz
如果内核已经安装,在/usr/src/目录有linux子目录,在光驱中找到kernel-source-2.xx.xx.rpm文件,,如RedHat linuxde RPm目录
是/redhat/RPMS/目录,使用rpm -ivh kernel-source-2.xx.xx.rpm安装内核}

cd /usr/src/linux //清除编译内核时残留的.o文件以及不必要的关联
make mrproper   //如果你是下载的内核代码,并且是第一次编译,就没有必要执行这一个步骤
make xconfig //图形界面下使用,配置内核
{make menyconfig //字符界面下使用}
make dep //设置关联文件
make clean //清理不必要的文件
make bzImage // 编译大内核(比如需要SCSI支持)
{make zImage//编译校内核}
make modules //编译模块,可加载模块,内核选项中为M的选项,编译时间跟M选项的数量有关
make modules_install  //把编译好的modules拷贝到/lib/modules下

A:mv /usr/src/linuxX.X.X/system.map /boot/system.map
B:mv /usr/src/linuxX.X.X/archi/i386/boot/bzImage /boot/vmlinuz //使用新内核
/etc/lilo.conf //修改/etc/lilo.conf 加一个启动选项,使用新内核bzimage or zimage启动

boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
linear
default=linux-new    ### 告诉lilo缺省使用新内核启动linux ###
append="mem=256M"

image=/boot/vmlinuz-2.2.14-5.0
        label=linux
        read-only
        root=/dev/hda5

image=/boot/bzImage(zImage)
        label=linux-new
        read-only
        root=/dev/hda5
//方法二:修改grup.conf文件
A:mv /usr/src/linuxX.X.X/system.map /boot/system.map
B:mv /usr/src/linuxX.X.X/archi/i386/boot/bzimage /boot/vmlinuz   //更换内核

//修改grub ,/etc/grup.conf
image=/boot/vmlinuz-2.2.14-5.0
        label=linux
        read-only
        root=/dev/hda5

image=/boot/bzImage(zImage)
        label=linux-new
        read-only
        root=/dev/hda5
 
//方法三:修改启动配置文件  /boot/grub/grub.conf
/*格式如下:
title 显示在启动菜单上的名称
root 根文件系统挂载分区
kernel 压缩过的内核文件名
initrd 根文件系统文件名
              如:
              title My new kernel
              root (hd0,2)
              kernel /boot/vmlinuz-x.y.z
              initrd /boot/initrd-x.y.z.img
*/

//mkinitrd initrd-内核版本号 内核版本号命令重新生成ram磁盘文件
mkinitrd initrd-2.2.14-5.0 2.2.14-5.0
initrd=/boot/initrd-2.2.14-5.0 //把/etc/lilo.conf中的initrd指向新生成的initrd-2.2.14-5.0文件

时间: 2024-08-02 16:32:29

linux 编译内核时网卡驱动丢失如何解决的相关文章

Linux编译内核时提示“ Too many open files”的解决方法

Linux编译内核时提示" Too many open files"的解决方法如下: 这是因为file-max默认值(8096)太小.要解决这个问题,可以root身份执行下列命令(或将它们加入/etc/rcS.d/*下的init脚本): # echo "65536" > /proc/sys/ 最后进入解压后的目录,运行安装命令. # cd vmware-linux-tools# ./install.pl

解决linux 编译内核网卡驱动问题

由于项目原因,需要从新编译内核,修改 TUN 源码支持共享模式,编译内核期间遇到了网卡驱动丢失问题,废话不多说,直接说解决问题的方式,本人对底层的东西了解很浅,所以解决问题的方式也很笨拙. OS version : Centos 5.9 kernel : 2.6.18-402 更新内核版本: 2.6.20 由于 yum 里面的内核头文件和卡发包并没有过多的源码 .c 文件.所以只能从 www.kernel.org 下载 相近的版本,有人肯定说了下你还不下个最新的 内核版本,答: 如内核版本跨度比

Linux编译内核,内核源码在哪里?

Linux编译内核,内核源码在哪里? 1.一般在发行版的盘里都有,比如 RedHat,一般在第二.第三张上 2.4 内核的叫 kernel-source-2.4.xx-xx.rpm2.6 内核的叫 kernel-devel-2.6.xx-xx.rpm 2.去www.kernel.org 下载一份你喜欢的内核版本,重新编译安装也可以.

Windowns 10新系统不能上网怎么办 网卡驱动不能用解决办法

1.我们在电脑中 右键计算机--属性--设备管理器--网络适配器  打开进入,如下图所示. 2.然后安装驱动人生网卡版 这个可以百度搜索下载了,在此111cn小编不提供下载地址 修复完成,驱动人生会显示修复结果,此时,网卡驱动问题便解决好了. 其实我们还有一种办法就是更新网卡驱动了,这种方法少知道能不能行得通了,不过小编觉得能解决问题就好.

debian编译内核时err: line 65 dpkg-gencontrol command not found

在编译debian内核时出现如下错误: INSTALL include/asm (64 files) /home/fuckids/linux-3.13.7/scripts/package/builddeb:行65: dpkg-gencontrol: 未找到命令 make[1]: *** [deb-pkg] 错误 127 make: *** [deb-pkg] 错误 2 解决方法: apt-get install  dpkg-dev 安装好后,在命令行能够找到此命令: root@debian-id

Linux编译内核出现“kernel Panic:VFS:Unable to mount root fs on 0:00”错误

安装了一台 Linux 服务器,想自己编译内核,一步一步做下来, GRUB 也添加进去了,但出现" kernel Panic:VFS:Unable to mount root fs on 0:00 " 的错误,请问是怎么回事? 一般情况下initrd这个文件在台式机上不是必须的,但是在有SCSI设备的服务器上却是必须的.有可能因为编译内核的时候没有产生initrd那个文件,所以会有上面的错误提示. 用户可以使用mkinitrd命令来生成一个initrd.img文件,然后加入GRUB,重

Ubuntu 11.10编译内核时的make xconfig错误

问题: root@czu:~/桌面/linux-2.6.30.4# make xconfig CHECK   qt * * Unable to find the QT3 installation. Please make sure that * the QT3 development package is correctly installed and * either install pkg-config or set the QTDIR environment * variable to t

Linux umount设备时出现device is busy解决方法

在Linux中,有时使用umount命令去卸载LV或文件时,可能出现umount: xxx: device is busy的情况,如下案例所示 [root@DB-Server u06]# vgdisplay -v VolGroup03     Using volume group(s) on command line     Finding volume group "VolGroup03"   --- Volume group ---   VG Name              

整理linux编译link出undefined reference’dlclose’错误解决办法

对于linux我持中立态度,而且我认为linux这么多年发展比较慢的原因是因为桌面化做的不好或者不够好,所以我比较偏爱ubuntu. 由于以前项目是makefile的,我个人不是很喜欢makefile,因为他看起来比较费劲,而且编译完成后出现问题调试是个大难题,不是每个人都精通gdb,而且vi上手比较难.所以将工程转为codeblocks的cbp,本来想使用cmake的,但是觉得要写的比较多,于是作罢,毕竟代码不是跨平台的,windows下没法用. 编译完link的时候,报了一句undefine