第一步
:修改系统grub
vi /boot/grub/grub.conf
增加一个 biosdevname=0 的启动参数,我修改的结果如下:
[[email protected] ~]# 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
[[email protected] ~]# 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