VIRT-CLONE(1)
VIRT-CLONE(1) π
okay bestie, welcome to the Virtualization Support corner of the manual, where we talk about virt-clone β¨
πΈ NAME πΈ
virt-clone β clone existing virtual machine images π¦
β¨ SYNOPSIS β¨
virt-clone [OPTION]...
π DESCRIPTION π
So virt-clone is a command line tool for cloning existing virtual machine images, and it does that using the libvirt hypervisor management library. It will copy the disk images of any existing virtual machine, and define a new guest with an identical virtual hardware configuration. The elements that need to be unique get updated so old guest and new guest don't clash, periodt π
By default, virt-clone will show an error if the necessary information to clone the guest is not provided. But the --auto-clone option will generate all needed input, aside from the source guest to clone. iconic behaviour honestly π
Please note,virt-clonedoes not change anything _inside_ the guest OS β it only duplicates disks and does host side changes. So things like changing passwords, changing static IP address, etc are outside the scope of this tool π For these types of changes, please seevirt-sysprep.
π«Ά GENERAL OPTIONS π«Ά
Most options are not required. Minimum requirements are --original or --original-xml (to specify the guest to clone), --name, and appropriate storage options via -file π
--connect URIβ connect to a non-default hypervisor. Seevirt-install(1)for details π«-o,--original ORIGINAL_GUESTβ name of the original guest to be cloned. This guest must be shut off π--original-xml ORIGINAL_XMLβ libvirt guest xml file to use as the original guest. The guest does not need to be defined on the libvirt connection. This takes the place of the--originalparameter πΈ--auto-cloneβ generate a new guest name, and paths for new storage β¨
An example of possible generated output:
Original name : MyVM
Generated clone name : MyVM-clone
Original disk path : /home/user/foobar.img
Generated disk path : /home/user/foobar-clone.img
If generated names collide with existing VMs or storage, a number is appended, such as foobar-clone-1.img, or MyVM-clone-3 π’
-n,--name NAMEβ name of the new guest virtual machine instance. This must be unique amongst all guests known to the hypervisor connection, including those not currently active π-u,--uuid UUIDβ UUID for the guest; if none is given a random UUID will be generated. If you specify UUID, you should use a 32-digit hexadecimal number. UUID are intended to be unique across the entire data center, and indeed world π Bear this in mind if manually specifying a UUID π-f,--file PATHβ path to the file, disk partition, or logical volume to use as the backing store for the new guest's virtual disk. If the original guest has multiple disks, this parameter must be repeated multiple times, once per disk in the original virtual machine πΎ--nvram NVRAMFILEβ optional path to the new nvram VARS file. If no path is specified and the guest has nvram, the new nvram path will be auto-generated. If the guest doesn't have nvram this option will be ignored π§--force-copy TARGETβ force cloning the passed disk target ('hdc','sda', etc.). By default,virt-clonewill skip certain disks, such as those marked'readonly'or'shareable'π₯--skip-copy TARGETβ skip cloning the passed disk target ('hdc','sda', etc.). By default,virt-clonewill clone certain disk images, typically read/write devices. Use this to skip copying of a specific device, so the new VM uses the same storage path as the original VM π«--nonsparseβ fully allocate the new storage if the path being cloned is a sparse file. Seevirt-install(1)for more details on sparse vs. nonsparse π--preserve-dataβ no storage is cloned: disk images specified by--fileare preserved as is, and referenced in the new clone XML. This is useful if you want to clone a VM XML template, but not the storage contents π--reflinkβ perform a lightweight copy. This is much faster if source images and destination images are all on the samebtrfsfilesystem. This only works for raw format disk images, any non-raw images will not attempt to use refink β‘-m,--mac MACβ fixed MAC address for the guest; if this parameter is omitted, or the valueRANDOMis specified, a suitable address will be randomly generated. Addresses are applied sequentially to the networks as they are listed in the original guest XML π--print-xmlβ print the generated clone XML and exit without cloning π--replaceβ before cloning, try a simplevirsh destroyandvirsh undefineon any existing VM with the passed--name. If those operations fail (like whenvirsh undefinerequires--nvramflag), the clone will fail and you will need to manually remove the existing VM π-h,--helpβ show the help message and exit π--versionβ show program's version number and exit π·οΈ--checkβ enable or disable some validation checks. Seevirt-install(1)for more details β-q,--quietβ suppress non-error output π€«-d,--debugβ print debugging information to the terminal when running the install process. The debugging information is also stored in~/.cache/virt-manager/virt-clone.logeven if this parameter is omitted π
π EXAMPLES π
Clone the guest called demo on the default connection, auto generating a new name and disk clone path π¦
# virt-clone \
--original demo \
--auto-clone
Clone the guest called demo which has a single disk to copy πΏ
# virt-clone \
--original demo \
--name newdemo \
--file /var/lib/xen/images/newdemo.img
Clone a QEMU guest with multiple disks ποΈ
# virt-clone \
--connect qemu:///system \
--original demo \
--name newdemo \
--file /var/lib/xen/images/newdemo.img \
--file /var/lib/xen/images/newdata.img
Clone a guest to a physical device which is at least as big as the original guests disks. If the destination device is bigger, the new guest can do a filesystem resize when it boots πͺ
# virt-clone \
--connect qemu:///system \
--original demo \
--name newdemo \
--file /dev/HostVG/DemoVM \
--mac 52:54:00:34:11:54
π BUGS π
Please see <https://virt-manager.org/bugs> β go tell them everything bestie, they wanna know π
π COPYRIGHT π
Copyright (C) Fujitsu Limited, Copyright (C) Red Hat, Inc, and various contributors. This is free software. You may redistribute copies of it under the terms of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law β οΈ
π SEE ALSO π
virt-sysprep(1), virsh(1), virt-install(1), virt-manager(1), the project website <https://virt-manager.org> π
and that's the whole page, no cap π«Ά this was Virtualization Support's virt-clone(1) β thanks for reading bestie, go clone something cute, mwah ππβ¨
π¦ where this page comes from
- alpine 3.24: virt-manager-doc 5.1.0-r0 Β· GPL-2.0-or-later
- debian trixie: virt-install 1:5.0.0-5+deb13u1 Β· GPL-2.0-or-later
- fedora 43: virt-install 5.1.0-2.fc43 Β· GPL-2.0-or-later
- fedora 43: virt-install 5.1.0-3.fc43 Β· GPL-2.0-or-later
- opensuse-leap 16.0: virt-install 5.0.0-160000.4.1 Β· GPL-2.0-or-later
- ubuntu resolute: virt-install 1:5.1.0-1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms