How do VMware Snapshots work

When I studied computer science it was not a raw science.  My training did not require knowledge of how transistors worked or even logic circuits.  It focused mostly on programming languages and how to configure a web server.   Why?  Because these were the skills most likely to be used by a computer scientist in the field today.   Very few people build computers from scratch.  Intel has a corner on that market.  Personally I wanted to understand all the under the hood components so I took a minor in electrical engineering.  It was worth my time and a great learning experience.   I find that a lot of technology is like this… which includes VMware snapshots.   I have had snapshots explained to me in every VMware course that I have attended and every answer is different.  I have cobbled together lots of KB articles and other sources into this article.  If something is missing or incorrect let me know so I can fix it.

What is a Snapshot?

  • A snapshot file is only a change log of the original virtual disk
  • A virtual machine uses the disk descriptor file to access the most current snapshot not the original disk.
  • It is not a complete copy of the original disk
  • Snapshots are combined dynamically with the original disk to form a current state of system
  • The snapshot change logs are sometimes called delta files
  • Think of them as chains to get the complete picture you need all the links in order.
  • Snapshot files will grow forever unless deleted(re-integrated into original disk)
  • Using a lot of snapshots can effect performance of the virtual machine

How do snapshots work?

The process on the surface seems simple.  When you initiate a snapshot the following process is followed:

  1. A request to create (CreateSnapshot) snapshot for a virtual machine is forwarded to ESXi host running the virtual machine.
  2. If memory snapshot is included the ESXi host writes the memory of virtual machine to disk
  3. If quiesce is possible the ESXi host request the guest OS to quiesce the disks via VMtools
  4. ESXi host changes the virtual machines snapshot database (.vmsd file) to denote snapshots
  5. ESXi host calls a function to make changes to the child disks (-delta.vmdk via the .vmdk descriptor)

What is a .vmdk descriptor?

Due to the nature of file systems os’s don’t like to have file names change mid-access.  So VMware has implemented descriptors.  Or symbolic links that point to the real files.  This allows a snapshot to be created and access via descriptor to continue.

How can I identify snapshots?

  • Select the Virtual Disk and check the Disk File. If it is labeled as VM-000001.vmdk , the virtual machine is running on snapshot disks.
  • Run the following command from ESXi Shell:
find /vmfs/volumes/ -iname "*.vmx" -exec grep -Hie "-[0-9][0-9][0-9][0-9][0-9][0-9].vmdk" {} \;
  • List currently open delta disks via command line:
ls -l /vmfs/devices/deltadisks
  • Locate all delta disks on file system:
find /vmfs/volumes/ -iname "*delta.vmdk"
  • In powercli
get-vm | get-snapshot | format-list

 

 

Leave a Reply

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

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