The task
Imagine a standard operation – you need to expand vhdx size. It isn’t hard, right? Just:
- go to Hyper-V manager,
- right click the VM,
- select settings,
- select vhdx you want to expand,
- click edit
- then next
- then select expand, click next
- select new size,
- then next
- then finish.
Or you ca use PowerShell:
- Get VM hard disk location
- Resize VHD file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$VMName = 'SomeVM' | |
#Get VM disk path. Assuming there's only one VHD here | |
$VHDPath = Get-VMHardDiskDrive $VMName | Select-Object –ExpandProperty Path | |
#Verify VHD information, including current size | |
Get-VHD –Path $VHDPath | |
#Expand the disk | |
$newSize = 120GB | |
Resize-VHD –Path $VHDPath –SizeBytes $newSize |
Trouble round the corner
But then the nasty gnome comes. The task doesn’t complete. Within 30 minutes. This is a dynamically expanding disk. Shouldn’t take longer than a few seconds. You try to stop the VM from within the guest OS. No go. You try to turn it off from Hyper-V host level. No go again. VM stays in ‘Stopped-Critical’ state. You want to try and kill the process vmwp.exe that is responsible for this VM. To get that, you first need VM GUID. GUI way is to go to VM folder and check for xml name:
Now, using ProcessExplorer we can add UserName column (View-> Select Columns) and check for given GUID:
Or you can use PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$VMName = 'SomeVM' | |
$GUID = Get-VM $VMName | Select-Object –ExpandProperty id | Select-Object –ExpandProperty Guid | |
$processID = Get-Process vmwp –IncludeUserName | Where-Object {$_.Username -match $GUID} | Select-Object –ExpandProperty ID |
Not so happy ending
Now, killing vmwp process USSUALY works. It didn’t work this time and caused the vmms (Virtual Machine Management Service) to stuck. Which in the end caused the whole node to go crazy. But that’s another story.