dell安裝linux 6u系統網卡名稱變為em解決方案

來源:互聯網
上載者:User

第一種方法如下


今天在看一台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 (p<slot number>p<port number> - 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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.