02、显示所有网卡 
由于一个系统可以支持多张网卡,可通过如下命显示当前系统的所有网卡及其基本信息:
#ifconfig -a


em1 Link encap:Ethernet HWaddr EC:F4:BB:D0:0B:60 
UP BROADCAST MULTICAST MTU:1500 Metric:1 
RX packets:0 errors:0 dropped:0 overruns:0 frame:0 
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
collisions:0 txqueuelen:1000 
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) 

em2 Link encap:Ethernet HWaddr EC:F4:BB:D0:0B:62 
UP BROADCAST MULTICAST MTU:1500 Metric:1 
RX packets:0 errors:0 dropped:0 overruns:0 frame:0 
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
collisions:0 txqueuelen:1000 
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) 

em3 Link encap:Ethernet HWaddr EC:F4:BB:D0:0B:64 
UP BROADCAST MULTICAST MTU:1500 Metric:1 
RX packets:0 errors:0 dropped:0 overruns:0 frame:0 
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
collisions:0 txqueuelen:1000 
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) 
Memory:dbe80000-dbf00000


03、查看网卡所需驱动

使用ethtool命令可以查看指定网卡所依赖的网卡驱动信息:

#ethtool -i em3


driver: igb - 网卡em3依赖igb驱动
version: 3.0.6-k 
firmware-version: 1.6-7 
bus-info: 0000:08:00.0 
注:igb 驱动程序支持所有基于 82575 、 82576 、 82580 和 I350 的千兆位网络连接。



04、查看网卡型号 

通过③我们已经知道了网卡所依赖的驱动,但是还不知具体的网卡设备型号,此时可通过如下命令查询:

# lspci -nn | grep "Eth" 


01:00.0 Ethernet controller [0200]: Intel Corporation 82599EB 10-Gigabit SFI/SFP+ Network Connection [8086:10fb] (rev 01)
01:00.1 Ethernet controller [0200]: Intel Corporation 82599EB 10-Gigabit SFI/SFP+ Network Connection [8086:10fb] (rev 01)
03:00.0 Ethernet controller [0200]: Intel Corporation 82599EB 10-Gigabit SFP+ Network Connection [8086:154d] (rev 01)
03:00.1 Ethernet controller [0200]: Intel Corporation 82599EB 10-Gigabit SFP+ Network Connection [8086:154d] (rev 01)
08:00.0 Ethernet controller [0200]: Intel Corporation I350 Gigabit Network Connection [8086:1521] (rev 01)
08:00.1 Ethernet controller [0200]: Intel Corporation I350 Gigabit Network Connection [8086:1521] (rev 01)
注:Gigabit为千兆 10-Gigabit为万兆


由④的操作可知当前内核(2.6.32-220.el6.x86_64)千兆网络驱动igb支持网卡型号[8086:1521],因此必须要求目标内核(2.6.33-110.el6.x86_64)对该型号网卡[8086:1521]的支持。

05、查看目标内核的网卡驱动是否支持当前型号网卡

可以通过modinfo命令查看*.ko对哪种设备型号的支持,目标内核(2.6.33-110.el6.x86_64)的相关驱动可在/lib/modules/2.6.33-110.el6.x86_64的目录中找到,如下所示:

#modinfo /lib/modules/2.6.33-110.el6.x86_64/kernel/drivers/net/igb/igb.ko


filename: igb.ko 
version: 2.1.0-k2 
license: GPL 
description: Intel(R) Gigabit Ethernet Network Driver 
author: Intel Corporation,  
srcversion: 412D1CB4C85682CBF07976F 
alias: pci:v00008086d000010D6sv*sd*bc*sc*i* 
alias: pci:v00008086d000010A9sv*sd*bc*sc*i* 
alias: pci:v00008086d000010A7sv*sd*bc*sc*i* 
alias: pci:v00008086d000010E8sv*sd*bc*sc*i* 
alias: pci:v00008086d0000150Dsv*sd*bc*sc*i* 
alias: pci:v00008086d000010E7sv*sd*bc*sc*i* 
alias: pci:v00008086d000010E6sv*sd*bc*sc*i* 
alias: pci:v00008086d00001518sv*sd*bc*sc*i* 
alias: pci:v00008086d0000150Asv*sd*bc*sc*i* 
alias: pci:v00008086d000010C9sv*sd*bc*sc*i* 
alias: pci:v00008086d00001516sv*sd*bc*sc*i* 
alias: pci:v00008086d00001511sv*sd*bc*sc*i* 
alias: pci:v00008086d00001510sv*sd*bc*sc*i* 
alias: pci:v00008086d0000150Fsv*sd*bc*sc*i* 
alias: pci:v00008086d0000150Esv*sd*bc*sc*i* 
depends: 
vermagic: 2.6.33-110.el6.x86_64 SMP mod_unload modversions


从以上信息中找不到[8086:1521]的信息,因此,目标内核(2.6.33-110.el6.x86_64)网卡驱动不支持当前网卡!

06、到官网下载网卡驱动
既然已经明确了目标内核的网卡驱动并不支持当前的网卡设备,也就是说一旦启用新的内核,将导致系统无法正常使用网络功能。如果是英特尔的网卡设备,则可到:http://www.intel.cn/content/www/cn/zh/homepage.html 下载所需的驱动源码到本地。

07、编译网卡驱动 
解压驱动源码后,按照以下命令格式编译驱动源码:
#make BUILD_KERNEL=2.6.33-110.el6.x86_64 
以上命令将会生成网卡驱动igb.ko。其中BUILD_KERNEL指明需要为哪个内核编译驱动,默认是给当前正在运行的内核编译,在此我们设定为目标内核(2.6.33-110.el6.x86_64)。那么又该如何查看新生成的网卡驱动igb.ko是否支持当前的网卡设备呢?

