What is a VMware snapshot?

A snapshot preserves the state and data of a virtual machine at a specific point in time.

  • State includes the virtual machine’s power state (powered‐on, powered‐off, suspended, etc).
  • Data includes all the files that make‐up the virtual machine, including disks, memory, and other devices, such as virtual network interface cards.
A virtual machine provides several operations for creating and managing snapshots and snapshot chains. These operations let you create snapshots, revert to any snapshot in the chain, and remove snapshots. You can create extensive snapshot trees that you can use to save virtual machine state at any point in time, and restore it later, if necessary.
When creating a snapshot, there are several options you can specify:
  • Name – used to identify the snapshot.
  • Description – used to describe the snapshot.
  • Memory – If the <memory> flag is 1 or true, a dump of the internal state of the virtual machine is included in the snapshot. Memory snapshots take longer to create.
  • Quiesce – If the <quiesce> flag is 1 or true, and the virtual machine is powered on when the snapshot is taken, VMware Tools is used to quiesce the file system in the virtual machine. Quiescing a file system is a process of bringing the on‐disk data of a physical or virtual computer into a state suitable for backups. This process might include such operations as flushing dirty buffers from the operating systems in‐memory cache to disk, or other higher‐level application‐specific tasks.
Note: Quiescing indicates pausing or altering the state of running processes on a computer, particularly those that might modify information stored on disk during a backup, to guarantee a consistent and usable backup.
When a snapshot is created, it is comprised of the following files:
  • <vm>-<number>.vmdk and <vm>-<number>-delta.vmdk
    A collection of .vmdk and -delta.vmdk files for each virtual disk is connected to the virtual machine at the time of the snapshot. These files can be referred to as child disks, redo logs, and delta links. These child disks can later be considered parent disks for future child disks. From the original parent disk, each child constitutes a redo log pointing back from the present state of the virtual disk, one step at a time, to the original.

    Note: The <number> value may not be consistent across all child disks from the same snapshot. The file names are chosen based on filename availability.

  • <vm>.vmsd
    The .vmsd file is a database of the virtual machine’s snapshot information and the primary source of information for the snapshot manager. The file contains line entries which define the relationships between snapshots as well as the child disks for each snapshot.
  • <vm>Snapshot<number>.vmsnThese files are the memory state at the time of the snapshot.

What products use the snapshot feature?

In addition to being able to use snapshot manager to create snapshots, snapshots are used by many VMware and third party products and features. Some VMware products that use snapshots extensively are:
  • VMware Consolidated Backup
  • VMware Data Recovery
  • VMware Lab Manager
  • VMware vCenter and the VMware Infrastructure Client (Snapshot Manager, Storage vMotion)
Note: This is not an exhaustive list and does not include third party programs.

How do snapshots work?

Our VMware API allows VMware and third party products to perform operations with virtual machines and their snapshots. Below is a list of common operations that can be performed on virtual machines, snapshots or using our API:
  • CreateSnapshot – Creates a new snapshot of a virtual machine. As a side effect, this updates the current snapshot.
  • RemoveSnapshot – Removes a snapshot and deletes any associated storage.
  • RemoveAllSnapshots – Remove all snapshots associated with a virtual machine. If a virtual machine does not have any snapshots, then this operation simply returns successfully.
  • RevertToSnapshot – Changes the execution state of a virtual machine to the state of this snapshot.
The following is a high level overview of how create, remove, or revert snapshot requests are processed within the VMware environment:
  1. A request to create, remove, or revert a snapshot for a virtual machine is sent from the client to the server using the VMware API.
  2. The request is forwarded to the VMware ESX host which is currently hosting the virtual machine in question.

    Note: This only occurs if the original request was sent to a different server such as vCenter which is managing the ESX host.

  3. If the snapshot includes the memory option, the ESX host writes the memory of the virtual machine to disk.

    Note: The length of time the ESX host takes to write the memory onto the disk is relative to the amount of memory the virtual machine is configured to use.

  4. If the snapshot includes the quiesce option, the ESX host requests the guest operating system to quiesce the disks via the VMware tools.

    Note: Depending on the guest operating system, the quiescing operation can be done by the sync driver, the vmsync module, or Microsoft’s Volume Shadow Copy (VSS) service. For more information on quiescing, seeTroubleshooting Volume Shadow Copy quiesce related issues (1007696) for VSS or A virtual machine can freeze under load when you take quiesced snapshots or use custom quiescing scripts (5962168) for the SYNC driver.

  5. The ESX host makes the appropriate changes to the virtual machine’s snapshot database (.vmsd file) and the changes are reflected in the snapshot manager of the virtual machine.

    Note: The operation to remove the snapshot entity in the snapshot manager completes before the changes are made to the child disks. The snapshot manager does not contain any snapshot entries while the virtual machine continues to run from the child disk.  For more information, see Committing snapshots when there are no snapshot entries in the snapshot manager (1002310).

  6. The ESX host calls a function similar to the Virtual Disk API functions to make changes to the child disks (-delta.vmdk and .vmdk files) and the disk chain.

    Note:  During a snapshot removal, if the child disks are large in size, the operation may take a long time. This could result in a timeout error message from either VirtualCenter or the VMware Infrastructure Client. For more information about timeout error messages, see vCenter operation times out with the error: Operation failed since another task is in progress (1004790).

The child disk

The child disk which is created with a snapshot, is a sparse disk. Sparse disks employ the copy‐on‐write (COW) mechanism, in which the virtual disk contains no data in places, until copied there by a write. This optimization saves storage space. The grain is the unit of measure in which the sparse disk uses the copy-on-write mechanism. Each grain is a block of sectors containing virtual disk data. Default size is 128 sectors or 64KB.

Child disks and disk usage

The following are points which should be noted regarding the space utilization of Child disks:
  • If a virtual machine is running off of a snapshot, it is making changes to a child or sparse disk. The more write operations made to this disk, the larger it grows.
  • The space requirements of the child disk are in addition to the parent disk on which it depends.  If a virtual machine has a 10 GB disk with a child disk, the space being used will be 10 GB + the child disk size.
  • Child disks have been known to grow large enough to fill an entire datastore.
  • The speed at which child disks grow are directly dependent on the amount of I/O being done to the disk.
  • The size of the child disk has a direct impact on the length of time it takes to delete the snapshot associated to the child disk.
The following Knowledge Base articles touch on the topic of child disks and disk usage:

The disk chain

Generally, when you create a snapshot for the first time, the first child disk is created from the parent disk. Successive snapshots generate new child disks from the last child disk on the chain. The relationship can change if you have multiple branches in the snapshot chain.

The following diagram is an example of a snapshot chain, each square represents a block of data or a grain as described above:

Caution: Manually manipulating the individual child disks or any of the snapshot configuration files may compromise the disk chain. VMware does not recommend manually modifying the disk chain as it may result in data loss. For more information, see Consolidating snapshots (1007849).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s