Device eth0 does not seem to be present, delaying initialization

Recently I’ve been deploying quite a few VMs for a wide range of different services. This issue happened to me before when I added a second ethernet card to my homeserver last year (before it died, lously Intel Atom motherboard).

When adding the new ethernet card or if you want to switch eth0 and eth1, the issue is there’s a hard preset storage of the MAC address to system network device. When trying to bring up eth0 I got this error message.

Device eth0 does not seem to be present, delaying initialization  

This became quite common when working with cloning images.
Dmesg revealed that eth0 has been renamed to eth1 (udev: renamed network interface eth0 to eth1)

The simple fix is to remove the persistent rule and give it a reboot. Don’t forget to update the networks file /etc/sysconfig/network-scripts/ifcfg-ethx

Comment or Modify UUID and MAC Address

nano /etc/sysconfig/network-scripts/ifcfg-eth0  
rm -f /etc/udev/rules.d/70-persistent-net.rules  

Now when the server reboots, these persistent-net.rules will be regenerated again on boot with the new mac addresses.

Note: If you're creating VM images (ami etc.) These five lines should fix everything for you.

sed -i '/HWADDR/d' /etc/sysconfig/network-scripts/ifcfg-eth0  
sed -i '/HOSTNAME/d' /etc/sysconfig/network-scripts/ifcfg-eth0  
sed -i '/UUID/d' /etc/sysconfig/network-scripts/ifcfg-eth0

rm -f /etc/udev/rules.d/*-persistent-*  
touch /etc/udev/rules.d/75-persistent-net-generator.rules  

The first three sed lines remove the mac address, hostname and uuid lines from the interface. And the final two will simply block the persistent interface file from being created.

If you're running a VM on a hosting provider such as DigitalOcean, this error may also appear if you've got a mismatching kernel installed on your instance and the one provided by the hypervisor. This is due to the incorrect modules being loaded.

comments powered by Disqus