Delete Windows Server 2012 Virtual Hard Disk

I noticed on Windows Server 2012 Datacenter edition that deleting a virtual hard disk is a little tricky. This is by design, of course. Imagine deleting your Production server database or web site after a clean up or maintenance cycle. It is not easy to do. If there is a an actual hard drive associated with a Hyper-V virtual machine, it is impossible to delete without tearing things down first. This is good. But even with excellent clustering, replication or {insert fail over of your choosing}, it’s still not good to remove a virtual machine ‘by mistake’.

But let’s say you need to clean up the virtual machines and drives on a large server? The Volumes, Drives, and/or Disks can grow rapidly. Before you know it, you do not know what is what. You can really see this by the location of your Virtual Hard Disks and Hyper-V files (config files). This can get messy if you are storing the virtual machines in different places (don’t do this). So, let’s say a few test servers are set up quickly. Some testing is done and as you are about to remove all virtual disks and machines associated with these testers, you get called off on another project or emergency. You will get to these disk ‘another time’.

But it is forgotten. Before you know it you need some space over n your Exchange Servers. A clean up of unused machines is needed to reclaim space.

This is what I learned. The first step occurs before any of this, when planning out your infrastructure. Namely, pay attention to Virtual Machine NAMING SCHEME. Be sure there is a rhyme and reason to it. In the modern age, you likely do not want to call the virtual machines by the company name + number, i.e. CoolStartup1, CoolStartUp2, etc. What happens if the company gets bought, renamed? Also, it is helpful to use function in the names: ServIIS1 or SERVER_SSL1, etc. This is important as in time, you may need to remove servers from the virtual environment. In other words, be organized.

To remove a Virtual Hard Disk, you first need to locate it, then detach it. First, I verified the ones CURRENTLY IN USE. Screen shots are nice for your own reference. These are not to be touched.
Next up: open Computer Management/Storage/Disk Management. This area is clear on a home laptop, but on a fully raided beast of a Windows Datacenter 2012 Server, this can be blinding. Depending on your scenario, you may have dozens and dozens of Data Partitions and Disk drives. Verify your Disk to be deleted is correct. Right-click the Disk (#), and select Detach VHD (Virtual Hard Disk). In the Detach Virtual Hard Disk window, verify all is good. You will see the name of the .VHDX file that is associated with your virtual machine to be deleted. Hopefully, the names of your machines are logical. Then you can confirm.

This clears it from this interface. But in order to delete the virtual machine’s folder, the one with the large .VHDX file, you may need to find the SYSTEM RESERVED drive within Disk Management. Right click the virtual hard disk and try to Mount. This should yield a System Reserve drive letter. That needs to be deleted, then you should be able to delete the .Vhdx.

Leave a Reply

Your email address will not be published. Required fields are marked *

8 + 2 =