When cloning a VMware Virtual Machine, how can I prevent MAC address & UUID conflicts?

29,951

Since device persistence stuff is just getting in the way for these VMs, rip it out:

  • Completely remove the HWADDR and UUID lines from the ifcfg file, and
  • Delete /etc/udev/rules.d/70-persistent-net.rules before cloning

That should let the eth0 with a new MAC address actually use the ifcfg-eth0 on initial boot.

Share:
29,951

Related videos on Youtube

Stefan Lasiewski
Author by

Stefan Lasiewski

Stefan Lasiewski Daddy, Linux Guy, Bicyclist, Tinkerer, Fixer & Breaker of things. I work as a Senior SYstem Engineer at the National Energy Research Scientific Computing Center (NERSC) Division at Lawrence Berkeley National Laboratory (LBNL) in Berkeley, CA. Father of 3 cute children. Yes I'm a sysadmin and a parent. Heavy user of CentOS, RHEL & FreeBSD for production services at work. I also run Ubuntu at home, for the simplicity. I'm a fan of Apache HTTP Server, Nagios & Cacti. Original proposer of unix.stackexchange.com (Yes, this proposal predated askubuntu.com, and I wish they would have merged with the Unix proposal.).

Updated on September 18, 2022

Comments

  • Stefan Lasiewski
    Stefan Lasiewski over 1 year

    I've run into the following problem on both VMware Fusion (for Macs) and with VMware ESXi/vSphere. Many of you are familiar with the problem, and it is described at VMware KB: "Networking does not work in a cloned Linux virtual machine (2002767) ."

    1. Create a CentOS VM.
      • This is a bare-bones VM with a minimal set of software and a functioning network stack. The idea is that we take the minimal VM, clone it and add more software later.
    2. Clone that VM
    3. VMware Fusion or vCenter will assign a new MAC address to the network interface on the cloned VM.
    4. Linux doesn't know about this new MAC address and thus networking doesn't work. The file /etc/sysconfig/network-scripts/ifcfg-ethN has the MAC address of the interface on the first machine.
    5. To fix this, I need to find the MAC address of the new VM, edit ifcfg-ethN and add this MAC to the HWADDR= field. I can't simply cut and paste the MAC into the field, so this can be an error-prone task, especially if I forget my pen and paper to write down the MAC.
    6. (Bonus points) On the new VM, often eth0, eth1, etc. display in the wrong order. Fixing this involves an arcane dance around /etc/udev/rules.d

    I can do this, but it's error prone and kind of a pain when I simply wanted to spin up a new VM to test something.

    Is there a way to simplify this manual process? When you clone a new machine, how do you fix the MAC address problem?

    • ravi yarlagadda
      ravi yarlagadda over 9 years
      For these systems, do you care about keeping the device persistence stuff at all?
    • Stefan Lasiewski
      Stefan Lasiewski over 9 years
      No not for the network interface.
  • Stefan Lasiewski
    Stefan Lasiewski over 9 years
    Hm, this seems to work. I had no idea HWADDR was optional. Should I also remove the UUID?
  • ravi yarlagadda
    ravi yarlagadda over 9 years
    @StefanLasiewski Ahh, yes, you should.
  • deepdive
    deepdive about 8 years
    +1 worked like charm J
  • Howard Lee
    Howard Lee almost 8 years
    out of top 10 google results, this is the one that works! note: remove the HWADDR AND UUID lines from /etc/sysconfig/network-scripts/ifcfg-eth0