I've faced this situation a couple of times, and came up with a way to tell my startup scripts to skip certain interfaces via kernel commandline parameters (which can be specified via your boot loader).
It's so simple that I often wonder why I (or anyone else) hadn't done it before. It's likely that everyone else on earth answered
noto my question above.
Anyway, this is what I did:
In
/etc/init.d/network
, in the loop that iterates over $interfaces
:after we've eliminated non-boot interfaces:
# bring up all other interfaces configured to come up at boot time
for i in $interfaces; do
I add this:
if LANG=C egrep -L "^ONBOOT=['\"]?[Nn][Oo]['\"]?" ifcfg-$i > /dev/null ; then
# this loads the module, to preserve ordering
is_available $i
continue
fi
# If interface was disabled from kernel cmdline, ignore
if cat /proc/cmdline | grep -q $i=off &>/dev/null; then
continue;
fi
Add the same for the next loop that iterates over
$vlaninterfaces $bridgeinterfaces $xdslinterfaces $cipeinterfaces
and you're done. As simple as that.Now, when your boot loader pops the question, you choose to edit the kernel command line, and add something like
eth0=off
to prevent eth0 from coming up at boot time. You could turn this into an alternate boot config in grub by adding an entry in /boot/grub/grub.conf
like this:
title Linux, skip eth1
root (hd0,1)
kernel /vmlinuz-2.6.10 ro root=LABEL=/ rhgb quiet eth1=off
initrd /initrd-2.6.10.img
Which will give you a nice menu option below your default Linux option saying
Linux, skip eth1.
You can always enable your interface later by doing
/sbin/ifup eth1
.Note: You may need to add
is_available $i
inside the if
block. I don't know, and it works for me without it.
0 comments :
Post a Comment