Sunday, April 27, 2008

Virtualbox - Clone virtual machine ubuntu hardy

Hi again! Today I will write the second Virtualbox tutorial: Cloning Virtual Machines.

What we need is having a virtual machine already set up, with its virtual hard-drive and configuration file, i.e., a virtual machine fully operative, which will be the one to clone.

To clone a virtual machine, from a previous installation, we cannot do that by simply copying the virtual disk. If we copy the disk we will not be able to run the virtual machine aside the original VM, because each virtual disk has a unique ID.



So for cloining we have to use the tool provided by Virtualbox, which is "VBoxManage". We open the console, "cd" the virtual disks directory (the folder containing .vdi files) and if our VM is called UbuntuJEOS, it is logical the disk has the same name: UbuntuJEOS.vdi. Let's say we want the cloned virtual machine to be called UbuntuClient01. Therefore, we type the following:

VBoxManage clonevdi UbuntuJEOS.vdi UbuntuClient01.vdi

Once we have done that, we already have our VM cloned and ready to use!. We only should go to virtualbox and create a new VM, configure it with the virtual hard drive just created.

Troubleshooting:

We have no network, the network devices are scrambled or are missing.

This is due to the systems based on Debian, such as Ubuntu, have a very useful feature when we use actual hardware, but it is not that good when we clone VM. This feature assign a unique name to a network interface with a specific MAC address.
Debian, and therefore Ubuntu, make this by using UDEV rules, so as to solve it, simply we delete the rule created in the cloned machine for the original network interface:

sudo rm /etc/udev/rules.d/70-persistent-net.rules

Reboot and voilà! There is network again!

1 comments:

Subrata said...

Great one!!!!! Specially solution of the network problem.