Linked clone VirtualMachines share their base disks with their parent virtual machine. Only changes (delta) are stored in the childs virtual disks. These results in two major benefits:

  • Fast Provisioning time
  • Space savings

 

However, linked clones have some limitations:

  • Diskspace cannot be adjusted
  • Performance impact – Depending on storage cache

The following PowerCLI snippets will promote all virtual disks or a specific virtual disk of a linked clone to a full clone.

 

Prerequisites:

  • Linked Clone – PoweredOff or Suspended state
  • Enough free space on the Virtual Machine homedirectory
  • vCenter Server

The vSphere SDK allows the promotion of the disks. So here is the link to the promoteDisks method documentation

http://pubs.vmware.com/vsphere-55/topic/com.vmware.wssdk.apiref.doc/vim.VirtualMachine.html#promoteDisks

PowerCli lets you access SDK Methods using the get-view Cmdlet or extensiondata property.

1. Check method on VM Object.

#List availabe methods on VM View object:
$BaseVM.ExtensionData | gm -MemberType method
..
PromoteDisks
..

2. Create Linked clone based on snapshot “SnapBase” on source VM

#Create reference snapshot for linked clone
$BaseSnapshot = Get-Snapshot -vm $BaseVM -Name SnapBase
$LinkedVM = New-VM -Name HotzenplotzLC -LinkedClone -ReferenceSnapshot $BaseSnapshot -vm $BaseVM -VMHost $BaseVM.VMHost
$Disks = $LinkedVM | get-Harddisk

2a. Promote all disks

# Verify current Backing
$Disks[0].extensiondata.backing.Parent.Filename
...
FileName : [DS] Hotzenplotz/Hotzenplotz.vmdk
...
# Promote all disks
$LinkedVM.ExtensionData.PromoteDisks($true, $null);
$Disks = $LinkedVM| Get-Harddisk
$Disks[0].extensiondata.backing.Parent.Filename
# no parent disk anymore

2b. Promote individual disks:

# List Individual disk keys:
$Disks | % { $_.extensiondata.Key }
2000
2001
#datadisk
$Disk = $disks | ?{ $_.extensiondata.key -eq '2001'}
$LinkedVM.ExtensionData.PromoteDisks($true, $disk.extensionData );

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.