Where are my snapshot files? [Hyper-V]

In the past I have talked about the fact that when you take a snapshot of a running virtual machine, we create a copy of the virtual machines configuration files, write the current memory to disk and create a differencing disk that is then used to run the virtual machine off of.  But you may want to know what these files are exactly and where they are.

Snapshot files are created in a folder labeled “Snapshots” under the virtual machines snapshot file location, as specified in the virtual machine settings:


You can check on this location at any time – but you can only change it if the virtual machine has no snapshots.  This location will be different depending on whether you select to “Store the virtual machine in a different location” when creating the virtual machine.  If you select this option the snapshot folder will be created underneath the virtual machine location that you specify in the new virtual machine wizard.  If you do not select this option the snapshots will be created in a snapshot folder underneath the default virtual machine location – as specified in the Hyper-V settings:


So now that we know where the files are – what do the files look like?  If I create a virtual machine and store it in a different location – a file listing with no snapshot looks like this:


There is a configuration file (.XML), saved state file (.BIN & .VSV) and a virtual hard disk (.VHD).  The .XML file is named after the GUID that identifies the virtual machine.  The saved state files are also named after the virtual machine GUID, and are stored in a folder that is named after the virtual machine GUID (the virtual machine GUID is the value that Hyper-V uses internally to uniquely identify the virtual machine).  After creating a single snapshot the file listing changes to this:


There are a number of changes here.  A snapshot folder has been created and a configuration (.XML) file and saved state files (.BIN & .VSV) have been created for the first snapshot.  They are all named after the GUID that identifies the new snapshot.  There is also a folder that has been created to store the snapshot differencing disks (.AVHDs).  All .AVHDs for a given virtual machine are stored in the same location.  Which is in a folder that is stored under the snapshot folder and is named after the base virtual machine GUID.

You will notice that the AVHD does not share any identifiers with the base virtual machine or the snapshot.  The only way to map these together (without using the WMI interfaces) is to open the .XML files and check what VHDs and AVHDs they are pointing at.

A subtlety that many people miss is that the base virtual machine is always pointed at the latest AVHD in the chain.  So in this case the first snapshot configuration file is now pointing at the base VHD file and the base virtual machine configuration is pointing at the AVHD file.

Next if a second snapshot file is created, the file listing looks like this:


Here you will see a new set of snapshot configuration and saved state files.  As well as a new AVHD.  The base virtual machine configuration is now pointing at the newest AVHD.  The first snapshot configuration continues to point at the base VHD while the second snapshot configuration points at the AVHD that was created when the first snapshot was created.

Hopefully this helps you to understand what is happening underneath the covers when you are using snapshots.