Jump to content
RESET Forums (homeservershow.com)

Delete orphaned VM's and VHD's


Jesse
 Share

Recommended Posts

Hello,

 

Still banging around on Hyper-V server 2012.  Anyone know how to delete the folders/VHDX's for orphaned (i.e. deleted) vm's?  When I deleted the VM's the folders and VHD's remain and I cannot find a way to delete them.  I had some luck from the command line in Hyper-V server 2012, but some of the folders will not budge.

 

Thanks,

 

Jesse

Link to comment
Share on other sites

I haven't had that problem. A few days ago, deleted a VM from the Hyper-V manager. This didn't delete the files that made up the VM. Then went to the location of the files in file explorer and deleted them. The first time I tried, it wouldn't let me, saying they were in use, so I shut down the manager and waited a minute. It then let me delete the whole folder where I had the VM files.

Edited by Sorta Oldguy
Link to comment
Share on other sites

Hello,

 

So I would need to insure that I am not remotely connected to the host via Hyper V manager and then delete from the command line on the host?

 

Thanks,

 

Jesse

Link to comment
Share on other sites

I don't really know. I was just using an RDP session when I did what I described above. Maybe there's some sort of timeout on the locks.

Link to comment
Share on other sites

When you deleted the unwanted VMs, did you by any chance have snapshots of them or had ever put them into a 'saved state' and not deleted these before deleting the VMs themselves?

 

If so then what's become locked is an xml file and a folder with the same name (it'll be a long GUID-style name) containing two files, a .bin file and a .vsv file. These are the saved state files (the bin file is a copy of the memory allocated to the VM just before shutdown and the vsv is a saved version of the VHD file itself).

 

Anyhow even though the virtual machine itself has been deleted, the host hangs on to these just in case you want to ever restore it. On the host, from the command prompt, you should be able to navigate to where the VHD(x) files are stored and there will be a folder within this called "Virtual Machines". You should be able to delete the VHDX files from the command prompt but the contents of "Virtual Machines" is locked by the Hyper-V system. In theory (at least) if the VHD files are still there, you could create a new (temporary) virtual machine with the same name pointing to the VHD files, start it up to check that it's all intact and then make sure that you delete any existing snapshots, shut it down and also delete any associates saved states for it. The you should be able to delete the VM itself and that will delete the problematic folders.

 

If you don't have the VHDX files any more then I believe it is still possible but it involves creating an new VM with the same memory and disk size settings and then renaming various files and folders in an attempt to trick the Hyper-V manager. Now I have to admit that in the one instance this has happened to me, I have never gotten it to work properly and as it is on a live production server with six virtual machines running on it, I'm not too keen to start pocking at it with the big pointy stick of IT just to see what will fall out - they are not doing any harm other than taking up a bit of disk space so I've left them alone.   

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...