Today I needed to enlarge a virtual hard drive used by a Hyper-V virtual machine.
No problem: I used the third-party VHD Resizer which successfully copied my existing VHD to a new and larger one.
The snag: when I renamed the VHDs so that the new one took the place of the old, the VM would not start and Hyper-V reported “Access Denied”.
I looked at the permissions for the old VHD and noticed that they include full access for an account identified only by a GUID. Even more annoying, you cannot easily add those permissions to another file, as the security GUI reports the account as not found.
The solution comes from John Dombrowski in this thread:
1. Shutdown the VM
2. Detach the VHD file, apply changes
3. Reattach the VHD file, apply changes
This replaced the correct GUID for the VM.
Incidentally, this might not work if you use a remote Hyper-V manager. Permissions for remote management of Hyper-V are a notoriously prickly thing to set up. I have had problems on occasion with importing VMs, where this did not work from the remote management tool but did work if done on the machine itself, with similar access denied errors reported. If you use exactly the same account it should not be a problem, but if the remote user is different then bear this in mind.