Home > Blogs > VMware PowerCLI Blog

Snapshot Size

There have been multiple posts in the community about the size of the snapshots and how it should be calculated. There are some issues with the “SizeMB” property of the Snapshot object, so this post will try to explain what these problems are and what is the correct way to calculate snapshot sizes.

We’ll try to keep things simple and not go in too much detail. To start off let’s imagine you have a virtual machine with a single hard disk. This disk is represented as a “vmdk” file in the datastore (e.g. VM.vmdk). Whenever you write something on the hard disk of the VM it is saved in that VM.vmdk file (figure-1). 

When you create a snapshot this VM.vmdk file gets “frozen” and a new one (VM-1.vmdk) is created. The “frozen” VM.vmdk file represents the exact state of the VM’s hard disk at the time when the snapshot was taken. From that point on all changes on the VM’s hard disk are reflected in the new VM-1.vmdk file. Also a new “vmsn” file is created (e.g. Snapshot1.vmsm) which represents the state of the VM’s memory at the time of the snapshot creation (figure-2).


Similarly when a second snapshot is taken VM-1.vmdk gets “frozen” and VM-2.vmdk and Snapshot2.vmsn files are created, the same thing happens when we create a third snapshot (figure-3).


So how is the snapshot size calculated?

For each snapshot the size includes the sizes of the files needed to capture the state of the VM at snapshot time (e.g. hard disk and memory).

For Snapshot2 (figure-3) these files are Snapshot2.vmsn and VM-1.vmdk. The VM-1.vmdk contains all changes made after the first snapshot and it is required part of Snapshot 2.

For the currently active snapshot (e.g. Snapshot3), its size also includes the file which stores disk changes after the snapshot (e.g VM-3.vmdk, figure-3). Thus Snapshot3 files are Snapshot3.vmsn, VM-2.vmdk and VM-3.vmdk. VM-2.vmdk contains all changes since previous snapshot and VM-3.vmdk contains the current changes.

The root snapshot (e.g. Snapshot1) is based directly on the VM’s disk (e.g. VM.vmdk) but its size is not calculated (it’s calculated towards the size of the hard disk itself, not the snapshot). That way the files calculated in the size of each snapshot are the ones marked in orange in figures 2 and 3.

(Note: if we consider figure 3 and imagine that Snapshot2 is the currently active snapshot, then the size of VM-3.vmdk will be calculated in Snapshot2’s size, not Snapshot3’s)

Now for the “SizeMB” property of the Snapshot object. When calculating its value we use the above mentioned approach and calculate the size correctly for ESX 3.0 and 3.5. However there are some changes in the API behavior from 3.5 to 4.0 that we overlooked, thus resulting in wrong calculation of the snapshot size on ESX 4.0.

This issue will be fixed in a future release, but until then you can use the attached script to get the correct snapshot sizes. The script works on all ESX versions and uses the above mentioned approach for calculation.

Download GetSnapshotSize.ps1(fixed)

Dimitar Hristov & Vitali Baruh

PowerCLI Team

15 thoughts on “Snapshot Size

  1. LucD

    Great article.
    I know the definition of a snapshot’s size is like you defined it in the text above, but I still think you need to know what ‘extra’ disk space is needed when you create a snapshot.
    That’s what I tried to do in my http://www.lucd.info/2010/03/23/yadr-a-vdisk-reporter/ post.
    Btw, if you want a nice diagram of your disks and snapshots, you can use my http://www.lucd.info/2010/03/31/uml-diagram-your-vm-vdisks-and-snapshots/ post, where I followed that same logic.

  2. Robbie Wiley

    I had to modify the CalculateVMSnapshotsSizeMB function to use $vmView = Get-View $vm.id as the first line. Get-View didn’t like just getting the entire VM as an input.

  3. Vitali Baruh

    The script was written using PowerCLI 4.1. Now it works also with version 4.0u1.

  4. David Chan

    Do you have a release date for this snapshot size bug ? Is it stil there with ESX 4.1 ?

  5. neel

    The vmware page for VirtualMachineFileLayout (http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc_50%2Fvim.vm.FileLayout.html) says VirtualMachineFileLayout is deprecated. Need to modify the script?

  6. Vitali Baruh

    You can use the Get-Snapshot cmdlet. I believe that SizeMB property now shows correct values.
    Vitali Baruh
    PowerCLI Team

  7. Chaitanya Reddy

    How to get the Virtual Machine Snapshot Space using vi java api? Is there any method or property to get snapshot space ? ..Plz help me..!!!

    1. ramakrishna

      Hey, even i am working on that now.. Did u got the answer??
      thanks in advance

  8. Purple Colors

    Your nature fell on your only purple nature and have to yell to you which you will be smileful. The best writing is the collection that I feels for in their lives. You must make electric writings. Nature.

  9. vijay

    Good one ,, its a simple and shot explanation.

  10. vijay

    Good one ,, its a simple and short explanation.

  11. Craig

    Your style is very unique in comparison to other people I have read
    stuff from. Thanks for posting when you have the opportunity, Guess I’ll just bookmark this web site.

  12. Vincent

    I was curious if you ever considered changing the page layout of youhr website?

    Its very well written; I love what youve got to
    say. But maybe you coould a little moore in tthe way of content so peoople could connect witth it better.

    Youvee got an awful lot of text for only having 1 or two images.
    Maybe you could space iit out better?

  13. Visalia Skincare Anti Aging

    Simply wanna state that this is handy, Thanks for taking your time to write this.

  14. my nba 2k17 hack

    Thank you for the good writeup. It actually was a leisure account
    it. Look complicated to far added agreeable from you!
    However, how could we keep up a correspondence?


Leave a Reply

Your email address will not be published. Required fields are marked *