Being careful with physical disks

One of the features of Hyper-V is that you can to connect a physical disk directly to a virtual machine.  You can only do so if the disk is “offline” in the parent partition, this is necessary to avoid the data corruption that could occur if two operating systems tried to write to the same disk at the same time.

Unfortunately it is still possible to get into this bad situation.  Two ways to do this are to:

  1. Start a virtual machine with a physical disk connected to it – and then go and online that disk in the parent partition.  This is not blocked today and will cause much mayhem (and potential data loss).
  2. Use tools that perform low level disk access in the parent partition.

I accidentally did the second one the other day when I was running some vendor specific disk test tools in the parent partition and had forgotten that I had the disks assigned to a running virtual machine.

In the future we would like to detect and block these scenarios – but for now it is up to the user to be careful when it comes to using physical disks in a virtual machines.