LinuxCommandLibrary

qm-clone

Clone virtual machines and containers

TLDR

Copy a virtual machine

$ qm clone [vm_id] [new_vm_id]
copy

Copy a virtual machine using a specific name
$ qm clone [vm_id] [new_vm_id] --name [name]
copy

Copy a virtual machine using a specific descriptionn
$ qm clone [vm_id] [new_vm_id] --description [description]
copy

Copy a virtual machine creating a full copy of all disks
$ qm clone [vm_id] [new_vm_id] --full
copy

Copy a virtual machine using a specific format for file storage (requires --full)
$ qm clone [vm_id] [new_vm_id] --full --format [qcow2|raw|vmdk]
copy

Copy a virtual machine then add it to a specific pool
$ qm clone [vm_id] [new_vm_id] --pool [pool_name]
copy

SYNOPSIS

qm clone vmid newid [OPTIONS]

PARAMETERS

vmid
    The numeric ID of the existing virtual machine or container to clone.

newid
    The numeric ID to assign to the new virtual machine or container.

--full boolean
    If set to 'true', perform a full copy of all disk images, making the new VM/container independent. Defaults to 'false' (linked clone) if not specified.

--storage storage
    Specify the target storage where the new VM/container's disk images will be placed. If not specified, the original storage is used for full clones, or the same storage as the original for linked clones.

--name name
    Assign a human-readable name to the newly created virtual machine or container.

--description description
    Add an arbitrary descriptive text for the new VM/container.

--format format
    Specify the disk image format for the cloned disks (e.g., 'qcow2', 'raw', 'vmdk'). Applicable primarily for full clones.

--target-node node
    Specify the target Proxmox VE node where the new VM/container should be created. By default, it's created on the same node as the source VM/container.

--pool poolid
    Assign the new VM/container to a specific resource pool.

--bwlimit integer
    Limit the bandwidth for disk operations during the cloning process, specified in KB/s.

--snapname string
    Use a specific snapshot of the source VM/container as the basis for the clone instead of its current state.

DESCRIPTION

The qm-clone command in Proxmox VE is used to create a new virtual machine or container (LXC) by replicating an existing one. It allows for two main types of cloning:
full clones and linked clones. A full clone creates an independent, complete copy of all disk images, meaning the new VM/container is entirely separate from its source. A linked clone, on the other hand, creates a new VM/container that shares the original's base disk image, storing only changes in a new delta image (also known as a Copy-on-Write, or COW, clone). Linked clones save disk space and are faster to create but maintain a dependency on the original VM/container's disk images. This command is essential for quickly deploying multiple similar instances or setting up test environments based on pre-configured setups.

CAVEATS

When using linked clones (the default behavior if `--full` is not specified), the cloned VM/container is dependent on the original VM/container's base disk image. If the original VM/container or its base disk is deleted, moved, or corrupted, the linked clone will become unusable. For production environments or completely independent instances, full clones are generally recommended.

CLONING TYPES

There are two main types of cloning:
Full Clone: Creates a complete, independent copy of the VM's disk. This takes longer and consumes more disk space but ensures the new VM has no dependency on the original. Use --full 1 for this type.
Linked Clone: Creates a Copy-on-Write (CoW) snapshot. The new VM shares the base disk with the original, only storing changes. This is much faster and saves disk space but creates a dependency. This is the default behavior if --full is not specified.

COMMON USAGE

A common use case for qm-clone is to create a 'template' VM or container. Once a base operating system installation is configured, it can be rapidly deployed into new instances by cloning it multiple times for different services or development environments, significantly reducing setup time.

HISTORY

The qm-clone command is an integral part of the Proxmox VE command-line interface (CLI), specifically designed to manage QEMU/KVM virtual machines. Proxmox VE, an open-source server virtualization management solution, has continually evolved its CLI tools since its inception in 2007. The cloning functionality has been a core feature, reflecting the need for rapid deployment and efficient resource utilization in virtualized environments. It abstracts the underlying QEMU/KVM and various storage backends (like LVM, ZFS, Ceph) operations, providing a user-friendly way to replicate virtual instances.

SEE ALSO

qm(1), pct(1), qm-create(1), qm-start(1), qm-snapshot(1)

Copied to clipboard