WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Automation / Creating SE Sparse Linked Clones Using the vSphere 5.1 API

Creating SE Sparse Linked Clones Using the vSphere 5.1 API

09.07.2012 by William Lam // 9 Comments

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 vGhettoLinkedClone.pl 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:

./vGhettoLinkedClone.pl --server vcenter51-1.primp-industries.com --username root --vmname Regular-VM --vmname_destination Linkedclone-SeSparse-Destination --snapname pristine --vmhost vesxi51-1.primp-industries.com --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:

./vGhettoLinkedClone.pl --server vcenter51-1.primp-industries.com --username root --vmname SeSparse-VM --vmname_destination Linkedclone-SeSparse-Destination --snapname pristine --vmhost vesxi51-1.primp-industries.com --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.

More from my site

  • How to Create an SE Sparse (Space-Efficient) Disk in vSphere 5.1
  • Retrieving vscsiStats Using the vSphere 5.1 API
  • Retrieving ESXTOP Performance Data Using the vSphere 5.1 API
  • How To Initiate a Wipe & Shrink Operation On an SE Sparse Based Disk
  • Nested Virtualization APIs For vSphere & vCloud Director 5.1

Categories // Automation, vSphere Tags // api, ESXi 5.1, linked clones, sesparse, vSphere 5.1, vsphere sdk for perl

Comments

  1. *protectedAnonymous says

    09/19/2012 at 9:33 am

    hello it is impossible to find the latest version of the script on the site vGhettoLinkedClone.pl http://communities.vmware.com/docs/DOC-9852 script dates from 2009 and it is impossible to download.

    Thank you.

    Reply
    • *protectedWilliam says

      09/19/2012 at 3:09 pm

      @Anonymous,

      I've fixed the link on here

      Reply
    • *protectedxatic says

      10/29/2012 at 1:44 pm

      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...

      Thanks!

      Reply
  2. *protectedAnonymous says

    11/29/2012 at 5:48 pm

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

    Reply
  3. *protectedAndy says

    11/30/2012 at 3:00 am

    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?

    http://txtbin.us/GitLS

    Reply
    • *protectedWilliam says

      11/30/2012 at 4:10 am

      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.

      Reply
  4. *protectedTheBashar99 says

    12/25/2012 at 1:02 am

    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.

    Reply
  5. *protectedBrian Clow says

    11/12/2015 at 12:41 pm

    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.

    Reply

Trackbacks

  1. vUnhandledException » Planning and building the “nasty” SSL/SSO lab – Part 2 says:
    01/04/2015 at 2:54 pm

    […] I am using Workstation 11 for this lab build (basically just to test out the new Workstation version at the same time, the amount of free time I got to do so will rapidly decrease starting next week when support calls come in again). The laptop I am running this lab on has some horse power (8 Cores a 2.4GHz, 16GB RAM, 256GB SSD) but the lab should still perform somewhat decent on slower hardware as well. To save on disk space I will be using linked clones. If you want to do the same on ESXi check out the awesome post by William Lam (@lamw) explaining how to use the API to create linked clones using vSphere. […]

    Reply

Leave a Reply to xaticCancel reply

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

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025