Cloud

How to limit the number of VMware VM snapshots

In this technical blog, vExpert Bryan O'Connor explains why, and how, to limit the number of VMware snapshots for a virtual machine.

What is a VM snapshot?

Virtual machine (VM) snapshots have their uses – they're handy, for instance, to repeatably return back to a virtual machine's previous state.

When we take a snapshot, we capture the virtual machine's hard disk, hardware and optionally the memory state.

Within VMware, we create three state files:

  • Disk files – Delta.VMDK (VMFS5 less than 2TB virtual disk)
  • Hardware state – .vmsn
  • Memory state – .vmem

These snapshots then allow us to revert back to a previous state if something goes wrong, for example, if a software update fails.

Snapshots best practices

VMware has some best practices for using snapshots.

  • Do not use snapshots as back-ups.
  • Do not use a single snapshot for more than 72 hours.
  • When using third-party back-up software, ensure that snapshots are deleted after a successful back-up.
  • A maximum of 32 snapshots are supported in a chain. However, for a better performance use only two to three snapshots.

Why you should limit the number of VM snapshots

The last point is quite interesting: The more snapshots we take, the slower the VM will potentially run, but most importantly, the VM will take up a lot of additional disk space, as the snapshot disk file increases in size.

How to limit the number of VM snapshots

VMware has a setting that we can add to the VMs .vmx file – we set the maximum number of snapshots for a virtual machine by editing the snapshot.maxSnapshots = n variable of the configuration file.

Here's how:

Once we are in the vSphere Client, right-click and edit your VM settings, select VM options and then select Advanced, then locate Configuration Parameters, and select EDIT CONFIGURATION.

Image: Vware snapshot advanced settings

Then select ADD CONFIGURATION PARAMS.

Next, type for max of 2 snapshots, and click OK.

Image: VMware configuration parameters

Now we can only take a maximum of 2 snapshots against this machine:

Snapshot.maxSnapshots            2

Image: VMware max snapshots settings

If you would like to learn more, check out our comprehensive catalogue of VMware courses