On Fri, Mar 16, 2012 at 15:41, Joost Roeleveld <jo...@antarean.org> wrote:
> On Friday, March 16, 2012 02:54:16 PM Pandu Poluan wrote:
>> What I have in mind for "helper scripts" would be (for example) a
>> script to ensure that, on boot, ethernet devices will maintain their
>> relative order. This needs to be stuck into /etc/mdev.conf (already
>> part of stage3).
>>
>> (And if someone's well-versed enough in Linux, maybe he/she will
>> convert the shellscript into a simple -- and faster -- binary with
>> exact same functionality).
>
> I think you are talking about a script that handles a more "dynamic" database
> to force renames/softlinks for devices keeping names identical?
> I haven't played with mdev yet, but isn't that already in mdev?
> Or does mdev require it to be set manually?
>

Well, to make mdev simple enough for embedded devices (whose devices
always come up in the same order), busybox devs do not include any
database of devices.

However, mdev is perfectly able to execute a program (script or
binary) when it detects a device coming up, and it can choose which
program to execute based on the device name.

Let's say you have two NICs, one will get eth0, the other will get
eth1, depending on the order that the kernel initializes the device
name. For that, you don't have to do a thing.

However, if the devices somehow gets initialized at the same time
(e.g., hotplug events), it's a toss which dev will get which name.

That is why, the busybox devs recommended the "linuxrc" file to
contain the line "mdev -s", which will handle dev initializations
during boot in a sequential fashion, ensuring exact same device names.

> Btw, the "keep same devicename" is rather annoying when having to replace the
> network card and the network then doesn't come back up...
>

There are several scenarios:

Scenario 1: eth1 is replaced, eth0 stays -- if the new card is
initialized after eth0, it will automatically assume eth1. If the new
card is initialized before eth0, it will become the new eth0, and the
previous eth0 will become eth1 automatically.

Scenario 2: eth0 is replaced, eth1 stays -- if the new card is
initialized before eth1, it will automatically assume eth0. If the new
card is initialized after eth1, the previous eth1 gets eth0, while the
new card gets eth1.

The program (script) I'm planning will have a simple 'database'
(actually, a text file) containing pairs of MAC address and devname.
This should ensure that devices with a certain MAC address will
*always* get the same devname, while devices not listed in the
database will get the first available devname.

Thus, in the case where devname swapping would happen (see the second
situation in Scenarios 1 & 2), *at least* the non-replaced device will
get the exact devname as before replacement happens.

Rgds,
-- 
FdS Pandu E Poluan
~ IT Optimizer ~

 • LOPSA Member #15248
 • Blog : http://pepoluan.tumblr.com
 • Linked-In : http://id.linkedin.com/in/pepoluan

Reply via email to