Ubuntu 14.04 server: Change em1 to eth0 - no /etc/udev/rules.d/70-persistent-net.rules file

8,910

EDIT: After a small troubleshooting session with OP I'm modifying the answer to remove the quotes for "biosdevname"

Edit the following lines in /etc/default/grub:

GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""

To:

GRUB_CMDLINE_LINUX_DEFAULT=biosdevname=0
GRUB_CMDLINE_LINUX=biosdevname=0

Next, run sudo update-grub and then reboot.

After this, you should have the udev rules persisted in /etc/udev/rules.d/70-persistent-net.rules and you can edit them as necessary.

Make sure you're changing the right interface by comparing MAC address information properly, e.g. via ifconfig -a.

Share:
8,910

Related videos on Youtube

lchristina26
Author by

lchristina26

I am a software developer working primarily in C, also completing a graduate degree in computer science with a focus on computer security.

Updated on September 18, 2022

Comments

  • lchristina26
    lchristina26 over 1 year

    I am trying to rename one of my network interfaces from em1 to eth0. I do not have /etc/udev/rules.d/70-persistent-net.rules. I have tried to regenerate this file by running these commands:

    udevadm trigger
    udevadm trigger --action=add
    udevadm trigger --action=change
    

    I tested each command individually, rebooted, looked for the 70-persistent file, before trying the next. None of the commands work, as the file is still not there, even after reboot.

    I have also tried manually running the /lib/udev/write_net_rules and I get this error:

    Cannot lock /etc/udev/rules.d/70-persistent-net.rules!
    

    This is what is in my /etc/network/interfaces file (nothing else):

    auto lo
    iface lo inet loopback
    

    My ifconfig output results in no eth0 interface, but I have an em1 interface that I need to change to eth0. I don't know how to do this without re-creating the 70-persistent file. Any help in either recreating this file or changing em1 to eth0, or both, would be greatly appreciated!

  • lchristina26
    lchristina26 over 8 years
    When I add that to grub and run sudo update-grub I get the error: biosdevname=0: not found. Am I missing a package or other file?
  • Audioz
    Audioz over 8 years
    Try sudo apt-get install biosdevname and then run sudo update-initramfs -u
  • lchristina26
    lchristina26 over 8 years
    That did not work, I still get the same error. In full it is : /usr/sbin/grub-mkconfig: 12: /etc/default/grub: biosdevname=0: not found
  • Audioz
    Audioz over 8 years
    And this is after you ran sudo apt-get install biosdevname and then sudo update-initramfs - u ?
  • lchristina26
    lchristina26 over 8 years
    Yes. Do I need to reboot after running sudo update-initramfs - u and then do ```sudo update-grub`` and reboot again?
  • Audioz
    Audioz over 8 years
    Yes, you'll need to reboot after installing biosdevname and updating the initramfs
  • Audioz
    Audioz over 8 years
  • lchristina26
    lchristina26 over 8 years
    This solution worked, thanks John Jensen!