dell安装linux 6u系统网卡名称变为em解决方法

作者:简简单单 2015-03-05

第一种方法如下


今天在看一台710服务器时,发现如下问题:

[root@BJ-BX-128-98 ~]# ifup eth1
WARNING: Deprecated config file /etc/modprobe.conf, all config files belong into /etc/modprobe.d/.
WARNING: Deprecated config file /etc/modprobe.conf, all config files belong into /etc/modprobe.d/.
Device eth1 does not seem to be present, delaying initialization.

发现eth1不存在,

查看udev配置,发现网卡名字为em2


[root@BJ-BX-128-98 ~]# vim /etc/udev/rules.d/70-persistent-net.rules
 
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
 
# PCI device 0x14e4:0x163b (bnx2)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="78:2b:cb:3b:ae:0e", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
 
# PCI device 0x14e4:0x163b (bnx2) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="78:2b:cb:3b:ae:0f", ATTR{type}=="1", KERNEL=="eth*", NAME="em2"

然后把网卡的配置文件的device改为em就可以正常停启了。


[root@BJ-BX-128-98 network-scripts]# vim ifcfg-eth1
DEVICE=eth1
BOOTPROTO=static
IPADDR=111.xx.xx.xx
NETMASK=255.255.255.0
GATEWAY=111.xx.xx.254
ONBOOT=yes
TYPE=Ethernet
改为如下

[root@BJ-BX-128-98 network-scripts]# vim ifcfg-eth1
DEVICE=em2
BOOTPROTO=static
IPADDR=111.xx.xx.xx
NETMASK=255.255.255.0
GATEWAY=111.xx.xx.254
ONBOOT=yes
TYPE=Ethernet
 
为什么在dell的R710服务器上安装RedHat6的系统,看到的网卡是em1和em2,和以往的eht0和eth1不一样,换成其他服务器没有问题?这个原因是由于biosdevname导致的。
在Redhat6中,默认biosdevname是关闭的,但是当服务器是dell的时候就变成开启的了。
biosdevname是由dell开发的工具,旨在为网络设备的命名理清思路(并且保持一致性!)。Biosdevname是一款udev帮助程序,可根据系统BIOS提供的信息对网络接口进行重命名。
具体解决成eth0和eth1,需要在grub.conf中添加上biosdevname=0,进行禁用新命名方案。当然ifcfg-eth0和ifcfg-eth1也需要改回eth0和eht1.
记得把这个文件清空或者删除  /etc/udev/rules.d/70-persistent-net.rules

dell官方是这么说的:

此文代表戴尔Enterprise Linux 设计团队的 Narayanan D 发表
 
Red Hat 现已推出的 Red Hat Enterprise Linux 6 Service Pack 1 (RHEL 6 SP1) 对网络接口实施了新的命名规则。戴尔同时开发,并遵从GPL协议义发布了‘biosdevname’ udev helper实用程序。它会根据网络接口在系统中的物理位置来建议新的设备名称。
 
将RHEL6 SP1 安装到支持的戴尔PowerEdge 服务器过程中,新的网络接口名称将变为:
 
            emN (em1, em2, ..)
 
以取代主板集成网口过去使用的 ethN 名称。
 
对于 PCI 扩展网络接口,名称将是:
 
          pXpY (pp - p1p1, p1p2, ..).
 
根据新的命名方案,em1 将映射 ‘Gb1’(em2 映射 ‘Gb2’),与服务器底座上的标签相同,从而使网络接口的有效管理更加轻松。名称 p1p2 可便于识别扩展网卡上的网络端口。
 
新的命名方案在支持的戴尔PowerEdge 平台上默认开启。在安装过程中传送‘biosdevname=0’ 内核命令行参数,即可禁用新命名方案,并在运行时中保留。
 
对 ethN 名称进行硬编码的现有脚本可能需要更改,使其能识别网络设备名称。


第二种方法介绍:

第一步:修改系统grub

vi /boot/grub/grub.conf

增加一个 biosdevname=0 的启动参数,我修改的结果如下:
[root@localhost ~]# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,0)
#          kernel /boot/vmlinuz-version ro root=/dev/sda1
#          initrd /boot/initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-220.el6.x86_64)
       root (hd0,0)
       kernel /boot/vmlinuz-2.6.32-220.el6.x86_64 ro root=UUID=360d089b-d466-4005-abcb-c5e517d31a96 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM biosdevname=0 #--->这里是新加的
       initrd /boot/initramfs-2.6.32-220.el6.x86_64.img

第二步:删除udev的配置文件rm -f /etc/udev/rules.d/70-persistent-net.rules

注:第二步可以不需要操作。

第三步:修改当前网卡配置文件的名称

mv ifcfg-em1》》》》》 ifcfg-eth0
mv ifcfg-em2》》》》》 ifcfg-eth1
mv ifcfg-em3》》》》》 ifcfg-eth2
mv ifcfg-em4》》》》》 ifcfg-eth3

第四步:修改网卡配置文件内容,把em1全部修改改为eth0

[root@xingfujie ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="dhcp"
HWADDR="24:B6:FD:F8:D5:84"
NM_CONTROLLED="yes"
ONBOOT="yes"
可以使用命令进行替换,如下:

perl -p -i -e 's/em1/eth0/g' ifcfg-eth0 或sed -i 's/em1/eth0/g' ifcfg-eth0
最后一步:重新启动系统 shutdown -r now 启动之后你就发现熟悉的eth0-eth4已经回来啦,顺便说下centos 6.2 还有一个问题就是如果你没有在网卡配置文件里写dns的话,重启之后你就会发现 /etc/resolv.conf 文件被清空了,一个方法就是在网卡配置文件中写DNS,另一个方法就是给/etc/resolv.conf加i属性,chattr +i /etc/resolv.conf

相关文章

精彩推荐