virtualization


Ubuntu 11.10 (Oneiric Ocelot): Cloning a KVM Virtual Machine

After properly installing and creating your first virtual machine, you might want to create a clone for some reason.

To do this we use the command virt-clone as follows:

sudo virt-clone --connect qemu:///system -o coeus -n phoebe -f /home/kvm/2KA.qcow2 -f /home/kvm/zK6.qcow2 --force

Where:

  • –connect is used to connect to the hypervisor of the virtual machine, here it is system
  • -o is the original virtual machine name (which is registered with the previous hypervisor)
  • -n is the name of the new virtual machine, the clone (this name will be used to register the clone to the hypervisor)
  • -f the location that the clone will use to store it’s virtual hard drives, can be used as many times as needed (in the above example coeus has two hard disks and that is why we need to provide two -f paramaters)
  • –force prevents interactive prompts and replies ‘yes’ to all yes/no questions

There is more directives that can be provided to the clone manager from which a very important one is the: –mac where you get to define the mac address of the new virtual machine (e.g –mac C0:FF:EE:11:00:11)


Ubuntu 11.10 (Oneiric Ocelot): Installing KVM 2

Without any additional comments, we managed to install KVM over a fresh installation of Ubuntu 11.10 (Oneiric Ocelot).

To do this we installed the following packages from the repositories and added our user to the libvirtd group.

We called kvm-ok to make sure that our hardware supports KVM properly and thus having better performance.
Installation Commands:

sudo apt-get install kvm libvirt-bin
sudo adduser $USER libvirtd
sudo apt-get install virt-viewer
sudo apt-get install python-vm-builder
sudo apt-get install bridge-utils
sudo apt-get install virtinst #for cloning

After these we created a virtual machine with the following command:

sudo vmbuilder kvm ubuntu --suite oneiric --flavour virtual --arch amd64 --mem 1024 --cpus 2 -o --libvirt qemu:///system --ip 192.168.0.100 --hostname uranus --part vmbuilder.partition --user userName --name MyName MySurname --pass myPassword --addpkg unattended-upgrades --addpkg acpid --addpkg nano

where in general, what it does is, create an Ubuntu Oneiric Ocelot JeOS virtual machine that has an AMD64 architecture, 1GB of RAM, 2 Virtual CPUs, it’s name is uranus, has a user with the username userName, has pre-installed some applications like nano and enabled automatic updates for the system.