Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've changed my rules in /etc/udev/rules.d (Ubuntu) to change my ethernet port names from 0 to 1 and 1 to 2, however whenever I run:

    sudo service udev restart
    sudo udevadm control --reload-rules

it doesn't update my ethernet port numbers until I restart.

This obviously isn't an issue for running a normal computer, however I need to implement this idea into a live CD (Knoppix) to test ethernet ports on multiple systems that each need a different kernel set to specific ethernet ports for my scripts to work, and the only way I've found to do it was using the udev rules, however that's not easily possible because of the fact that the rules won't update unless you restart.

Is there anyone out there that knows a way to get these ports to change without restarting the machine?

share|improve this question

2 Answers 2

up vote 0 down vote accepted

Reloading the rules will only make sure the device is named correctly the next time it is detected. You will have to unload and load again the network interface driver (kernel module).

If the driver is a kernel module, find out the module name and reload it (most probably if you didn't configure the kernel yourself). Note that this will shut down all the interfaces using this driver (or see below):

# ls -l /sys/class/net/eth0/device/driver
lrwxrwxrwx 1 root root 0 Jul 18 19:18 /sys/class/net/eth0/device/driver -> ../../../../bus/pci/drivers/atl1c
# rmmod atl1c
# modprobe atl1c

If however the driver is built-in, it's a little more work. You have determine both the driver name and the PCI ID, order the driver to unbind itself from the device, and bind it back.

# ls -l /sys/class/net/eth0/device
lrwxrwxrwx 1 root root 0 Jul 18 19:18 /sys/class/net/eth0/device -> ../../../0000:06:00.0
# ls -l /sys/class/net/eth0/device/driver
lrwxrwxrwx 1 root root 0 Jul 18 20:41 /sys/class/net/eth0/device/driver -> ../../../../bus/pci/drivers/atl1c
# echo 0000:06:00.0 > /sys/bus/pci/drivers/atl1c/unbind
# echo 0000:06:00.0 > /sys/bus/pci/drivers/atl1c/bind
share|improve this answer
    
Thanks for the reply. I never thought about using rmmod. I'll suppose I'll post any other issues I run into here. –  Vincanis Jul 19 '11 at 11:36
    
rmmod/modprobe was the way to go. It works manually in Knoppix and Ubuntu, so it should work with a script but who knows. Thanks for the help. –  Vincanis Jul 19 '11 at 12:09

Rules are only applied when a device is plugged. Try udevadm trigger to cause rules to be reapplied to all devices.


Quote from the manual page of udevadm:

--reload-rules

Signal udevd to reload the rules files. The udev daemon detects changes automatically, this option is usually not needed. Reloading rules does not apply any changes to already existing devices.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.