LinuxCommandLibrary

vboxmanage-clonevm

Clone existing VirtualBox virtual machines

TLDR

Clone the specified VM

$ VBoxManage clonevm [vm_name]
copy

Specify a new name for the new VM
$ VBoxManage clonevm [vm_name] --name [new_vm_name]
copy

Indicate the folder where the new VM configuration is saved
$ VBoxManage clonevm [vm_name] --basefolder [path/to/directory]
copy

Register the cloned VM in VirtualBox
$ VBoxManage clonevm [vm_name] --register
copy

SYNOPSIS

VBoxManage clonevm <source_vm_uuid|source_vm_name> --name <new_vm_name> [
  --groups <group1>[,<group2>...] ] [
  --basefolder <path> ] [
  --snapshot <snapshot_uuid|snapshot_name> ] [
  --mode <mode> ] [
  --options <option1>[,<option2>...] ] [
  --uuid <new_vm_uuid> ] [
  --register ]

<mode>: all | machine (default: all)
<option>: link | full (default: full), keepnatmacs, keepdisknames, keephwuuids, keepinputoutputcache

PARAMETERS

<source_vm_uuid|source_vm_name>
    The UUID or name of the virtual machine to be cloned.

--name <new_vm_name>
    Specifies the name for the new cloned virtual machine. This is a mandatory option.

--groups <group1>[,<group2>...]
    Assigns the new VM to one or more VirtualBox groups, separated by commas.

--basefolder <path>
    Sets the path to the directory where the new VM's configuration and disk files will be stored. If omitted, VirtualBox's default VM folder is used.

--snapshot <snapshot_uuid|snapshot_name>
    Clones the VM from a specific snapshot, rather than its current state. Useful for restoring a previous state as a new VM.

--mode <mode>
    Defines what components of the VM are cloned. all clones the machine and all attached storage. machine clones only the machine configuration without disk images. Default is all.

--options <option1>[,<option2>...]
    Controls specific aspects of the cloning process. Key options include:
  - link: Creates a linked clone (shares base disk, default is full).
  - full: Creates a full clone (independent copy).
  - keepnatmacs: Retains the original MAC addresses for NAT network adapters.
  - keepdisknames: Retains the original disk attachment names.
  - keephwuuids: Retains the original hardware UUIDs (generally not recommended).
  - keepinputoutputcache: Retains the original I/O cache settings.

--uuid <new_vm_uuid>
    Specifies a custom UUID for the new cloned VM. If not provided, VirtualBox generates a new unique UUID.

--register
    Registers the new cloned VM with VirtualBox (this is the default behavior).

DESCRIPTION

The VBoxManage clonevm subcommand is a powerful utility within Oracle VM VirtualBox that enables users to create duplicates of existing virtual machines. This functionality is crucial for various use cases, including creating test environments, backing up VMs before major changes, distributing pre-configured systems, or quickly deploying multiple identical instances. It supports two primary cloning modes:
full clones, which are independent copies including all disk images, and
linked clones, which share the original VM's disk image but store their own changes in a separate differencing image. The command provides flexibility to specify the new VM's name, UUID, location, and whether to clone from a specific snapshot.

CAVEATS

This command is a subcommand of VBoxManage, not a standalone executable.
Linked clones inherently depend on the original VM and its base disk image; deleting or moving the parent can break the clone.
Full clones require significant disk space equal to the original VM's storage.
Be mindful of duplicate network MAC addresses and hardware UUIDs when creating multiple clones, as this can lead to network conflicts or licensing issues for some software. The --keepnatmacs and --keephwuuids options control this behavior.

FULL VS. LINKED CLONES

Full clones are entirely independent copies, including all disk images, and can operate without the original VM. They consume more disk space but offer maximum portability.
Linked clones share the original VM's base disk image and store only their changes in a new differencing disk. They consume less disk space but require the parent VM and its base disk to be present and unchanged for the clone to function.

UUID AND MAC ADDRESS HANDLING

By default, VBoxManage clonevm generates new UUIDs and MAC addresses for the cloned VM. This is generally recommended to prevent conflicts on the network or with software licenses. However, specific options like --keepnatmacs and --keephwuuids allow retaining the original values for NAT network interfaces and the hardware UUID respectively, which might be necessary in specific scenarios but should be used with caution.

HISTORY

The clonevm feature has been an integral part of Oracle VM VirtualBox's VBoxManage command-line interface since its early versions. It evolved alongside the product, offering more granular control with options like linked/full cloning, snapshot-based cloning, and handling of various hardware identifiers as VirtualBox matured and its user base grew, making VM management more flexible and automated for developers and system administrators.

SEE ALSO

VBoxManage(1), VBoxManage createvm(1), VBoxManage import(1), VBoxManage export(1), VBoxManage snapshot(1)

Copied to clipboard