You have a 250GB VHD Dynamic VHD file which has eaten too much of your Hyper-V host’s drive space (WSUS Instances come to mind). You have accessed the virtual machine and deleted/removed the unwanted bloat that occurs over time. But, you still can’t shrink the .VHD file on the host server.
Simply deleting or otherwise removing files from your virtual machine’s drive does not allow the VHD to be shrunk. You must “Zero Out” the unused sectors so Hyper-V can reclaim the space.
The How To
- Download Secure Delete from Microsoft onto the Virtual Machine
Important: Remember to unzip the file to an easy to access location.
- Open a Command Prompt
Important: Remember to launch as Administrator!
- Execute SDelete as follows (where [path] is the located you unzipped the file)
[PATH]sdelete –c -z
- Accept the terms and let it run
- Shutdown the virtual instance
- Launch Hyper-V Manager on the host server
- Open up the setting panel for the Hyper-V instance you wish to perform a VHD shrink for.
- Select the drive you wish to compact and click Edit
- Select Compact and click Finish
That is it! Your done!
Windows 2008 R2 Hyper-V server is an incredible tool in the IT pro’s test, backup, and recovery arsenal…. as long as everything meshes together nicely.
One of the more interesting errors we see in the field is the dreaded message
Error Applying New Virtual Network Changes
Binding to the external ethernet [NIC goes here] failed.
Cannot bind to [NIC goes here] because it is already bound to another virtual network.
We at AIS see this problem most often when dealing with multiple-NIC servers. The failure scenario goes something like this:
- Provision and configure Hyper-V server 2008 R2
- Access the new Hyper-V server via Hyper-V Manager on a separate PC
- Provision the first NIC under a virtual network
- Provision the second NIC under a virtual network (At this point, something goes awry in the Hyper-V Manager due to a variety of RPC / COM issues… the list of which would fill a small book)
- The second NIC provisioning is partially active within Hyper-V but is not accessible via the Hyper-V Manager
- Any additional attempts to provision the second NIC will now be met with the dreaded “is already bound to another virtual network” error
The quick and dirty solution
- Remote desktop into the Hyper-V server
- Find the command prompt window
This is usually located behind the blue colored Server Configuration prompt window
- Type the following commands to uninstall and then reinstall the Microsoft Virtual Network Switch Protocols
C:> netcfg –u vms_pp
C:> netcfg –c p –i vms_pp
These two commands will 1st uninstall the virtual switch protocols and then force a reinstall of the same protocols. This simple two step process forces the invalid virtual network mapping to be cleared from the configuration.
Happy (Virtual) Mappings!
The one function not currently well supported in Hyper-V is the movement and copying of VM and VHD files or virtual machines without using the Export / Import functionality. While it is possible to manually move VHD files, the operation is tedious and complex.
At AIS, we have discovered the need for copying VHD files ranges from moving a large .VHD from a full hard drive to quickly supporting test bench copies from a gold disk image. After the 10 or 12 manual updates of the VHD XML file, symbolic links, and security we decided it was time for a utility.
You can download and read the documentation from this link
The Windows .MSI installer is available for download via this link