Insta Clone

 In Product updates, Software, VMware

One of the new features in vSphere 6.7 is Instant Clone. Well, it’s not exactly new feature, some of you might heard about something called VMfork but since vSphere 6.7 its fully integrated into the vSphere itself. So, what it is? Imagine a situation when you need to (almost) instantly create dozens or even hundred VMs from parent (or source) VM but with possibility to customize new VMs.

How it works internally? Well, it is similar to snapshot technology when the new changes are written to delta disk, so all the VMs have the similar base disk at the beginning of their lifecycle, but individual changes in those VMs are not affecting each other. And now add memory as well!

Basically, all the new Insta Clone VMs shared based disk and base memory of the parent VM and only the changes are written to the datastore (in case of disk) or actually written into pRAM of the ESXi host.

What is the beauty about that? Basically, you use the resources really wisely meaning that you can Insta Clone dozens of VMs but the footprint in the pRAM of the ESXi host will be kept at minimum. Please not, that you do not need to enable transparent memory sharing on the ESXi hosts, everything works internally out-of-the-box.

In the past, the idea of VMfork was about creating virtual desktops on-the-fly from the master VM but there is much more you can do with Insta Clone. Imagine a situation when you are developing large-scale cloud native application. Every time you build new version of your application you would need to deploy dozens of webservers let’s say.

And now the Insta Clone comes into the play.

Using your CI/CD pipeline you can easily invoke script that will build those instances, the tests will be run on dozens of new VMs (but they will not consume much of the resources) and once the test of the deployment will be done those VMs will be destroyed. All of this within few minutes.

So how Insta Clone works internally?

There are two components that you need to prepare.

  • First is a hostcustomization script that will reside in the Source VM. This script will do all the changes to the VM like IP readdressing, editing hostname or whatever you need to make each Insta Clone VM unique.
  • Second one is a PowerCLI script that will be run, and which will actually push those changes to the Insta Clone VMs.

If you want to download the scripts you can check my GitHub repository

Let’s have a look at the example of my script


set -x
exec 2>/home/customization.log

echo -e "\n=== Start Pre-Freeze ==="

echo "Disabling ${INTERFACE_NAME} interface ..."
ip addr flush dev ${INTERFACE_NAME}
ip link set ${INTERFACE_NAME} down

echo -e "=== End of Pre-Freeze ===\n"

echo -e "Freezing ...\n"

vmware-rpctool "instantclone.freeze"

echo -e "\n=== Start Post-Freeze ==="

# retrieve VM customization info passed from vSphere API
HOSTNAME=$(vmware-rpctool "info-get guestinfo.ic.hostname")
IP_ADDRESS=$(vmware-rpctool "info-get guestinfo.ic.ipaddress")

echo "Updating IP Address ..."
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 <

As you can see it’s a standard bash script that will do several tasks

  1. It will disable the network interface of the VM (in my case eth0)
  2. Then using vmware-rpc call the VM will be “freeze”
  3. After the freeze we will receive new IP address and hostname as parameters from guestinfo.ic API call
  4. And then we will use those values to actual reconfiguration of the VM

It can be much more complex, you can for example customize some apps on the new Insta Clone VM or whatever you need to.

You might be wondering how the freeze process forks exactly. Well, at the beginning you will start this script in the source (master) VM (and of course, you can do that from the PowerCLI using vmware-tools to run script in the VM itself).

The VM will be paused and once new Insta Clone VM will be deployed from that master VM the freeze status will be automatically resumed and the script will continue inside new Insta Clone VM.

Now let’s have a look at the PowerCLI script

Function New-InstantClone {

Connect-VIServer -server -user "administrator@vsphere.local" -password "MyPass"

$StartTime = Get-Date
Write-Host -ForegroundColor Cyan "Starting Instant Clone setup"

foreach ($i in 1..20){



 $guestCustomizationValues = @{
        "guestinfo.ic.hostname" = $newVM
        "guestinfo.ic.ipaddress" = "$ip"

New-InstantClone -SourceVM $SourceVM -DestinationVM $newVM -CustomizationFields $guestCustomizationValues

$EndTime = Get-Date
$duration = [math]::Round((New-TimeSpan -Start $StartTime -End $EndTime).TotalMinutes,2)
Write-Host -ForegroundColor Cyan  "`nStartTime: $StartTime"
Write-Host -ForegroundColor Cyan  "  EndTime: $EndTime"
Write-Host -ForegroundColor Green " Duration: $duration minutes"

Disconnect-VIServer -Confirm:$false
  1. First you need to obtain custom PowerCLI function from William Lam “New-InstaClone”. You can either add the content of the file to your PowerCLI scrip or you can easily include it as an external module.
  2. Then we need to connect to our vCenter server (and please not that you MUST have vCenter 6.7 AND ESXi 6.7 installed to make this work)
  3. I have defined what will be the source VM in variable $source
  4. Then we will deploy 20 new VMs starting with IP till and new hostname will be InstaCloneX (for 1 –> 20)

And that’s it. No more magic here. Again, this is just sample, really basic script but it can be much complex based on your desired use-case.

Also, don’t forget to check Will’s blog post regarding some best-practices regarding host customization and some recommendations regarding Insta Clones

So, as you can see, with this technology you can easily provision dozens or even hundreds of new VMs without using almost no resources on your ESXi server. As said I can see the biggest use-case for some advanced CI/CD pipelines but feel free to post your experience in the comments!

Showing 2 comments
  • Washington

    I´m testing Instant Clone based in your article. But, i have some questions, may would you help-me?

    The Source VM (parent) pass to use Delta Disk (no more its original vmdk) , and I don´t know how to rollback that!!
    Each time that i run Instant Clone process, a delta disk (in Source VM) is created… how I exclude that ?

    Sorry for my mistakes, but I dont write in Elnglish very well !!

  • Javier Barreto

    Thanks, do you have this code for windows template?

Leave a Comment

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

Not readable? Change text. captcha txt