A Linux Playground

My doodles and what I get up to.

Move Location of Kvm Virtual Machine

I recently rearraged the contents on a multidisk server to create a large partition that is not encrypted. It turns out that my CPU does not support the aes instruction set causing slow disk speeds. As I am running many kvm virtual machines I decided to remove their disk-io from the encrypted parts to improve overall performance.

Searching the web on how to relocate the location of a virtual kvm instance, I found that there are no how tos or guides. After some tinkering I found that this could be achieved in the following way.

Instructions.

First off shutdown the virtual machine. This is so that when you copy it’s virtual drive/s to their new home they won’t be changing.

Second move the img/qcow/raw files to their new home. Ensure that they have the same permissions and that any directories above allow ‘libvirt-qemu’ to enter and read as necessary.

Next edit the instances xml file that contains the information about the server. This is located at ‘/etc/libvirt/qemu/SERVERNAME.xml’. Change SERVERNAME as appropriate. The line that your need to change is

1
  <source file='/media/primary/kvm/util.img'/>

to where the new file is located.

Lastly restart the libvirt deamon.

1
sudo service libvirt-bin restart