Friday, February 11, 2011

Hyper-V Virtual Machine Snapshots

Virtual Machine Snapshots

Snapshots are read-only, ―point-in-time‖ images of a virtual machine. You can capture the configuration and state of a virtual machine at any point in time, and return the virtual machine to that state with minimal interruption. Multiple snapshots can be created, deleted, and applied to virtual machines. Snapshots form parent-child hierarchies with a parent virtual hard disk (VHD) and automatic virtual hard disks (AVHDs).

 
In Hyper-V Manager, when you create a snapshot the following occurs:
  1. The virtual machine pauses.
  2. An AVHD is created for the snapshot.
  3. The virtual machine is configured.
  4. The virtual machine is pointed to the newly created AVHD.
  5. The virtual machine resumes (the time lapsed is not perceivable by end user).
  6. While virtual machine is running, the contents of the virtual machine's memory are saved to disk. If a guest operating system attempts to modify memory that has not yet been copied, the write attempt is intercepted and copied to the original memory contents.
  7. When the snapshot is completed, the virtual machine configuration file, the virtual machine saved state files, and the snapshot (AVHD) are stored in a folder under the virtual machine's snapshot directory.
 
Snapshot Deletion:

Deleting a snapshot deletes all the saved state files (.bin and .vsv files). Hyper-V takes different actions on AVHDs, depending on the location of deleted snapshots relative to the running state of the virtual machine.
When you delete a snapshot, the following occurs:
  1. The copy of the virtual machine configuration taken during the snapshot process is removed.
  2. The copy of virtual machine memory taken during the snapshot process is removed.
  3. When the virtual machine is powered down, the contents of any "deleted" AVHDs are merged with its parent.
 
Deleting a snapshot subtree deletes the selected snapshot and any snapshots listed hierarchically underneath it.
  1. Deleting a snapshot between the first snapshot and the running state of the virtual machine preserves AVHDs. When the virtual machine is shut down, the data in the AVHDs is merged with the parent.
  2. If the deleted snapshot exists on a different branch or the same branch but at a point in time after the running state of the virtual machine, then the AVHD is deleted immediately.
 
Applying Virtual Machine Snapshots:

Applying a snapshot to a virtual machine basically means copying the complete virtual machine state from the selected snapshot to the active virtual machine. This effectively returns your current working state to the previous snapshot state. Any unsaved data in the currently active virtual machine will be lost if you do not take a new snapshot of the current virtual machine state before you apply the selected snapshot.
 

No comments: