Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've changed the name of my eth1 interface to eth0. How to ask udev now to re-read the config?

service udev restart

and

udevadm control --reload-rules

don't help. So is there any valid way except of rebooting? (yes, reboot helps with this issue)

  • yes, I know I should prepend the commands with sudo, but either one I posted above changes nothing in ifconfig -a output: I still see eth1, not eth0.

  • I just changed the NAME property of udev-rule line. Don't know any reason for this to be ineffective.

There is no any error in executing of both commands I've posted above, but they just don't change actual interface name in ifconfig -a output. If I perform reboot - then interface name changes as expected.

For development purposes I write some script that clones virtual machines (VirtualBox-driven) and pre-sets them up in some way.

So I perform a command to clone VM, start it and as long as network interface MAC is changed - udev adds the second rule to network persistent rules. Right after machine is booted for the first time there are 2 rules:

  • eth0, which does not exist, as long as it existed in the original VM image MAC
  • eth1, which exists, but all the configuration in all files refers to eth0, so it is not that good for me

So I with sed delete the line with eth0 (it is obsolete and useless in cloned image) and replace eth1 with eth0. So currently I have valid persistent rule, but there is still eth1 in /dev.

The issue: I don't want to reboot the machine (it will take another time, which is not good thing on building-VM-stage) and just want to have my /dev rebuilt with some command so I have ready-to-use VM without any reboots.

share|improve this question
    
How did you change eth1 to eth0? Did you just rename the device file? If so, that's not an effective way to do it (and you should expect the change to be reverted by a successful restart of the udev daemon). If you used some other method, please describe it in detail, and please also give the complete and exact text of any error messages you're seeing when you run the commands you've tried (for restarting the udev daemon or reloading its rules). You can edit your question to provide this information. –  Eliah Kagan Nov 25 '11 at 1:11
    
@Eliah Kagan: updated. ps: why should it be reverted? It shouldn't ;-) –  zerkms Nov 25 '11 at 1:13
    
udev dynamically generates your devices in /dev. If you restart it, it will regenerate them according to its rules. Changes made directly to them are not, generally speaking, persistent. It looks like restarting udev is working fine, but that you just haven't properly changed the device names. –  Eliah Kagan Nov 25 '11 at 1:15
    
@Eliah Kagan: udev only adds (not modifies) new rules if it cannot find the one for particular device. If there is a rule that matches - it just follows it without modifications. –  zerkms Nov 25 '11 at 1:17
    
@Eliah Kagan: and I changed it properly. Just believe I do can change one char in a line ;-) (also reboot helpes, and this proves that everything is fine with rules) –  zerkms Nov 25 '11 at 1:19

9 Answers 9

So for me on VirtualBox with Ubuntu 12.04, I often switch between ethernet and wireless.

So when my connection changes, I must choose the Bridged Adapter from Devices > Network Settings. Either 'Intel 82579LM Gigabit Network Connection' or 'Intel Centrino Ultimate-N 6300 AGN'.

After doing this, I can run

sudo modprobe -r e1000
sudo service udev restart
sudo modprobe e1000
ping google.com # To test I ran this between each command.

This is just an explanation of my results after reading all the answers above.

share|improve this answer
udevadm trigger 

it will work enter link description here

share|improve this answer
1  
Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  Braiam Aug 30 '13 at 2:50

This should do it safely:

sudo reload udev

As I have used this command with no issues.

share|improve this answer
    
Nope, ifconfig -a still shows me old eth1 interface –  zerkms Nov 25 '11 at 1:05

I had a similar problem. Since I didn't want to take the time to reboot, I ran a one liner using Chris Wesseling's suggestion.

/etc/init.d/networking stop && modprobe -r tg3 && udevadm control --reload-rules && udevadm trigger && modprobe tg3 && /etc/init.d/networking start

This worked for me using Ubuntu 12.04.02 server. My nics were using the tg3 kernel module driver, so change tg3 to the module your interfaces are using. I found the ones mine used in /etc/udev/rules.d/70-persistent-net.rules:

PCI device 0x14e4:/sys/devices/pci0000:00/0000:00:1c.4/0000:02:00.1 (tg3) <-kernel module driver for the nic

The one issue I had was a bad route which I fixed with a simple route add command. Thanks for the help Chris!

share|improve this answer

You have to combine all the advice given here in the right order:

  1. Bring down the network service networking stop
  2. Unload the driver module from the kernel
    1. Find the name of the module lspci -v and look for "Kernel driver in use:"
    2. modprobe -r <driver module>
  3. Reload the udev rules udevadm control --reload-rules
  4. Trigger the new rules udevadm trigger
  5. Load driver modprobe <driver module>
  6. Restart the network service networking start
  7. (optional) Re-run any iptables scripts that referenced the eth interface name before it was up.

I suspect either step 4 or step 5 isn't really needed, but these steps worked for me. You could check after step 4 with step 2.1 to see if the trigger command already did step 5, edit this answer to reflect your findings if you do.

share|improve this answer

You need to reload udev to trigger the rule change, but the device won't be renamed unless you unload/reload the driver module.

So modprobe -r e1000 && modprobe e1000 after udev reload should do the trick. Of course, don't do that if you need the network and have only e1000 interfaces.

share|improve this answer

I don't know if this helps in reloading the network configuration, but when I modified /etc/udev/rules.d/70-persistent-cd.rules to correct the DVD device link from /dev/dvd1 to /dev/dvd, I had to run

sudo udevadm trigger

to get have the new links created.

share|improve this answer
    
I believe sudo udevadm trigger --action=change is safer, as per this email about what's safe and not safe to do about udev: lists.ubuntu.com/archives/ubuntu-devel/2009-January/027260.html –  Ehtesh Choudhury Mar 11 '13 at 19:14

I've been researching this for a while with pretty much the same purpose, and I haven't been able to find a way to change the network interface name in a live system.

The workaround I have gone for is to delete the /etc/udev/rules.d/70-persistent-net.rules file in the template, which means that on the next boot it will see any network card as eth0.

share|improve this answer

sudo /etc/init.d/udev restart should do the trick. Some of the commands you had tried, if run with sudo, might be effective as well.

share|improve this answer
    
Nope, ifconfig -a still shows me old eth1 interface –  zerkms Nov 25 '11 at 1:05

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.