Mike's Tech Head Blog

What’s a Tech-Head? Well, hard to explain, but they do use technology where ever it is possible, even if it is not very smart or even needed…

Like Snapshots in Hyper-V? - Please read this

Snapshots is nice to have, in fact very nice to have when running a virtual platform. In Hyper-V it is easy to do snap-shots and there are no problems, or is there something you should be aware of...

Yes, there is a a issue, it is not a bug but there is something you absolutely need to know, otherwise you will be in serious trouble. So lets here the story...

A snapshot is a way to "freeze" a virtual machine so that you can reverse back to a previous state. As an example, if you want to install a servicepack or a hotfix, it could be a very good idea to do a snapshot before. In case of a big "oops" you can revert back. If all works nicely you can remove the snapshot file.

In Hyper-V the standard way to run a virtual machine is to use Virtual Hard Disks (VHD) and there are different kinds of VHD files, we have fixed size disks and dynamic disk. Fixed size consumes the size that the file have, dynamic files expand them self's while you store data. That means that for performance you always use fixed size disk, also to not dynamic disks, dynamic disk are very good for LAB and/or servers with low disk IO load.

This is how it works:

When you create a snapshot, Hyper-V creates a difference disk (a dynamic disk that is chained into the ordinal disk) and instructs Hyper-V to write data on that instead of the original disk.

That means that the performance will be lower and the load on the host machine will rise, not much but it will. It also means that the snapshot will continue to grow "if" changes occur on the disk, worse case it can be grow up to the same size as the original  disk, that means that you can loose 500gb of storage in just a couple of minutes in worst case, but the biggest problem is that most customers does not know that a snapshot is not deleted when they delete it, it is merged into the ordinal disk only when the virtual machines is TURNED OFF, so lets say that you run 4 virtual machines using 127gb of disk, you snapshot them and then you delete the snapshot after 1 second or so after you have done the snapshot, no snapshots right? Sorry to say byt Hyper-V will still use the snapshots, they will grow, they will have lower performance, they will be ugly when you turn the machine off because then it starts to merge....

Let the systems run for 90 days (lets assume they are web servers or something) and then when you turned them off because you want to change the configuration or something like that. Then the 4 machines will turn off and MERGE the 127GB file into an other 127GB file, all server at the same time. I have seen it, it took almost 12 hours to reboot 4 web servers, the customer did not know how snapshot works, we where also forced to add more disk capacity to be able to make room for the merge.

  1. If you use snapshot, delete them after you have done your job and turn OFF the virtual machine as soon as possible.
  2. Only use Snapshots as a temporary protection to be able to rollback, not as a backup solution.
  3. Watch disk space BEFORE shutting down a virtual machine
  4. Use fixed size disk for performance
  5. Use dynamic disk for LAB/Demo/Play/low performance
  6. If you use dynamic disk, be sure to monitor the disk
MVP_FullColor_ForScreen Mikael Nystrom - TrueSec
MCT, MVP Windows Server - Setup/Deployment
Posted: 09-20-2008 15:40 by Mikael Nystrom | with 11 comment(s)
Filed under:

Comments

Janne said:

Very good blog post!

# September 20, 2008 4:49 PM

Jonas said:

Interesting information, thanks for sharing :)

Does this architecture of thinking with snapshots applies for the VMware platform to?

# September 21, 2008 11:07 AM

Anders said:

Excellent post. Thanks a million.

# September 22, 2008 10:08 PM

Boris said:

Yep agreed fantastic blog, I was wandering where my 560 GB of Disc space disappeared and then I saw the size of the snapshot folder which was quite ugly.

Well I realised what happened when I turned off one of the computers and then I saw the blog and realised what happened.

Yep you better turn of the machine after you deleted the snapshot otherwise you are in deep *** (It took me 50 minutes to merge my mailserver so 50 minutes downtime not good at all. Anyway thanks for the blog

# October 14, 2008 1:07 PM

Mikael Nystrom said:

Thank you all, regarding VMware I really do not know, but i'll guess the story is the same there.

# January 31, 2009 3:12 PM

Attila Bognar said:

VMware ESX/ESXi: no, you don't have to shutdown the VM to clean up snapshot files.

# March 3, 2009 7:28 PM

Eric Gray said:

VMware snapshots do not behave this way -- the data will be merged while the VM is running, as soon as possible.  No need to power off the VM.  Huge snapshots will take a long time to merge, but ideally, as in the scenario described above, the snapshot will be in place for a very short time and then removed, not taking long at all.  Get the free ESXi if you want to try it and see.

I wrote a couple articles on this on my blog, may be interesting to you all www.vcritical.com/.../snapshots

# March 3, 2009 10:09 PM

Craig said:

Vmware snapshot work in the same way in that an additional disk file is created.  but you don't have to power off your VM to delete a snapshot.  Just another example of how vmware provides a more enterprise level availability of your VM's (vmotion being another example).

# March 22, 2009 2:12 PM

yoni said:

I have the same issue with snapshots on hyper-v but my work is forcing me to use snapshots regularly and not for temporary use. is there any work-around to that issue so I could use snapshots and fixed disk together?

# May 31, 2009 6:04 PM

Joel Lindberg said:

When it comes to VMware snapshots it is implemented a bit differently.

For example, when you do a "commit" of a snapshot this is done in realtime, no need for rebooting the machine...

# June 22, 2009 4:03 PM

LnddMiles said:

Great post! I’ll subscribe right now wth my feedreader software!

# July 21, 2009 6:56 PM