公司新買了幾臺Dell服務器,安裝Centos6.6後發現服務器的網卡名稱爲em1,這個緣由是biosdevname引發的,默認狀況下Centos6.6下biosdevname是關閉的,可是若是是Dell的服務器則會自動啓用該內核參數。 biosdevname是由dell開發的工具,旨在爲網絡設備的命名理清思路(而且保持一致性!)。biosdevname是一款udev幫助程序,可根據系統BIOS提供的信息對網絡接口進行重命名。 ios
新的命名規則以下:vim
em[1-N] 表示主板NIC(內置網卡)服務器
pci<slot>#<port> 表示 PCI 插槽中的卡,端口 1 至 N (PCI類的網卡) 網絡
NPAR & SR-IOV 設備增長後綴 _<vf>,從 0 至 N,取決於各端口可用的分區或虛擬功能的數量。 app
其餘 Linux 命名規則,如 .<vlan> 和 :<alias> 後綴,保持不變且仍然適用。 ide
Red Hat 現已推出的 Red Hat Enterprise Linux 6 Service 對網絡接口實施了新的命名規則。戴爾同時開發,並聽從GPL協議義發佈了‘biosdevname’ udev helper實用程序。它會根據網絡接口在系統中的物理位置來建議新的設備名稱。工具
將RHEL6 安裝到支持的戴爾PowerEdge 服務器過程當中,新的網絡接口名稱將變爲:
emN (em1, em2, ..) ui
以取代主板集成網口過去使用的 ethN 名稱。this
對於 PCI 擴展網絡接口,名稱將是:spa
pXpY (p<slot number>p<port number> - p1p1, p1p2, ..).
根據新的命名方案,em1 將映射 ‘Gb1’(em2 映射 ‘Gb2’),與服務器底座上的標籤相同,從而使網絡接口的有效管理更加輕鬆。名稱 p1p2 可便於識別擴展網卡上的網絡端口。
新的命名方案在支持的戴爾PowerEdge 平臺上默認開啓。在安裝過程當中傳送‘biosdevname=0’ 內核命令行參數,便可禁用新命名方案,並在運行時中保留。
那麼如何將網卡修改成咱們熟悉的ethx方式呢,有2種方法
第一種:
(1)修改udev策略
[root@localhost ~]# cd /etc/udev/rules.d/
[root@localhost rules.d]# vim 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:0x165f (tg3) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="b0:83:fe:e6:d8:a4", ATTR{type}=="1", KERNEL=="eth*", NAME="em1"
# PCI device 0x14e4:0x165f (tg3) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="b0:83:fe:e6:d8:a5", ATTR{type}=="1", KERNEL=="eth*", NAME="em2"
改成
# 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:0x165f (tg3) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="b0:83:fe:e6:d8:a4", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x14e4:0x165f (tg3) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="b0:83:fe:e6:d8:a5", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
(2)修改網卡文件名稱
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# mv ifcfg-em1 ifcfg-eth0
[root@localhost network-scripts]# vim ifcfg-eth0
DEVICE=em1
改成
DEVICE=eth0
(3)從新啓動系統
第二種方法:
(1)修改grub.conf
[root@localhost ~]# vim /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,1)
# kernel /vmlinuz-version ro root=/dev/mapper/VolGroup-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/sda1
device (hd0) HD(1,800,64000,dd2e2742-0973-4678-9989-276e29b7e967)
default=0
timeout=5
splashp_w_picpath=(hd0,1)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-504.3.3.el6.x86_64)
root (hd0,1)
kernel /vmlinuz-2.6.32-504.3.3.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet biosdevname=0
initrd /initramfs-2.6.32-504.3.3.el6.x86_64.img
(2)刪除udev策略
[root@localhost ~]# cd /etc/udev/rules.d/
[root@localhost rules.d]# rm -rf 70-persistent-net.rules
(3)修改網卡設備文件的名稱
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# mv ifcfg-em1 ifcfg-eth0
[root@localhost network-scripts]# mv ifcfg-em2 ifcfg-eth1
(4)修改網卡設備文件名
[root@localhost network-scripts]# vim ifcfg-eth0
將
DEVICE=em1
改成
DEVICE=eth0
[root@localhost network-scripts]# vim ifcfg-eth1
將
DEVICE=em2
改成
DEVICE=eth1
(5)從新啓動服務器
[root@localhost ~]# reboot