InterWeb.org.uk

Interweb Blog Hyper-V, App-V, Dell Equallogic, Forefront TMG Security, DPM 2010, SCVMM

21Mar/110

Understanding Hyper-V Virtual Machine Snapshots/Checkpoints

Snapshots or Checkpoints - One and the Same.

First of all a snapshot is exactly the same as a checkpoint, if you use Hyper-V Manager you will see the term snapshot and if you use System Centre Virtual Machine Manager or SCVMM you will see checkpoint both processes are exactly the same the differences are merely in terminology.

Snapshot Checkpoint Example

Snapshot Checkpoint Example

The first and most important thing I would like to cover is that snapshots are not a backup/disaster recovery solution, they are simply a point in time capture of the data,hardware configuration and state of your virtual machine.  snapshots are particulary useful for reverting back to a previous state quickly and easily, Microsoft only recommends the use of snapshops in a test/development environment.  I only use snapshots for a virtual machine when applying updates to the guest operating system or an application within the OS, if the update is successful then the snapshot is immediately deleted and the VM shutdown so the merge process can take place.  I do not recommend keeping snapshots of your Virtual Machines in a production environment.

Creating Snapshots, What happens?

When you create a snapshot a .avhd files is created and the .vhd file becomes read-only, all changes are then written to the .avhd file preserving the state of the .vhd file at the point of creating the snapshot.  This is where the disk performance aspect comes in, now you have 2 files a .vhd and .avhd if you request a file prior to the creation of the snapshot then it will be in the .vhd file and after the creation of the snapshot the .avhd file, firstly the .avhd file is checked to see if an updated version of this file exists then if not refers back to the origional .vhd, the more snapshots you have the longer this takes.

Once you have created a snapshot it will sit there with all the changes being written to it thus growing in size, upon deletion all of these changes will be merged with the .vhd and the .avhd file deleted from your storage.  Your VM needs to be shutdown for the merge process to take place, the merge process may take time and there is no way to tell how long it will take, just be patient!

Snapshots are stored in the same folder as your VM or .vhd file unless otherwise specified, snapshots are saved as .avhd you will see multiple .avhd files if you have multiple snaphots.  Snapshots are hierarchical, each snapshot depending on the one before or its 'Parent'.

Below is an example of a VM which has multiple snapshots and is currently running from a snapshot .avhd and not a vhd, this is one of my VM's that does not merge its snapshot files on shutdown and is becoming a bit of a issue.  This is why I don't keep multiple snapshots of VM's or a single snapshot for a long period of time!

snapshot/checkpoint

.avhd example

 

As you can see the filename ends with .avhd and its parent is also a .avhd file this is a VM that has multiple snapshots and therefore has 6 .avhd files in this chain before the final file is the actual .vhd.  These snapshots have been deleted but when shutdown the merge process did not take place (I don't know why!).  I intend on exporting this VM deleting the files from the cluster and re-importing it, this process according to Mr. Microsoft will merge the .avhd files or snapshots in to a single .vhd then I will re-import back to the cluster storage, I will keep you posted on how this goes!

Never delete the .avhd files manually!! (Note the use of  two exclamation marks, I am trying to say this is important).  Always use Hyper-V Manager or SCVMM to delete the snapshots from the snapshot tree, I have done this before and believe me this is not pretty and your VM will not boot as the snapshot tree has been changed without the VM knowing about it and therefore its configuration which is referncing the .avhd file is referencing a file which no longer exists in the tree.

Some points to remember when creating snapshots;

  • Minimize the use of snapshots in a production environment and delete as soon as it is no longer needed.
  • Merely having a snapshot of a VM reduces the disk performance, so if this is a production VM that requires every ounce of performance, then you guess right, don't keep a snapshot of it.
  • Depending on the size of your VM, the snapshot or snapshots can comsume disk space quickly, so if this is your TIER 1 storage then snap-shotting can be quite expensive.
  • When you delete a snapshot, the VM needs to be shutdown so a merge can take place, depending on how many snapshots you have this may take some time.  Interrupting this process may corrupt your .vhd file.  Give yourself plenty of time for the merge to take place.
  • Microsoft does not support the use of snapshots on Domain Controllers or on servers with the Active Directory Lightweight Directory Services role installed. 
  • Finally snapshots are not a backup/disaster recovery solution! Remebering this will save you alot of heartache in the future.

Snapshots or Checkpoints are a useful beast if used correctly, if not they can quickly become the root of all evil.

 

    Comments (0) Trackbacks (0)

    No comments yet.


    Leave a comment

    No trackbacks yet.

    Get Adobe Flash player