In my previous article, I showed you how you can easily create your own SE Sparse (Space-Efficient) disks for you virtual machines running on vSphere 5.1. In addition to just creating new virtual disks using the new disk format, you can also create SE Sparse Linked Clones by leveraging the vSphere 5.1 API. I had previously shared a vSphere SDK for Perl sample script called that allows you to create your own Linked Clones and I have updated the script to now support the new SE Sparse disk format.

The script now includes new parameter called --convert which allows you to specify whether or not the destination Linked Clone should follow the same source virtual disk format or the new SE Sparse disk format. Remember to upgrade your VMs to the latest ESXi 5.1 compatibility and later (virtual hardware version 9) if you wish to leverage the new SE Sparse disk format. The way this is accomplished is by specifying a new disk backing  VirtualDiskFlatVer2BackingInfo in the VirtualMachineRelocateSpec and passing in the deltaDiskFormat to be of type seSparseFormat.

Disclaimer: This is for educational purposes only, this is not officially supported by VMware. Please test this in a development environment before using it on actual systems.

Note: Linked Clones is a feature of vCenter Server, make sure you are connecting to a vCenter Server 5.1

If you have a VM that has a VMDK that is NOT an SE Sparse disk format but wish to create Linked Clones with the new SE Sparse disk format, then you can use the --convert sesparse option, here is an example command:

./ --server --username root --vmname Regular-VM --vmname_destination Linkedclone-SeSparse-Destination --snapname pristine --vmhost --datastore datastore1 --convert sesparse

If you have a VM that has a VMDK that IS an SE Sparse disk format and you wish to create Linked Clones with the same disk format, then you can use the --convert source option, here is an example command:

./ --server --username root --vmname SeSparse-VM --vmname_destination Linkedclone-SeSparse-Destination --snapname pristine --vmhost --datastore datastore1 --convert source

If we head over to our vSphere Web Client and take a look at our new Linked Clones, we can confirm their virtual disks is using the new SE Sparse disk format.

9 thoughts on “Creating SE Sparse Linked Clones Using the vSphere 5.1 API

    • Great post William i was researching a lot about linked clones, and making it Flex-SE type is even better, however i’m wondering is it possible to “live-update” the snapshot in order to install new software or such? Or is it limited to destroy all linked clones and start from scratch…


  1. Thanks William – fantastic script. I just used it to build 100 VM’s for a test lab in approx 5mins

  2. Had some issues with ESXi 5.1, and VMs with multiple interfaces and disks, I hacked the script up a bit. My use is to generate a single linked clone, here are my (very poor) changes.. So far it would appear that it works. Any idea how I can lock the base image so deleting from disk via the vsphere client doesn’t delete the base?

    • The only way to prevent the base disk from being deleted is by powering it on to create a lock. The script you’re using is a “hacked” way of getting linked clones w/o vCenter Server. If you use the vSphere APIs to create Linked Clones, then you can delete the individual VMs w/o impacting the base VM.

  3. I use this script quite a bit, thank you! Is there any way to covert a non-sesparse backing to sesparse in place? Often I make linked clones of deployed OVA/OVF appliances just to be able to convert to sesparse.

  4. Quick note to anybody running across this article more recently – you cannot create an SE sparse disk by cloning a parent non-SE sparse disk except on vSphere 5.1. I’ve tried on 5.5 and 6.0 and it always ends up in redoLogFormat, same code on 5.1 produces seSparseFormat. In 5.5/6.0, the parent VM’s disk must already be in seSparseFormat. You can create a standalone seSparse disk using the virtual disk manager, as described in another one of William’s posts.

Thanks for the comment!