[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

predefine interfaces by MAC with udev?



Hi,

I have tried a premount script live-premount/10set_device_by_mac

    if [ -n "${BOOTFROMMAC}" ];then
    {
        for interface in /sys/class/net/eth*; do
                MAC=`cat $interface/address`
                if [ $MAC == $BOOTFROMMAC ];then
                {
                        # this is the mac we're looking for:
$BOOTFROMMAC found on $interface
                        if [ -n "`echo $interface | grep eth0`" ];then
                        {
                                # bingo! MAC is already asigned to eth0
                                break
                        }
                        else
                        {
                                # we want to rename this interface to eth0
                                interface=`echo $interface|cut -f 5 -d /`
                                ifconfig eth0 down
                                ifconfig $interface down
                                mv /sys/class/net/eth0 /sys/class/net/eth0-old
                                mv $interface /sys/class/net/eth0
                                mv /sys/class/net/eth0-old $interface
                                ifconfig eth0 up
                                ifconfig $interface up
                                break
                        }
                        fi
                }
                fi
        done
    }
    fi

but that didn't work.
I've read that udev reads from /sys which also makes me think that I
should concentrate on udev, but if that it so then why are the devices
already named like /sys/class/net/eth0 ?

Thanks again.
Chris.

> Hi,
>
> Thanks for the replies.
>
> > create a file in the chroot, with that lines,
> >
> > /etc/udev/rules.d/010_netinterfaces.rules
> >
> > and rebuild the initrd
> Yes, but that means I need a seperate initrd for each diskless server, right?
>
> > Well what about trying to use the boot param ip from tftp, then for
> > each server just specify as you want.
>
> The problem I'm having is that udev names the interfaces from
> /etc/udev/rules.d/z45_persistent-net-generator.rules
> And there seems to be know way to guarantee that the interface you pxe
> boot from will be named eth0 by the persistent-net-generator.rules
> So the boot fails. (is that right or am I way off course?)
>
> I need to find a way to create an new rule in
> z45_persistent-net-generator.rules or maybe EOF a rule into
> /etc/udev/rules.d/z25_persistent-net.rules
> (I think).
>
> I've stopped the boot with break=top and I can see
> /etc/udev/rules.d/z45_persistent-net-generator.rules
> but no
> /etc/udev/rules.d/z25_persistent-net.rules
>
> I feel like an aprentice butcher.
>
> Chris.
>
>
>
> On Feb 7, 2008 5:33 PM, Richard Nelson <unixabg at gmail.com> wrote:
> > Greetings,
> >
> > Well what about trying to use the boot param ip from tftp, then for
> > each server just specify as you want.
> >
> > http://live.debian.net/other/manpages/live-initramfs.7.html
> >
> > Hope this helps.
> >
> >
> > On Feb 7, 2008 5:00 AM, Chris Fanning <christopher.fanning at gmail.com> wrote:
> > > Hi,
> > >
> > > We're trying to boot diskless servers that have two network interfaces.
> > >
> > > We boot from one interface (dhcpd/MAC), but when initramfs kicks in,
> > > udev (isn't it?) sets the interface names and then (often) the boots
> > > process fails becuase it's looking for the filesystem on the wrong
> > > interface.
> > >
> > > We can't use the MAC as an option for 'ifconfig' or 'ip add add', so
> > > we need to change something with udev, right?
> > >
> > > KERNEL=="eth*", SYSFS{address}=="00:12:34:fe:dc:ba", NAME="eth0"
> > > KERNEL=="eth*", SYSFS{address}=="00:56:78:98:76:54", NAME="eth1"
> > >
> > > I've looked around the scripts but nothing as jumped out at me.
> > >
> > > What would you do?
> > >
> > > Thanks.
> > > Chris.
> > >
> >
> > > _______________________________________________
> > > debian-live-devel mailing list
> > > debian-live-devel at lists.alioth.debian.org
> > > http://lists.alioth.debian.org/mailman/listinfo/debian-live-devel
> > >
> >
>



Reply to: