Fork me on GitHub

Cloning Ubuntu Hardy image in VMWare Fusion

Posted by Jamis on August 15, 2008 @ 04:50 PM

Having spent the better part of a day googling and struggling, I figured it would possibly benefit others if I took a minute to post the steps I took to clone a VMWare Fusion image. The image in question is of Ubuntu Server (Hardy). I’m using VMWare Fusion 2 (beta 2).

Just find your “Virtual Machines” folder (should be in your Documents folder), and copy the image in question to a new location. (The images are actually folders; a simple “cp -R” worked fine for me.)

Then, open the copied image in VMWare Fusion and boot it. VMWare Fusion will ask if you if you copied or moved the image—be sure to say you copied it (that let’s VMWare set up a new MAC address for your image).

Go ahead and log in once the server boots. You’ll find networking is all hosed. To fix networking, this worked for me:

  • “sudo hostname blah”, to set the hostname. This doesn’t change it permanently, so you’ll also want to:
  • “sudo vim /etc/hostname”. Change the contents of the file to the hostname you want. Then:
  • “sudo vim /etc/hosts”. Replace all mentions of the old hostname with the new hostname.
  • “sudo vim /etc/udev/rules.d/70-persistent-net.rules”. There will be two entries in this file. The first points eth0 at the old MAC address, and the second points eth1 at the new. Go ahead and delete the first entry, and change “eth1” to “eth0” in the second (and now only) entry.
  • “sudo shutdown -r now” to restart your virtual machine.

Once your machine comes back up, you should have a network again! Now, if only VMWare Fusion could bake all this in somehow… :/

(Related: installing VMWare Tools on Ubuntu server. It’s from 2006, but it still worked well enough for me, though I followed the instructions for tweaking the network that the VMWare Tools install gave at the end, rather than what this gent said.)

Posted in Tips & Tricks

Comments

Have something to add? Click here to leave a comment.

16 Aug 2008

1. Patrick Gundlach said...

You can assign a static MAC address to the machine, then you can copy and move the virtual machine around and still have network access.

If you don’t assign a static MAC address or you say ‘I’ve copied it’, sudo dhclient should be enough to get network access again.

Patrick

19 Aug 2008

2. Jamis said...

Thanks, Patrick, I’ll try dhclient next time and see if that does it for me. A static MAC won’t, though, because I want to clone the image so I can have multiple running at once. (I’m trying to mimic a cluster of machines for local capistrano testing and training.)

09 Sep 2008

3. Andy said...

I’m using DHCP and copying a Ubuntu 8.04 image and ran across the same problem. Thanks for refreshing my memory on where all the network settings are located! What did we do before the internet and a search engine to solve problems like this?

4. Jim Wylder said...

I tend to blame Ubuntu on this one. Shouldn’t a Linux Server Distribution be able to handle its mac address changing without losing network connectivity?

01 Oct 2008

5. mlarkypants@hotmail.com said...

This method is not straight forward as put forward I believe as most systems will just come back with unable to resolve host once a change has been made, this will prevent further changes of any kind being made to the system.

16 Oct 2008

6. carlo said...

Anyone tried this one?

UBUNTU VMWARE IMAGES

http://chrysaor.info/?page=images

24 Oct 2008

7. Pelle Braendgaard said...

You can also just remove the ATTR{address}==”...” section completely and it should theoretically work every time you copy it without problems.

SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?”, ATTR{type}==”1”, KERNEL==”eth”, NAME=”eth0”

09 Nov 2008

8. scott@thereisnoarizona.org said...

You should be able to remove the /etc/udev/rules.d/70-persistent-net.rules file and reboot. It will be rebuilt on reboot with the detected MAC addresses/devices. Delete the existing file, shutdown, then make the copy.