Clone a Ubuntu Virtual Machine Image

Sat 09 April 2011 by Lance Jian in Linux.

I recently created a Ubuntu server virtual machine image in kvm and wanted to clone it so that I don't need to install everything from scratch again. It turned out this is fairly easy.

This works for any virtual machine program including Vmware, VirtualBox, etc.

First, copy the image file and create a new virtual machine from it. Next, start and log in the "new" machine.

Now, remove 70-persistent-net.rules, otherwise the network will not work:

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

This file will be re-generated after a reboot.

Next, change the hostname in /etc/hostname and /etc/hosts according to your preference.

Finally, reboot and enjoy using the new virtual machine.

See also: Cloning Ubuntu 10.04 Server KVM guests efficiently