Error while Expanding Disk Space of virtual machine in Hyper-V server

hard drivehyper-vvirtualizationwindows-server-2008

I have one Virtual machine running on my hyper-v server which has allotted the disk space of 100GB, i have only created C drive in this machine and C drive of this machine is fully consumed due to which my website is down. I turned off the machine and tried to expand the hard disk by 100GB for this virtual machine.

I have enough space left on my Hyper-V server.
i clicked on

 settings > scsi > given location of my *.vhd file > edit > expand > and expanded the disk size to 200GB > finsh > apply

when i clicked to apply after doing all the settings i got the below error.

enter image description here

I searched for this but most of links which i found they did not pointed me to right direction, links guided me about switching off the vm and then proceed again for expanding this, but i already did this after shutting down the machine. May anyone kindly guide me on this. Thanks in advance.

Best Answer

In this case, disconnect the VHD from the virtual machine. This implies removing it from the virtual machine configuration, modifying the image, and then re-adding it. This is common to have to do on a lot of hypervisors in some capacity or another just to get the disk info for the VM itself updated. This is a little more extreme, but with the way Windows handles locking I'm not entirely surprised.

So remove the drive > resize the drive > re-add the drive, pointing to the same .VHD. DO NOT delete the file. Just detach it.

Hopefully that works. If it doesn't, I would suspect a bad lock of some kind, but we'll move into that if we have to.