The cloning of a KVM virtual machine is divided into two cases, the first KVM host on the virtual machine directly cloned
The second replication clone (for a static migration of a different machine)by copying a configuration file to a virtual machine with a disk file.
Now I will separate the two KVM virtual machine cloning of the detailed operation process are recorded as follows:
Method One: Direct cloning of virtual machines on the KVM host (requires operation in a shutdown or paused state)
1. View the location of all virtual machines, as well as the hard disk files of the virtual machines that need to be cloned.
[[Email PROTECTED]_KVM ~]# virsh list--all // View all installed KVM virtual machines
2. We can find the disk file location by editing the source virtual machine configuration file that needs to be cloned, the command is as follows:
[[Email PROTECTED]_KVM ~]# virsh edit kvm_client00 // View the location of their hard disk files by editing the virtual machine's configuration file
The location of the disk file can be seen by the following:
<source file= '/var/lib/libvirt/images/kvm_client00.img'/>
3. Start cloning, clone the kvm_client00 virtual machine into a new virtual machine kvm_client01, the new virtual machine's disk file is/var/lib/libvirt/images/kvm_client01.img
[Email PROTECTED]_KVM ~]# virt-clone-o kvm_client00-n kvm_client01-f/var/lib/libvirt/images/kvm_client01.img
4, cloning is over, we can see through the Virsh list--all, if you need to delete the cloned virtual machine, we only need to execute the following command.
[[Email PROTECTED]_KVM ~]# virsh undefine kvm_client01 // the command simply deletes the wintest01 configuration file and does not delete the Vdisk file
Method Two: Copy the configuration file to the disk file for cloning (you can not shut down the source virtual machine)
1, here we still clone kvm_client00, we create a new virtual machine configuration file with the following command
[Email PROTECTED]_KVM ~]# virsh dumpxml kvm_client00 >/etc/libvirt/qemu/kvm_client02.xml // Create a configuration file for a new virtual machine
2, copy the original virtual machine disk file, through method One, we know that the default location of the disk is/var/lib/libvirt/images, we execute the following command to copy
[Email PROTECTED]_KVM ~]# cd/var/lib/libvirt/cp kvm_client00.img kvm_client02.img
3, directly edit modify configuration file Kvm_client02.xml, modify the name,uuid,disk file location, MAC address, VNC Port
4, through the new virtual machine configuration file, define a new virtual machine, only need to execute one of the following commands.
[[Email PROTECTED]_KVM ~]# virsh define/etc/libvirt/qemu/kvm_client02.xml // define a new KVM virtual machine via config file ]
In particular, the two methods of cloning virtual machines, we all need to enter the clone of the new virtual machine
Modify the NIC device file /etc/udev/rules.d/70-persistent-net.rules, or delete it directly, and then restart the cloned destination virtual machine
Respect for the work of others reproduced please be sure to indicate the source: http://www.cnblogs.com/5201351/p/4461000.html
A summary of cloning methods for KVM virtual machines