virt-clone
Clone libvirt virtual machines
TLDR
SYNOPSIS
virt-clone [options]
DESCRIPTION
virt-clone creates a copy of an existing libvirt virtual machine. It clones the VM configuration and can duplicate or create new disk images, generating unique identifiers for the clone.The tool handles creating new UUIDs, MAC addresses, and storage paths to avoid conflicts with the original VM. It is commonly used for creating test environments or deploying multiple similar VMs. Disks marked as readonly or shareable are skipped by default unless --force-copy is used.
PARAMETERS
-o, --original name
Name of the original VM to clone (must be shut off).--original-xml file
Libvirt guest XML file to use as the original guest.-n, --name name
Name for the new cloned VM.--auto-clone
Automatically generate new name, storage, and MAC.-f, --file path
Path for the new disk image. Repeat for multi-disk guests.-m, --mac address
MAC address for the new VM (or RANDOM).-u, --uuid uuid
UUID for the new guest (default: randomly generated).--preserve-data
Do not clone storage; preserve disk images and reference them.--reflink
Use copy-on-write reflinks if the filesystem supports it.--nonsparse
Fully allocate new storage instead of creating sparse files.--force-copy target
Force cloning of the specified disk target (e.g. 'hdc', 'sda').--replace
Shut down and remove any existing guest with the target name.--print-xml
Print generated clone XML and exit without cloning.-c, --connect uri
Connect to specified hypervisor URI.-d, --debug
Print debugging information.
CAVEATS
Requires libvirt and an appropriate virtualization backend (KVM, QEMU, etc.). The original VM must be shut off for a consistent clone. Cloning large disk images can take significant time and requires sufficient storage space. Use --nonsparse for full allocation if the filesystem does not support sparse files well.
SEE ALSO
virt-install(1), virsh(1), virt-manager(1)
