I'm using CentOS 6 in a virtual environment. When cloning a virtual version of CentOS, the old eth adapters are "removed" and replaced with new ones and net MAC addresses. However, the ifcfg-ethn files still exist. I am trying to figure out how to get CentOS to automatically rescan & recreate the network adapters / eth files, just like it did on install.

Otherwise I am left with the tedious process as described here: http://www.centos.org/docs/5/html/Installation_Guide-en-US/s1-s390info-addnetdevice.html

I know there is a quick way to do this in the GUI, but we are using a server so GUI does not apply in this case. Help?

Edit: @OldWolf suggested Kudzu, however Kudzu has been removed as of Centos 5 so I would rather avoid that. There is a procedure that Linux runs on initial install - can someone help me figure out what that is so I can manually trigger it?

link|improve this question

feedback

2 Answers

up vote 9 down vote accepted

With CentOS 6 everthing is handled by udev now. Go into /etc/udev/rules.d and delete the 70-persistent-net.rules file and reboot. If you open it berfore hand you will most likey see the original NIC MAC listed as eth0 and the new one as eth1.

Deleting the file forces the detection process to run again at boot with no baggage left over from the cloning process, namely the old NIC MAC address(es).

I have to do it with my CemtOS 6 clones on VMware ESXi 4.1 all the time. It's a pain kudzu would just handle it in the past with previous versions.

You will also need to remove the MAC addresses from the NICs too, in /etc/sysconfig/network-scripts/ifcfg-eth0 etc.

link|improve this answer
Sounded wonderful tracy, however it did not work as you described. The old ifcfg-eth0 file was still there, with the original MAC address etc instead of the correct new one. – Joshua Sep 8 '11 at 20:58
Sorry yes I had forgetten. You must also MANUALLY update the mac address in ifcfg-eth0 as well sorry. That will make it work. There might be an easier way but I have yet to find it... – Tracy Carlton Sep 8 '11 at 23:27
This was a good start. It seems like it could be possible to write a script that will automate the process - even the manual bits described - on bootup. The problem is activating the script only after the machine has been cloned / moved. Still no complete answer to this... – Joshua Feb 20 at 21:32
feedback

If your only problem is the mac address, you can run something similar to

TEST=`ifconfig | grep eth | awk '{ print $5}'`; sed "s/HWADDR.*/HWADDR\=$TEST/g" ifcfg-eth0 > TMP; mv TMP ifcfg-eth0

To update the HWADDR entry.

Edit: Since it looks like the problem is an actual change in virtual hardware you can try the following. (untested and referenced from here )

edit /etc/sysconfig/hwconf and remove all reference to the previous NIC and rerun kudzu to see if it detects the new hardware. You may need to reboot.

link|improve this answer
I tried manually changing the MAC address on eth0 for example, but it still did not work. Subsequent attempts at "service network force-reload", "ifup eth0" etc. would always end in "Device eth0 does not seem to be present..." Help? – Joshua Sep 6 '11 at 21:07
What type of virtualization are you using and how did you clone the system? – OldWolf Sep 6 '11 at 21:20
VirtualBox, but I don't think the virtualization matters. This should be like shutting a physical box down, removing the existing network adapters, and adding different ones. – Joshua Sep 6 '11 at 21:24
@Josh Where are the ifcfg-* files you are editing as there are possibly three sets - check out /etc/sysconfig/network-scripts and /etc/sysconfig/networking/devices and /etc/sysconfig/networking/profiles/default (yeah, I know - it seems to be something to do with which tool/s you use to setup the adaptors). The first should be the ones that make the difference, but you may need to deal with the others too. – Linker3000 Sep 6 '11 at 21:26
1  
The reason I asked and that the virtualization type matters is that it determines what the cloning process looks like. A VMware clone on the same host would not change the virtual network hardware unless you told it to. In your case, the problem is not the mac address nor the cloning process, it's that you are changing the virtual hardware. – OldWolf Sep 6 '11 at 21:41
show 5 more comments
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.