Thursday, November 7, 2013

Device eth0 does not seem to be present, delaying initialization: Linux Networking

PROBLEM
You receive random errors failing to initialize your network card at boot time or during manual restart that look like the one below:
$ifup eth0
via-rhine device eth0 does not seem to be present, delaying initialization. 
$
Or just a form of the
# service network restart
.
.
device does not seem to be present, delaying initialization
.
.
#
from any device such as bond0 or wlan0 etc.  Here's how to solve it.
SOLUTION
There are a couple of potential solutions to this issue:
  • Missing 'HWADDR' variable from '/etc/sysconfig/network-scripts/ifcfg-eth0'.  Try adding "HWADDR=01:23:45:67:89:AB" to '/etc/sysconfig/network-scripts/ifcfg-eth0' and rerunning 'ifup eth0' command.
     
  • You could try renaming the interface you have to the one the system is currently configured for and regunning service network restart.  An example of renaming a wireless LAN card is below:




    cd /sys/class/net
    ll
    lrwxrwxrwx 1 root root 0 Jun 14 06:17 wlan1 -> ../../devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/net/wlan1
    ip link set dev wlan1 name wlan0
    ll
    lrwxrwxrwx 1 root root 0 Jun 14 06:17 wlan1 -> ../../devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/net/wlan1
To make the above change persistent across reboots, please see the following post Linux Networking: Persistent naming rules based on MAC for eth0 and wlan0.  The persistent naming rules also solve this issue through the persistent naming rules in /etc/udev/rules.d/70-persistent-net.rules.  See the link for more on that.