08、检查网卡驱动是否支持当前网卡 
步骤⑦将会生成网卡驱动igb.ko,这时可通过modinfo命令验证该驱动是否支持网卡设备[8086:1521],如下所示:
#modinfo igb.ko 
filename: igb.ko 
version: 5.2.9.4 
license: GPL 
description: Intel(R) Gigabit Ethernet Network Driver 
author: Intel Corporation,  
srcversion: E377200391EBF74638FEDA2 
alias: pci:v00008086d000010D6sv*sd*bc*sc*i* 
alias: pci:v00008086d000010A9sv*sd*bc*sc*i* 
alias: pci:v00008086d000010A7sv*sd*bc*sc*i* 
alias: pci:v00008086d000010E8sv*sd*bc*sc*i* 
alias: pci:v00008086d00001526sv*sd*bc*sc*i* 
alias: pci:v00008086d0000150Dsv*sd*bc*sc*i* 
alias: pci:v00008086d000010E7sv*sd*bc*sc*i* 
alias: pci:v00008086d000010E6sv*sd*bc*sc*i* 
alias: pci:v00008086d00001518sv*sd*bc*sc*i* 
alias: pci:v00008086d0000150Asv*sd*bc*sc*i* 
alias: pci:v00008086d000010C9sv*sd*bc*sc*i* 
alias: pci:v00008086d00000440sv*sd*bc*sc*i* 
alias: pci:v00008086d0000043Csv*sd*bc*sc*i* 
alias: pci:v00008086d0000043Asv*sd*bc*sc*i* 
alias: pci:v00008086d00000438sv*sd*bc*sc*i* 
alias: pci:v00008086d00001516sv*sd*bc*sc*i* 
alias: pci:v00008086d00001511sv*sd*bc*sc*i* 
alias: pci:v00008086d00001510sv*sd*bc*sc*i* 
alias: pci:v00008086d00001527sv*sd*bc*sc*i* 
alias: pci:v00008086d0000150Fsv*sd*bc*sc*i* 
alias: pci:v00008086d0000150Esv*sd*bc*sc*i* 
alias: pci:v00008086d00001524sv*sd*bc*sc*i* 
alias: pci:v00008086d00001523sv*sd*bc*sc*i* 
alias: pci:v00008086d00001522sv*sd*bc*sc*i* 
alias: pci:v00008086d00001521sv*sd*bc*sc*i*
alias: pci:v00008086d00001539sv*sd*bc*sc*i* 
alias: pci:v00008086d0000157Csv*sd*bc*sc*i* 
alias: pci:v00008086d0000157Bsv*sd*bc*sc*i* 
alias: pci:v00008086d00001538sv*sd*bc*sc*i* 
alias: pci:v00008086d00001537sv*sd*bc*sc*i* 
alias: pci:v00008086d00001536sv*sd*bc*sc*i* 
alias: pci:v00008086d00001533sv*sd*bc*sc*i* 
alias: pci:v00008086d00001F45sv*sd*bc*sc*i* 
alias: pci:v00008086d00001F41sv*sd*bc*sc*i* 
alias: pci:v00008086d00001F40sv*sd*bc*sc*i* 
depends: hwmon 
vermagic: 2.6.33-110.el6.x86_64 SMP mod_unload modversions 
parm: InterruptThrottleRate:Maximum interrupts per second, per vector, (max 100000), default 3=adaptive (array of int)
parm: IntMode:Change Interrupt Mode (0=Legacy, 1=MSI, 2=MSI-X), default 2 (array of int)
parm: Node:set the starting node to allocate memory on, default -1 (array of int)
parm: LLIPort:Low Latency Interrupt TCP Port (0-65535), default 0=off (array of int)
parm: LLIPush:Low Latency Interrupt on TCP Push flag (0,1), default 0=off (array of int)
parm: LLISize:Low Latency Interrupt on Packet Size (0-1500), default 0=off (array of int)
parm: RSS:Number of Receive-Side Scaling Descriptor Queues (0-8), default 1, 0=number of cpus (array of int)
parm: VMDQ:Number of Virtual Machine Device Queues: 0-1 = disable, 2-8 enable, default 0 (array of int)
parm: max_vfs:Number of Virtual Functions: 0 = disable, 1-7 enable, default 0 (array of int)
parm: MDD:Malicious Driver Detection (0/1), default 1 = enabled. Only available when max_vfs is greater than 0 (array of int)
parm: QueuePairs:Enable Tx/Rx queue pairs for interrupt handling (0,1), default 1=on (array of int)
parm: EEE:Enable/disable on parts that support the feature (array of int)
parm: DMAC:Disable or set latency for DMA Coalescing ((0=off, 1000-10000(msec), 250, 500 (usec)) (array of int)
parm: LRO:Large Receive Offload (0,1), default 0=off (array of int) 
parm: debug:Debug level (0=none, ..., 16=all) (int)

终于在显示的信息中找到了[8086:1521]信息,说明新生成的驱动文件能够支持当前网卡型号。那么如何让目标内核(2.6.33-110.el6.x86_64)能够载入新驱动呢?

09、更新目标内核驱动 
首先,将新驱动igb.ko拷贝到目标内核/lib/modules/2.6.33-110.el6.x86_64下的指定目录
#cp igb.ko /lib/modules/2.6.33-110.el6.x86_64/kernel/drivers/net/igb/
其次,使用depmod更新目标内核(2.6.33-110.el6.x86_64)模块的依赖关系
#depmod -a 2.6.33-110.el6.x86_64

10、以上工作完成后,可以重启系统了!
10-17 19:16