How to exclude VHDX disk from snapshots on Hyper-v

hyper-vsnapshotvirtualizationwindows-server-2012

(I'm using the built-in Hyper-V that comes with Windows Server 2012 R2)

I want to play with my snapshots while I have a separate disk that would not be affected by those snapshots, thus I can store separately installation files etc.
(I could do this easily on VMWare)

How can I define such disk on Hyper-v?

Best Answer

Snapshots in Hyper-V include, in addition to the virtual disks, the state of memory and the virtual processors (along with sundry other stuff.) So when you apply the snapshot, anything that was in the virtual machines memory related to the file systems on the virtual disks is still there, and still coherent. The file systems on the virtual disks don't get corrupted specifically because they are in sync with the in-memory state of the OS running in the VM.

If you were to exclude a VHD from the snapshot, and then you applied the snapshot, the file system on the VHD would immediately be corrupted, because the in-memory file system state would assume that the virtual disk was in the same state as the moment the snapshot was taken. It would flush out pending writes, which would then be written to the VHD. And since the VHD wasn't part of the snapshot, the on-disk structures would have changed and now it's garbage.

If you really want a file system that doesn't come along with the snapshot, one which will be coherent when the snapshot is applied, you need to make that file system external to the VM itself, or you need to make it read-only. The easiest answer, of course, would be to put the files you want to keep constant on a file share on a file server somewhere. You could also make an ISO image -- they're read-only.

Related Topic