Microsoft MVP Aidan Finn posted a interesting blog post about Virtual Hard Disk (VHD) Block Fragmentation. He was reviewing the document about Performance Tuning Guidelines for Windows Server 2012 and found a very important note about VHD performance.
Just as the allocations on a physical disk can be fragmented, the allocation of the blocks on a virtual disk can be fragmented when two virtually adjacent blocks are not allocated together on a virtual disk file.
The fragmentation percentage is reported for disks. If a performance issue noticed on a virtual disk, you should check the fragmentation percentage. When applicable, defragment the virtual disk by creating a new virtual disk with the data from the fragmented disk by using the Create from Source option.
Now first thanks to Aidan Finn for finding this one. But how do I create a new VHD or VHDX from a source? Simple there are two ways of doing that, the first one is over the Hyper-V Manager GUI.
Create a new VHD and give it a new name.
On the Configure Disk window check the Copy the contents of the specified virtual hard disk, and select the path to the source VHD.
Click next and finish and this will create the new VHD with the content from the source VHD.
The second and my preferred way of doing it, is of course with Windows PowerShell.
# Mount the Source VHD Mount-VHD "C:\VMs\WS2012\Virtual Hard Disks\WS2012.vhdx" # List the Disks Get-Disk # Create the new VHD (SourceDisk = Disknumber) New-VHD -Dynamic -Path "C:\VMs\NewDefragVHD2.vhdx" -SourceDisk 1
Tags: Defrag, Hyper-V, Microsoft, performance, PowerShell, VHD, VHDX, Windows Server, Windows Server 2012 Last modified: August 9, 2012
Hi Maurer , can you please give the interest in real life of cloning a DC? i can’t figure out how to use this fonctionnality
I think your comment was for this post: https://www.thomasmaurer.ch/2012/08/windows-server-2012-hyper-v-how-to-clone-a-virtual-domain-controller/
Scenarios for cloning a domain controller can be:
Rapid deployment of additional domain controllers in a new domain
Quickly restore business continuity during disaster recovery by restoring AD DS capacity via rapid deployment of domain controllers using cloning
Optimize private cloud deployments by leveraging elastic provisioning of domain controllers to accommodate increased scale requirements
Rapid provisioning of test environments enabling deployment and testing of new features and capabilities before production rollout
Quickly meet increased capacity needs in branch offices by cloning existing domain controllers in branch offices
checkout this link: http://technet.microsoft.com/en-us/library/hh831734.aspx#virtualized_dc_cloning
Ok, but where is the block fragmentation of dynamic VHDX disks reported?
I don’t see a “block fragmentation” percentage anywhere in Hyper-V Manager. Is it a Powershell command??
If so, what’s the command syntax then?
it is about the normal fragmentation percentage.. any strange one.. if you disk needs defrag.. create a new one from source.. i just guess… where i will take the time needed for this everytime.. this is very far from the scheduled defrag pratice in task manager.