A number of blogs and presentations have explained the advantages of VHDX files in Windows Server 2012 over the VHD files in Windows Server 2008. These advantages include:
- VHDX files can host larger data volumes – in particular, VHDX files can host 64 TB volumes versus 2 TB for VHD files
- VHDX files have their metadata aligned on 1MB boundaries whereas VHD files have 512 byte sized metadata that cause alignment issues and in particular, cause significant slowdown when used with newer disks that use 4096 byte sectors instead of 512 byte sectors
- VHDX files are more resistant to corruption
However, VHDX files have one more huge advantage that has not been as adequately explained, or at least, seems to be less widely known. This is the fact that VHDX files are much more disk space efficient in a number of ways, especially so when the system administrator follows proper best practices. This blog and some successor blogs will explain the necessary and sufficient conditions for each particular use case, and also lay out the best practices to obtain the maximum benefit.
- VHDX files declare themselves to be storage volumes capable of thin provisioning
- When used properly, VHDX files based on appropriate type of storage can free up disk space and utilize the thin provisioning features of the underlying storage
- Even when VHDX files are placed on regular storage, best practices will prevent the VHDX files from growing in size by reusing free space within the VHDX file
So what are the necessary and sufficient conditions to take advantage of these VHDX file features? They can be summarized as:
- These tips apply to running Windows Server 2012 and Windows 8 as guest operating systems. I am hoping to find a way to have them apply to Windows Server 2008R2 and Windows 7 as well, but as of now, that is just a possibility and not a reality.
- Separate the data volume from the system volume within the VM. Don’t just put data into the system volume
- Seriously consider using dynamically expanding VHDX files rather than statically fully allocated VHDX files. Meta data overheads, for VHDX files have been considerably reduced in Windows Server 2012, VHDX files grow less often, and with the tips in this blog, they will grow even less often. The idea is to accept the minimal overhead of expanding VHDX files in exchange for storage space optimization. Note that if the VHDX file is placed on thin provisioned storage e.g. a thin provisioned Storage Space, using a fixed size VHDX file does not guarantee that the VHDX file will never face an issue of running out of disk space.
- Always present the VHDX based data volume as either SCSI or virtual HBA attached storage within the VM .
- Periodically run a PS cmdlet to optimize the VHDX based volume. In particular, run the PS cmdlet Optmize-Volume with the ReTrim option. Optimize-Volume is described at this MSDN link, and the description is certainly incomplete. While the MSDN web page claims this PS cmdlet applies to only Windows Server 2012, it certainly also applies to Windows Server 8 as well. Yours truly has submitted the web page feedback and hopefully the page is updated soon. Further note that this PS cmdlet needs to be run with administrative privileges, again something the MSDN web page does not mention.
Details of the investigation that led to this summary of recommendations will be published in follow up blogs soon.