FIRST INVESTIGATION
For a while now I kept getting the error message " via-rhine device eth0 does not seem to be present, delaying initialization" on and off when I logged into my Linux distribution.  A reboot fixed this problem virtually everytime.  So what's wrong?  First thing I tried is to use:
$ifup eth0
via-rhine device eth0 does not seem to be present, delaying initialization.
$
Naturally this produced absolutely the same error I saw at boot time, which wasn't very helpfull at all.  I know my primary card (My link to my WRT54GL switch and therefore my way of accessing the WEB) was down and I couldn't connect anywhere.  What it didn't tell me is the root problem.  At this point I started at the obvious points by checking the log files:
/var/log/messages
/var/log/secure
/var/log/dmesg
Next thing I checked is '/etc/sysconfig/hwconf', searched for NETWORK where I found both eth1 and eth0 correctly configured.  I compared the two and saw nothing out of the ordinary.  Next thing I tried is:
lspci|grep Ethernet
00:0c.0 Ethernet controller: National Semiconductor Corporation DP83815 (MacPhyter) Ethernet Controller
00:0d.0 Ethernet controller: D-Link System Inc RTL8139 Ethernet (rev 10)
00:12.0 Ethernet controller: VIA Technologies, Inc. VT6102 [Rhine-II] (rev 78)
$
Which showed that all network cards were being seen by my system.  In particular I went through /var/log/dmesg with a fine toothed comb but nothing appeared that provided any hint as to the problem.  At least nothing I could understand.  I tried restarting but unlike other times, this time, the system came back up and still didn't detect eth0. Not good!  At this point I decided to try a basic programming trick:
edit '/sbin/ifup' and insert 'echo' statements at various points to show variables the BASH utility sets along the way to the error message above (WARNING: Don't do this unless you know a bit about KSH/BASH and scripting in general).  That is until I reach something that would tell me more about where the problem is.  This took me long so you shouldn't expect a 5 minute job here.  Long story short, ultimately as I went along inserting statements I ended up modifying a bunch of files and utilities:
/sbin/ifup
/etc/sysconfig/network-scripts/network-functions
/etc/sysconfig/network-scripts/ifup-eth
All of which were called from '/sbin/ifup'.  This resulted in the following output:
$ ifup eth0
Running script /etc/sysconfig/network-scripts/ifup …
/sbin/ifup[1]: Running '. /etc/init.d/functions' …
Running '/etc/sysconfig/network-scripts/network-functions' through script /etc/sysconfig/network-scripts/ifup … /sbin/ifup[2]: Checking if folder '../network' exists …
/sbin/ifup[3]: Setting CONFIG=eth0 …
/sbin/ifup[4]: Running eth0 …
/sbin/ifup[5]: Check if ${CONFIG} ifcfg-eth0 exists…
/sbin/ifup[6]: Check if ${UID} 0 != 0 …
/sbin/ifup[7]: Running 'source_config' network-functions
[-1](PROC: source_config):
RESULTS:
$DEVNAME=||
$PARENTCONFIG=||
$PARENTDEVNAME=||
$TYPE=|| $DEVICE=|eth0|
$REALDEVICE=|eth0|
$ISALIAS=|no|
$DEVICETYPE=|eth|
$HWADDR = ||
$REALDEVICE=|eth0|
/sbin/ifup[8]: Test if $2 was specified as 'boot' and ${ONBOOT} 'yes' is set to 'no/NO', check IN_HOTPLUG and as 'Bridge' …
/sbin/ifup[9]: Check if VLAN: $VLAN = ||
/sbin/ifup[9.0]: Non VLAN config:
$VLAN = ||,
$DEVICE = |eth0|
/sbin/ifup[9.1]: Non VLAN config:
$VLAN = ||,
$DEVICE = |eth0|,
$BOOTPROTO = |static|
/sbin/ifup[9.2]: Test if '/sbin/ifup-pre-local' exists.  Run with |ifcfg-eth0|| if does.
/sbin/ifup[9.2]: Test if '/etc/sysconfig/network-scripts/ifup-eth' exists…
/sbin/ifup[9.2]: Execute: /etc/sysconfig/network-scripts/ifup-eth ifcfg-eth0
Running script /etc/sysconfig/network-scripts/ifup-eth …
Running '/etc/sysconfig/network-scripts/network-functions' through script /etc/sysconfig/network-scripts/ifup-eth … network-functions [-1](PROC: source_config):
RESULTS:
$DEVNAME=||
$PARENTCONFIG=||
$PARENTDEVNAME=||
$TYPE=||
$DEVICE=|eth0|
$REALDEVICE=|eth0|
$ISALIAS=|no|
$DEVICETYPE=|eth|
$HWADDR = ||
$REALDEVICE=|eth0|
network-functions[0]: eth0 = |eth0|\n
network-functions[1]: Running ‘modprobe -c | awk “/^(alias|install)[[:space:]]+eth0[[:space:]]/ { print $3 }"' …\n
network-functions[1]: Above alias returned: |via-rhine|.  Now running 'modprobe eth0' …\n
network-functions[2]: Checking $HWADDR = ||\n
network-functions[2]: Running 'ip -o link | grep -q eth0' again and providing it's return value to caller.
/etc/sysconfig/network-scripts/ifup-eth[0]: ${REALDEVICE} = |eth0|
network-functions[0]: eth0 = |eth0|\n
network-functions[1]: Running ‘modprobe -c | awk “/^(alias|install)[[:space:]]+eth0[[:space:]]/ { print $3 }"' …\n
network-functions[1]: Above alias returned: |via-rhine|.  Now running 'modprobe eth0' …\n
network-functions[2]: Checking $HWADDR = ||\n
network-functions[2]: Running 'ip -o link | grep -q eth0' again and providing it's return value to caller.
via-rhine device eth0 does not seem to be present, delaying initialization.
$
You'll noticed error is thrown right below the red line.  I tried the command above  to see what it would produce:
ip -o link|grep -q eth0
$
Nothing.  Apparently '/sbin/ifup' checks using '/sbin/ip' to look for a card.  Next I typed:
$ ip -o link
1: lo: <LOOPBACK,UP,10000> mtu 16436 qdisc noqueue \   
     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000\   
     link/ether 00:02:e3:17:e1:47 brd ff:ff:ff:ff:ff:ff
3: dev1804289383: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000\   
     link/ether 00:13:d4:3d:3b:6a brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000\   
     link/ether 00:0d:88:38:0a:34 brd ff:ff:ff:ff:ff:ff
$
Notice the differences.  One of the devices wasn't given an alias 'eth0'.  Now the question is why the other cards have proper aliases but this one, my main card, isn't given one.  I decided to try running '/sbin/ifup eth1' for my second card, which was picking up without issues:
ifup eth1
Running script /root/ifup …
/sbin/ifup[1]: Running '. /etc/init.d/functions' …
Running '/etc/sysconfig/network-scripts/network-functions' through script /etc/sysconfig/network-scripts/ifup …
/sbin/ifup[2]: Checking if folder '../network' exists …
/sbin/ifup[3]: Setting CONFIG=eth1 …
/sbin/ifup[4]: Running eth1 …
/sbin/ifup[5]: Check if ${CONFIG} ifcfg-eth1 exists…
/sbin/ifup[6]: Check if ${UID} 0 != 0 …
/sbin/ifup[7]: Running 'source_config' network-functions
[-1](PROC: source_config):
RESULTS:
$DEVNAME=||
$PARENTCONFIG=||
$PARENTDEVNAME=||
$TYPE=||
$DEVICE=|eth1|
$REALDEVICE=|eth1|
$ISALIAS=|no|
$DEVICETYPE=|eth|
$HWADDR = |00:02:E3:17:E1:47|
$REALDEVICE=|eth1|
/sbin/ifup[8]: Test if $2 was specified as 'boot' and ${ONBOOT} 'yes' is set to 'no/NO', check IN_HOTPLUG and as 'Bridge' …
/sbin/ifup[9]: Check if VLAN: $VLAN = ||
/sbin/ifup[9.0]: Non VLAN config:
$VLAN = ||,
$DEVICE = |eth1|
/sbin/ifup[9.1]: Non VLAN config:
$VLAN = ||,
$DEVICE = |eth1|,
$BOOTPROTO = |static|
/sbin/ifup[9.2]: Test if '/sbin/ifup-pre-local' exists.  Run with |ifcfg-eth1|| if does.
/sbin/ifup[9.2]: Test if '/etc/sysconfig/network-scripts/ifup-eth' exists…
/sbin/ifup[9.2]: Execute: /etc/sysconfig/network-scripts/ifup-eth ifcfg-eth1
Running script /etc/sysconfig/network-scripts/ifup-eth …
Running '/etc/sysconfig/network-scripts/network-functions' through script /etc/sysconfig/network-scripts/ifup-eth … network-functions[-1](PROC: source_config):
RESULTS:
$DEVNAME=||
$PARENTCONFIG=||
$PARENTDEVNAME=||
$TYPE=||
$DEVICE=|eth1|
$REALDEVICE=|eth1|
$ISALIAS=|no|
$DEVICETYPE=|eth|
$HWADDR = |00:02:E3:17:E1:47|
$REALDEVICE=|eth1|
network-functions[0]: eth1 = |eth1|\n
/etc/sysconfig/network-scripts/ifup-eth[0]: ${REALDEVICE} = |eth1|
network-functions[0]: eth1 = |eth1|\n
Running '/etc/sysconfig/network-scripts/network-functions' through script /etc/sysconfig/network-scripts/ifup-post … network-functions[-1](PROC: source_config):
RESULTS:
$DEVNAME=||
$PARENTCONFIG=||
$PARENTDEVNAME=||
$TYPE=||
$DEVICE=|eth1|
$REALDEVICE=|eth1|
$ISALIAS=|no|
$DEVICETYPE=|eth|
$HWADDR = |00:02:E3:17:E1:47|
$REALDEVICE=|eth1|
Running '/etc/sysconfig/network-scripts/network-functions' through script /etc/sysconfig/network-scripts/ifup-aliases …
$
Comparing, I noticed the HWADDR was not empty for 'eth1' whereas for 'eth0' it was empty.  This made sense since 'ip -o link' showed a random string for the ethernet alias I needed.  This led me to compare the two config files:
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth1
Which quickly showed eth1 had HDADDR="…" the other didn't.  Sure enough after the change, 'ip' also showed correct settings:
$ ip -o link
1: lo: <LOOPBACK,UP,10000> mtu 16436 qdisc noqueue \   
     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000\   
     link/ether 00:02:e3:17:e1:47 brd ff:ff:ff:ff:ff:ff
3: eth0: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc pfifo_fast qlen 1000\   
     link/ether 00:13:d4:3d:3b:6a brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000\   
     link/ether 00:0d:88:38:0a:34 brd ff:ff:ff:ff:ff:ff
$
It is noteworthy to say that I then removed the HWADDR from the ifcfg-eth0 config file, yet bringing eth0 up and down worked fine now while the system was on.  This could lead to a common mistake where removal of HWADDR from config file doesn't appear to cause issues, might cause one at next cold boot.

SECOND INVESTIGATION
Nov 1 2012: Another potential location where this might occur is when bonding module isn't loaded.  In this case, all that is necessary is to load the bonding module and you're set:
# service network restart
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface bond0:  bonding device bond0 does not seem to be present, delaying initialization.
                                                           [FAILED]
# modprobe bonding
# service network restart
Shutting down interface bond0:                             [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface bond0:  RTNETLINK answers: File exists
Error adding address 192.168.0.8 for bond0.
RTNETLINK answers: File exists
                                                           [  OK  ]
#


THIRD INVESTIGATION
The third investigation really has it's roots from the second investigation where I simply tried renaming the device name:
# service network restart
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Device eth0 does not seem to be present, delaying
initialization.
                                                           [FAILED]
Bringing up interface wlan0:  Device wlan0 does not seem to be present, delaying
initialization.
                                                           [FAILED]
#
Checking the devices under /sys/class/net we see that wlan0 doesn't exist at which point I attempted a rename as above:
# cd /sys/class/net
# ll
total 0
lrwxrwxrwx 1 root root 0 Jun 14 06:17 eth2 ->
../../devices/pci0000:00/0000:00:1e.0/0000:02:05.0/net/eth2
lrwxrwxrwx 1 root root 0 Jun 14 06:17 lo -> ../../devices/virtual/net/lo
lrwxrwxrwx 1 root root 0 Jun 14 20:19 sit0 -> ../../devices/virtual/net/sit0
lrwxrwxrwx 1 root root 0 Jun 14 06:17 virbr0 -> ../../devices/virtual/net/virbr0
lrwxrwxrwx 1 root root 0 Jun 14 06:17 wlan1 ->
../../devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/net/wlan1
# ip link set dev wlan1 name wlan0
# ll
total 0
lrwxrwxrwx 1 root root 0 Jun 14 06:17 eth2 ->
../../devices/pci0000:00/0000:00:1e.0/0000:02:05.0/net/eth2
lrwxrwxrwx 1 root root 0 Jun 14 06:17 lo -> ../../devices/virtual/net/lo
lrwxrwxrwx 1 root root 0 Jun 14 20:19 sit0 -> ../../devices/virtual/net/sit0
lrwxrwxrwx 1 root root 0 Jun 14 06:17 virbr0 -> ../../devices/virtual/net/virbr0
lrwxrwxrwx 1 root root 0 Jun 14 21:08 wlan0 ->
../../devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/net/wlan0
#
Per above, the error message produced from restarting the network is identical however this time wlan0 failed to reconnect following asetup of a wireless network configuration earlier on my HTPC when I swapped my G wireless adapter for an N wireless adapter.  The most likely reason for that was the system probably did not unregister the previous wlan0 fully registering only the wlan1 instead. 
So the renaming worked temporarily but always reverted back to the wlan1 configuration after a reboot.  Instead of renaming the card, I created an /etc/sysconfig/network-scripts/fcfg-wlan1 configuration file as well and rebound my wpa_supplicant configuration to run off this new device.  I preferred this over yanking out any reference to wlan0 in case I had to reuse my G wireless adapter.  For more details on this please see the above link.

MORAL OF THE STORY
This is the sure fire way to identify an issue provided all files are scripts (not binaries) and can be modified.  Nonetheless, and to cut yourself a bunch of work, be sure to compare the not working file to a working one when the option exists.  I could have saved myself a bunch of work. smiley   Nonetheless, it wasn't a total waste.  I did get to learn a bit more about the Linux networking and the zoo of functions available.   smiley
Cheers,
TK

CentOS 6.3 Device eth0 does not seem to be present (Minimal non-cloned setup)

In my situation, I changed the network adapter configuration of my hypervisor after the installation of CentOS. What happened in this case is that the old interface eth0 no longer existed but a new one called eth1 did.
ls /sys/class/net
eth1 lo
I changed the network config /etc/sysconfig/network-scripts/ifcfg-eth0 to use DEVICE=eth1 and it worked again.