Virtual Machine Snapshotting under Hyper-V

Virtual Machine Snapshotting under Hyper-V

Rate This
  • Comments 19

A number of people have been asking me how snapshots actually work "under the covers". So here we go: When you take a snapshot of a running virtual machine:

  • We pause the virtual machine.
  • We create a new differencing disk for each virtual hard disk and hook it up to the virtual machine.
  • We make a copy of the virtual machine's configuration file.
  • We resume the virtual machine (note that this happens so quickly that you do not know that the virtual machine was paused at all.
  • Once the virtual machine is running again we start saving the contents of the virtual machine's memory to disk.
  • While this is happening we monitor memory activity inside the virtual machine and if the the guest operating system attempts to modify memory that we have not copied, we intercept the write attempt and copy the original memory contents then allow the write to go through.

Once the snapshot is completed we have a set of the virtual machine configuration file, the virtual machine saved state files and the snapshot differencing disks (.AVHDs) stored in a folder under the virtual machine's snapshot directory.

This is now treated as a read-only "point in time" image of a virtual machine.  You can apply a virtual machine, in which case we set the virtual machine to start from a copy of the snapshot.  You can change the virtual machine settings after applying a snapshot - but you cannot change the snapshot settings themselves.

You can also delete a snapshot.  If you delete a snapshot that has no descendants (snapshot with differencing disks that reference the snapshot being deleted) then the files associated with the snapshot will just be deleted.  If you delete a snapshot with only one descendant the configuration and saved state files for the snapshot will be deleted and the snapshot differencing disks will be merged with those of it's descendant.  If you delete a snapshot with more than one descendant the snapshot configuration and saved state files will be deleted - but the differencing disks will not be merged until the number of descendant snapshots is reduced to one.

Cheers,
Ben

Leave a Comment
  • Please add 8 and 1 and type the answer here:
  • Post
  • I wish I would have read more into snapshots before clicking that button in hyper-V console. I thought it would simply be a redundant backup type, where I could revert to it if needed. I had no clue that it actually stops storing on your VHD file, creates a new avhd file that records changes, then has to merge the two when shut down if deleted... what a ridiculous method. I ran out of disk space on the C: of the host server because of this, and now our business has been down all day while the darn thing is merging after I deleted the snapshots. They need to clarify this process within the console, perhaps an acceptance screen of sorts. I will not use snapshot again. Is there a quicker method to get the VM back up and running without the avhd file but keeping the current state of the VM?

  • Nice note.

    My question is, when a snapshot is corrupted or lost from the middle of a chain in VM-Mangager, how do you recover?

    I have a corrupt or lost avhd from the middle of a snapshot chain and the system is telling me that I am stuck. Am I facing deleting the whole machine?

  • James Adamski -

    Unfortunately there is nothing you can do to recover if you have deleted / lost an AVHD from the middle of a chain.

    Cheers,

    Ben

  • Hello All,

    Why does my Hpyer-V Snap shot continue to grow untill it fills my drive ? What is it writing to the snapshot file after the VM is backup adn running?  I took a live snapshot, it said it completes, l applied my patches to my VM reboot and it came  backup running fine. I took this snapshot a week ago and everyday I check the snapshot grows initaly it was 1Gb now it is 136GB . Does the snapshot continually get updated by the VM ? If so what is writing to the snapshot ? And can I delete the snapshot at any time after I see the VM is up and running ok ?

    I know this has been posted prior but I cannot grasp why Hyper V says snapshot complete, yet it continues to grow.

    Why does it continue to write to a snapshot that is supposed to be an restore point so I can go back to a previous configuration prior to patching ?

    Thank you and

    Cheers!

Page 2 of 2 (19 items) 12