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:
-
su vbox
-
VBoxManage clonevm original_vm_name --name new_vm_name --register
-
VBoxManage controlvm original_vm_name poweroff
(or face the consequences) -
VBoxManage startvm new_vm_name
-
Use Remote Desktop to login to the console of the new VM.
-
sudo pico /etc/udev/rules.d/70-persistent-net.rules
- use your favourite editor of course -
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"
-
You should be left with one device entry. Edit the
NAME
section so it matches the Virtualbox VM configuration; probably like thisNAME="eth0"
-
sudo pico /etc/network/interfaces
-
Make sure your device settings are correct and that the name (
eth0
for example) matches the hardware file you just edited. -
sudo reboot
-
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
.
- Thanks to TerryE of the Virtualbox user forums for this fix https://forums.virtualbox.org/viewtopic.php?t=7749