KVM -HowTo move or copy a VM from Host to onther Host
To transfer a KVM virtual machine (VM) from one host to another, you can follow the steps below:
- Make sure you have the same version of KVM on both hosts. You can verify this by running the kvm –version command.
- Stop the VM you want to transfer. You can do this using the command virsh shutdown vm_name.
- Export the VM definition XML to the old host using the command virsh dumpxml vm_name > file_name.xml.
- Check where the VM files are stored. You can do this using the command virsh domblklist vm_name.
- Copy the VM files from the old host to the new host, including the xml definition file. You can use the scp command to do this.
- Check the contents of the VM xml definition file to correct the physical path of where the disk files are physically and correct the network
- adapter names if necessary.
- Import the VM to the new host using the command virsh define /path/to/vm_xml_file.
- Start the VM on the new host using the virsh start vm_name command.
Make sure you have properly configured networking and storage on the new host so that the VM can work properly. Also, if you’ve been using pass-through virtualization for your devices, make sure you’re configuring those on the new host correctly as well.
A lot of useful information on how to manage KVM virtualization systems can also be found on the blog: https://frontpagelinux.com/tutorials/getting-started-with-kvm-hypervisor-virtual-machines-the-right-way/