Example 1¶
This allows you to name the image file.
sudo virt-clone --original [ original_instance ] --name [ new_instance ] --auto-clone --file /var/lib/libvirt/images/[ new_instance ].qcow2
If you have multiple disks¶
virt-clone --original [ old_instance ] --name [ new_instance ] --file /var/lib/libvirt/images/[ new_disk0 ].img --file [ new_disk1]-1.img --connect=qemu:///system --force
Example 2¶
This will auto-generate an image name.
virt-clone --original [ old_instance_name ] --name [ new_instance_name ] --auto-clone
Caveats¶
The SSH keys on the cloned vm's will be identical to the keys on the original vm so you'll need to regenerate those:
sudo rm -f /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server
Troubleshooting¶
You might have a problem with udev renaming eth0 to eth1, i.e., you get the following error:
udev renamed network interface eth0 to eth1
sudo vi /etc/udev/rules.d/70-persistent-net.rules
delete the eth0 line - rename all instances of eth1 to eth0 reboot.