Skip to content

Instantly share code, notes, and snippets.

@dominicsayers
Last active December 12, 2015 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dominicsayers/4750840 to your computer and use it in GitHub Desktop.
Save dominicsayers/4750840 to your computer and use it in GitHub Desktop.
Cloning an Ubuntu guest machine in Virtualbox

Cloning an Ubuntu guest on Virtualbox

Cloning a VM is easy in theory but if you don't set up networking properly in the newly cloned machine it can kill all networking on the host.

In particular, Virtualbox gives your cloned machine a new NIC with a new MAC code. This is probably what you want since you don't want multiple machines on your network with the same MAC address. But Ubuntu still has the NIC from the original machine in one of its configuration files, so there's a clash between the hardware created by Virtualbox and the Ubuntu VM's own view of the world.*

Simple but tedious to fix. Here goes, on the Virtualbox host machine:

  1. su vbox

  2. VBoxManage clonevm original_vm_name --name new_vm_name --register

  3. VBoxManage controlvm original_vm_name poweroff (or face the consequences)

  4. VBoxManage startvm new_vm_name

  5. Use Remote Desktop to login to the console of the new VM.

  6. sudo pico /etc/udev/rules.d/70-persistent-net.rules - use your favourite editor of course

  7. There will be two entries in this file looking like below. Remove the first entry that was left there by the original VM (the top two lines in the example below).

    # PCI device 0x1022:0x2000 (pcnet32) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:12:34:56", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" # PCI device 0x1022:0x2000 (pcnet32) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:23:45:67", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

  8. You should be left with one device entry. Edit the NAME section so it matches the Virtualbox VM configuration; probably like this NAME="eth0"

  9. sudo pico /etc/network/interfaces

  10. Make sure your device settings are correct and that the name (eth0 for example) matches the hardware file you just edited.

  11. sudo reboot

  12. When the machine has rebooted it may have working networking. If so, hurrah! If not, I've sometimes needed to restart networking after the firt reboot with sudo /etc/init.d/networking restart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment