[lfs-support] Regeneration of udev net rules

Geoff Swan gswan3 at bigpond.net.au
Thu Jun 4 23:26:32 PDT 2015

On 2015-06-05 6:16 AM, Bruce Dubbs wrote:
> Geoff Swan wrote:
>> On 2015-06-04 1:48 PM, Bruce Dubbs wrote:
>>> Geoff Swan wrote:
>>>> On 2015-06-03 6:53 AM, Paul Rogers wrote:
>>>>>> However, when I move this OS drive to another similar server, the
>>>>>> network devices fail to start because the definitions in the udev
>>>>>> rule
>>>>>> file are stilll bound to the MAC addresses of the previous hardware.
>>>>>> The question is, is there a mechanism to allow the system to
>>>>>> regenerate
>>>>>> the rules file and bind the names to the new hardware devices
>>>>>> automatically?
>>>>>> Perhaps if the file was emptied before the OS drive being moved
>>>>>> then it
>>>>>> would be generated for the new hardware?
>>>>> Yep, that'll do it.  Just delete the file.  It'll make a new one,
>>>>> though
>>>>> the order it finds them on that first boot.  Note, however, if you
>>>>> need
>>>>> a particular NIC/plug to have a particular name, eth?, you can just
>>>>> edit
>>>>> the MAC address.
>>>> No, deleting the file just causes the interface initialisation to
>>>> fail.
>>>> It did not rebuild the 70-persistent-net-rules file.
>>>> I am looking for a way to have this file generated or updated
>>>> according
>>>> the the interfaces currently in the hardware that the OS drive is
>>>> plugged in to. It could be moved between several machines.
>>> What you need to do is (as root):
>>> rm /etc/udev/rules.d/70-persistent-net.rules
>>> bash /lib/udev/init-net-rules.sh
>>>    -- Bruce
>> Thanks Bruce.
>> I guess there is no automatic mechanism for when the box has not KB or
>> monitor attached, which was what I was hoping for.
>> Even if I remove the rules file before moving the OS drive, it does not
>> appear to rebuild the rules file automaticaaly when started on a
>> different box.
>> I guess I could exec the init-net-rules.sh script at startup if the
>> rules file is not present to have it build it automatically.
> Generally you need to make several changes when moving from one box to
> another.  Things like hostname, static ip addresses, etc are the most
> obvious.  You probably do not want a dhcp ip address on a headless box
> because you need to know the ip address for ssh.
> Just update the net rules at the same time.
> Note that the init-net-rules.sh script will not generate rules in a
> virtual box.  There is generally no guarantee that the MAC address
> will be the same for different instances.
>   -- Bruce
I put together a quick init boot script to check to see if the rules
file existed and if not ran the script to create it.
However it appears to have come up with its own set of names;
KERNEL=="enp*", NAME="enp7s0f0", instead of the expected eth* names.

More information about the lfs-support mailing list