Friday, 13 March 2009

ifup: network-functions: line 52: eth0: No such file or directory

The (external) power supply on my Linux box broke the other day. Tranquil PC sent me a new one, so I booted the machine up for the first time in ages. I noticed an error message as it was trying to bring up the eth0 interface (which is nicknamed "moors" on my machine):

ifup: network-functions: line 52: eth0: No such file or directory

This appeared twice every time I booted the machine.

I looked in /etc/sysconfig/network-script/network-functions, and line 52 was the (rather unhelpful):


I went through a prolonged debugging session, putting trace code in ifup and network-functions, and I found the problem was caused by line 155 of ifup:

is_available ${REALDEVICE}

REALDEVICE at this point is "eth0". is_available starts like this:

LC_ALL= LANG= ip -o link | grep -q $1
[ "$?" = "1" ] || return 0

alias=`modprobe -c | awk "/^(alias|install)[[:space:]]+$1[[:space:]]/ { print \\$3 }"`
if [ -z "$alias" -o "$alias" = "off" -o "$alias" = "/bin/true" ]; then
return 2
modprobe $1 > /dev/null 2>&1 || return 1
# if it is a mainframe ccwgroup device, configure it before
# trying to rename it:
need_config ${1}

I haven't figured out what all the tests at the top do, but (for eth0 only, and only when rebooting) control comes through to the call to need_config. need_config looks like this:

[ -f "${CONFIG}" ] && return
[ -f "${CONFIG}" ] && return
local addr=`get_hwaddr ${1}`
if [ -n "$addr" ]; then
local nconfig=`get_config_by_hwaddr ${addr}`
if [ -n "$nconfig" ] ; then
[ -f "${CONFIG}" ] && return

So CONFIG gets changed from "ifcfg-moors" (which is what it was to start with) to "eth0" - and there is no such file (nor an ifcfg-eth0) in /etc/sysconfig/network-scripts.

I have "fixed" the problem by adding a line to the top of need_config:

[ -f "${CONFIG}" ] && return

but this is the ravings of someone who doesn't really know what is going on!

Helpful suggestions welcome.

No comments: