-- Ben Armstrong, Virtualization Program Manager
Talking about core virtualization at Microsoft (Hyper-V, Virtual PC and Virtual Server).
I have been working on a personal project recently. My goal is to completely automate the process of building a virtual machine - without using templates.
As I have been working on this process, I have been making and deleting the same virtual hard disk over and over.
This causes an interesting problem. If you have a virtual machine all configured and ready to go - but you then replace the virtual hard disk file (i.e. delete the current .VHD file and create a new one in the same place with the same name) - when you try to start the virtual machine it will fail.
Instead of starting you will get an error message like this:
The problem here is the permissions on the new virtual hard disk. When you attach a virtual hard disk to a virtual machine Hyper-V will change the permissions (access rights) on the virtual hard disk. This needs to be done because Hyper-V virtual machines run under their own account, and this account needs to have permission to access the virtual hard disk. When you switch the virtual hard disk file of a virtual machine you lose these permissions.
Fixing this problem is simple - but not obvious. What you need to do is:
This should only take a couple of seconds to do, and it fixes the virtual hard disk permissions so the virtual machine will start again.
Cheers, Ben
So, it's same even if you use Hyper-V v3..
Why don't you simply check ACL of the VHD before starting process? It adds a few seconds only and should be acceptable if you are not in hurry.
icacls.exe can help to automate this, i.e.
icacls E:\NewClient.vhd /grant "NT VIRTUAL MACHINE\VM_GUID:(R,W)"
VM_GUID can be obtained from Hyper-V host WMI.
In cluster configuration, icacls.exe must be executed on the host where VM has been created.
Dmitri -
That is correct, and thanks for the extra information.
Cheers,
Ben