Deploying a linked-clone VM
search cancel

Deploying a linked-clone VM

book

Article ID: 382880

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

How to deploy a linked-clone VM with vCenter with PowerCLI

Environment

Creating linked clones VM that are not used in Horizon, VMware Workstation or Fusion

Cause

There is no option to create a linked-clone VM through the vCenter UI. The only option is to use PowerCLI.

Resolution

Please create a snapshot of the source VM that the linked clone will be deployed from. Make note of the snapshot name, it will be needed.

Connect to vCenter through Powershell

  1. Connect-VIServer “vCenter FQDN or IP”
    • Login with an account that has the appropriate role to create VMs
  2. $mySourceVM = Get-VM -Name MySourceVM1
    • Provide the name of the source VM that will be used for the linked-clone VM
  3. $myReferenceSnapshot = Get-Snapshot -VM $mySourceVM -Name "SNAPSHOTNAME”
    • enter the name of the snapshot that was created for the source VM
  4. $vmhost = Get-VMHost -Name ESXiHOSTNAME
    • Name of the ESXi host you want the linked-clone to be registered to
  5. $myDatastore = Get-Datastore -Name DatastoreName
    • Name of the location you want the linked-clone to be stored at.
  6. New-VM -Name MyLinkedCloneVM1 -VM $mySourceVM -LinkedClone -ReferenceSnapshot $myReferenceSnapshot -ResourcePool $vmhost -Datastore $myDatastore
    • The command will deploy the linked-clone VM using the information provided in Steps 2-5

Additional Information

Installing VMware PowerCLI

VMware PowerCLI Documenation

 

Please note:

  • Deleting the snapshot of the source VM or doing a storage vMotion of the source VM that the linked clones are based off of will not affect the linked clone VM. The linked clone VM disk descriptor file (vmdk) will have a line entry that will point to the source VM (Parent) vmdk file. The storage vMotion of the source VM will leave a copy of the source VM disk.
  • When doing a storage vMotion of the source VM to a new datastore, there will be a copy of the source VM's vmdk file left on the source datastore because of an active linked clone VM. Deletion of that vmdk from the source datastore will results in the linked clone VM no longer being able to power on and the deletion of the linked clone VM will fail saying the “file not found”.
  • Deleting the source VM will not delete all the files if there is a linked clone VM deployed. The source VM vmdk file will be left over since there is a linked clone VM deployed that is referencing it. Deleting all the linked clone VM that was deployed from the source VM will remove the source vmdk file from the datastore.