How to Delete Hard Disk Image File in Windows 10

  1. Home
  2. Windows
  3. Windows Server

Hi Folks,

I have an orphaned VHDX that I can't delete.

I have ran

                                        Get-VM                                        ComputerName                    HYPERV01                    ,                    HYPERV02                    |                    Get-VMHardDiskDrive                    |                    Select-Object                    -Property                    VMName                    ,                    VMId                    ,                    ComputerName                    ,                    ControllerType                    ,                    ControllerNumber                    ,                    ControllerLocation                    ,                    Path                    |                    Sort-Object                    -Property                    VMName                    |                    Out-GridView                    -Title                    "Virtual Disks"                                      

The disks aren't attached to any VMs

I've looked at the processes associated with disk usage and can not find anything there either.

I've also stopped the VMM service and attempted to delete it, with no luck.

I can't reboot the server, so I'm trying to find solutions that will allow me delete the vhdx without a reboot.

Any thoughts?

Edited Oct 14, 2014 at 12:54 UTC
Gary D Williams
Gary D Williams This person is a Verified Professional
This person is a verified professional.
Verify your account to enable IT peers to see that you are a professional.
Oct 13, 2014 at 18:01 UTC

Have a look with Process Explorer and see if it lists what process has the VHDX open?

Process Explorer can be downloaded from -> Process Explorer

23 Replies

Gary D Williams
Gary D Williams This person is a Verified Professional
This person is a verified professional.
Verify your account to enable IT peers to see that you are a professional.
Oct 13, 2014 at 18:01 UTC

Have a look with Process Explorer and see if it lists what process has the VHDX open?

Process Explorer can be downloaded from -> Process Explorer

JasonVivier

How can I get the GUID for a disk that isn't attached to a VM?

Neally
Neally This person is a Verified Professional
This person is a verified professional.
Verify your account to enable IT peers to see that you are a professional.
Oct 13, 2014 at 18:08 UTC

Is it mounted somewhere? That can be enough to prevent it from deletion as well.

Go to the VM where it is mounted, unmount it and try to delete it again.

JasonVivier

No it's not mounted somewhere.

Which is what the below determined.

                            Get-VM –ComputerName HYPERV01, HYPERV02 |  Get-VMHardDiskDrive |  Select-Object -Property VMName, VMId, ComputerName,  ControllerType, ControllerNumber,  ControllerLocation, Path |  Sort-Object -Property VMName |  Out-GridView -Title "Virtual Disks"                          
JasonVivier

I have several VMWP's running, but it is unclear if any of them have the VHDX opened.

techienateafs

Just a suggestion-double check disk manager on your local machine.  I've accidentally mounted vhdx files to my local computer while working with them.

JasonVivier

Thanks for the suggestion. I checked already. It isn't mounted.

tfl
tfl This person is a Verified Professional
This person is a verified professional.
Verify your account to enable IT peers to see that you are a professional.
Oct 13, 2014 at 19:16 UTC

I see this often.

1.Try stopping then re-starting the vmms service.

2. Reboot if all else fails. Not ideal, but it works...

JasonVivier

Yeah, I did already restart VMM, and a reboot is off the table until the weekend.

It's unfortunate I can't identify the process that has a lock on this thing.

JasonVivier

Okay okay, Gary has this one.

I took a look in the docs for process explorer and did a search by handle or dll substring. I found my vhdx file and the PID of the process. Which is great. But why it doesn't show up in the main window is still puzzling.

But though I've found it I can't close the handle. (Which might be for the best.)

Scott1408

I ran into this on a machine a few weeks ago, it took a restart in order to delete it.

JasonVivier

Yeah I'm not okay with that. I need to find a way to close this bastard without a reboot. :D

JasonVivier
JasonVivier

Ok so it is settled: Don't close a virtual machine worker process handler on a running system. Ultimately the VMMs service and likely others locked up after attempting to remove the handler from memory. So I had to reboot the system anyway.

Thanks for all the help everyone.

Take care,

kalpeshpatil

I have also facing same issue while deleting image hard disk image file (.vhdx) Virtual machine is already deleted, any have solution without reboot or without stop vmms.

  • I used process explore showing .vhdx file using PID 4
Dan Yedinak

@techienateafs alluded to this earlier

I was able to solve the problem by opening diskmgmt.msc on the host server. The disk was listed there, right click and choose detach. It prompts for confirmation that you have the correct file. At that point, process explorer confirms that the file is no longer open by pid 4 (nt kernel & system) and I am able to work freely with the .vhdx file.

uberchemist
uberchemist This person is a Verified Professional
This person is a verified professional.
Verify your account to enable IT peers to see that you are a professional.
Dec 14, 2016 at 01:24 UTC

I wanted to add to this thread that I'm having the same issue with a VHDX file on one of our servers. All the errors trying to delete it lead me to believe we also need to reboot. Once the right time comes (it's our file share server, so will have to wait for a late night or weekend), I'll post back with the results.

ersatyle

for me it was locked because it was merging the snapshot / checkpoints in the vhdx after I deleted the VM in the GUI.

after a while I was able to delete it.

danieljuhasz

For me that was the best option.:
(because I'm using Win10 insider preview so default option for me is PS)
Open PS -> net stop vmms

If it says that the service stopping try again later, open task manager and find vmms.exe and end process tree, then you can delete the .vmdk and after that on PS -> net start vmms

This worked for me.

Mark6567

Hi there,

I had the same issue and just to let you know it kind of resolved its self.

I deleted some VM's which had some check points (avhdx files).  After I deleted the VM in the HyperV manager the disk IO went nuts over these vm's.  So I waited and as thought its was merging the checkpoint back in.  Once complete I could delete the vhdx file without issue.

A little nutts but I guess its trying to keep things clean in case you need to re use that vhdx file etc

CharlesHTN
CharlesHTN This person is a Verified Professional
This person is a verified professional.
Verify your account to enable IT peers to see that you are a professional.
Nov 16, 2017 at 15:41 UTC

Old thread, but I came across this while trying to delete the files for a VM I had deleted.  The comments about checkpoints being merged was spot on.  In my case, I had a VM I was doing some experimentation with, and had saved multiple checkpoints at different stages.  Since I was done with it, I deleted the VM, and was just trying to get rid of the files.  Same errors as OP.  Then I started looking a bit closer, and noted that the VHDX file was growing in size.  After a bit, all the checkpoint files disappeared, at which point, I was able to delete the VHDX without any problem.

A "I care nothing about this VM...Nuke it and all its Files NOW" option would be nice.  Or maybe just call it "Skip merging the checkpoints, just trash everything associated with this VM immediately".

Stanislas BERNARD

moka works is an IT service provider.

Hi there.

Another suggestion : Server Manager, This server, Files & Disks services, iSCSI : Delete iSCSI Virtual Disk.

Have a good day.

Ozzi6752

I had to detatch it in Disk Management first.

This is a little bit painful to watch, but it worked.

https://www.youtube.com/watch?v=1c25bEq1ekg

This topic has been locked by an administrator and is no longer open for commenting.

To continue this discussion, please ask a new question.

How to Delete Hard Disk Image File in Windows 10

Source: https://community.spiceworks.com/topic/603713-solved-vhdx-can-t-be-deleted

0 Response to "How to Delete Hard Disk Image File in Windows 10"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel