VMmanager: Administrator guide

Linked clones

Managing linked clones is only available in the VMmanager Infrastructure version.

Linked clones are virtual machines (VMs) that are created from a single user image and share a common virtual disk. The use of linked clones is effective when creating a large number of similar VMs with few changes to the file system. For example, when creating virtual desktops.

The backing chain technology of libvirt software is used to create linked clones. A linked clone consists of a primary and a base disk. All changes to the VM's file space are written to the primary disk. The base disk is a read-only image in Qcow2 format. Multiple linked clones can use the same base disk.

Scheme of operation of linked clones

Features of linked clones

Advantages

The advantages of linked clones are:

  • saving disk space;
  • high speed of creation;
  • high speed of group migration;
  • high efficiency when using disk oversizing.

The advantages are achieved due to the fact that multiple VMs use the same base disk and the primary disk contains only differences from the base disk.

Disadvantages

Due to the fact that the base disk of a clone is used in parallel by multiple VMs, the performance of linked clones is lower than that of regular VMs.

Restrictions

Creating linked clones is only available in KVM virtualization clusters that use file storage or NAS.

The operation of a linked clone depends on the availability of the source image. The source image cannot be deleted if clones based on it exist in the platform. If an image is on NAS storage, linked clones for that image can only be created on the same NAS storage.

The linked clone is not supported:

  • resizing the primary disk;
  • changing the primary disk;
  • migration of the primary disk;
  • changing the boot order of disks;
  • cloning;
  • creating images;
  • reinstalling OS;
  • mounting and unmounting ISO images.

When the linked clone is backed up, the VM will be rebooted.

When the cluster node is put into maintenance mode, cold migration of linked clones will be performed — with possible VM shutdown.

Linked clones cannot be migrated by the balancer.

How linked clones work

When creating the first linked clone, the original image is copied to the cluster storage and unpacked. Unpacking converts the image to the Qcow2 format. This image is used as the base disk for all linked clones.

The files for the base disk operation are stored in the /linked_clone_base subdirectory of the VM's disk storage directory. The subdirectory contains:

  • file of the base disk — img.{image_name}.extracted;
  • file with checksum of the base disk — img.{image_name}.extracted.chksum;
  • marker files to logically link the base disk to the main disk — img.{image_name}.extracted.{primary_disk_name}.link. If there are no marker files, then the base disk is not being used by the linked clones.

When deleting linked clones, the base disk file remains in storage. By default, the file will be stored for 48 hours. After this period, if no new clones have been created based on the image, nodewatch service will delete the file.

You can change the storage time of an unused base disk through the API. To do this:

  1. Get the token authorization:

    curl -k -X POST -H "accept: application/json" -H "Content-Type: application/json" 'https://domain.com/auth/v4/public/token' -d '{"email": "admin_email", "password": "admin_pass"}'
    Comments to the command

    In response, you will get the message in the form:

    Example of response in JSON
    {
      "confirmed": true,
      "expires_at": null,
      "id": "6",
      "token": "4-e9726dd9-61d9-2940-add3-914851d2cb8a"
    }

    Save the received token value.

  2. Execute the command: 

    curl -k -H "x-xsrf-token: <token>" -X POST "https://domain.com/vm/v3/setting/unused_extracted_host_image_ttl_hours" -d '{"value":"<ttl>"}'
    Comments to the command

Migration of linked clones

When migrating a linked clone, both the VM disks and the source image file are migrated. The base disk is migrated first, followed by the primary disk. Disk only migration mode cannot be selected for a linked clone.

In most cases, it is recommended to perform cold migration of linked clones — with possible VM stopping. Live migration takes longer than cold migration. During live migration, VMs will lose the properties of linked clones — the primary disk will be merged with the base disk. If VMs have been backed up, it may not be possible to restore VMs from these backups after live migration.

Live migration of linked clones is recommended only for group migration of all linked clones from one NAS storage to another. In this case, VMs will not lose their linked clone properties.

Creating linked clones

To create a linked clone, enter Virtual machines → click Create a VMVM images tab → enable the create as linked clone option → specify the VM settings → click Create a VM.

Linked clones are displayed in the VM list with the icon.