VHDX file investigations on regular spinning disk

Refer my earlier blog on VHDX file best practices. This blog explains the details behind how I arrived at those recommended best practices. Based upon a TechEd talk, I ran a series of experiments with VHDX files. While the investigations led to the summary published in my previous blog, there also remain some unanswered questions. So far, my attempts to find answers to these questions have remained unfruitful. Presumably the appropriate Microsoft personnel are extremely busy. Once I publish what I found, I will publish my questions as purely that – questions, in the hope that some fellow MVPs may have some insight.

For the investigation, I created a Windows 8 based guest VM running on a Windows Server 2012 Hyper-V host. I created a dynamically expanding VHDX file and attached it as a SCSI attached volume to the Windows 8 guest. The investigation consists of performing a series of operations on the Windows 8 SCSI attached volume and observing the size of the VHDX file backing that SCSI attached volume. For the purposes of this particular blog, the VHDX file was placed on an external USB spinning hard disk, which was not thin provisioning capable.

Operation

VHDX file size in   bytes

Create an   empty dynamically expanding VHDX file that is not yet initialized and not yet   NTFS formatted

4,194, 304

 

Initialize   the disk as MBR partitioned & NTFS format the volume

205,520,896

Copy a   single file of size 949,350,400 into the VHDX file

1,178,599,124

Delete the   file, make sure it is deleted from recycle bin as well

1,178,599,124

Shut down   the VM

1,178,599,124

Run PS   cmdlet Optimize-VHD with Mode Retrim on the VHDX

1,178,599,124

 

The fact that Optimize-VHD did not shrink the VHDX file was both a little surprising and disappointing, but presumably the error is mine. After numerous presentations that claimed the TRIM/UNMAP commands flowed from the guest VM into the parent partition, I was under the impression that given a Windows 8 guest OS and a Windows Server 2012 Hyper-V host, the TRIM/UNMAP commands flowed natively. Perhaps they do, and I don’t understand it. But requiring a PS cmdlet to make them flow is not what I would call native.

The next experiment I performed was to see if the VHDX file reused space freed up

Operation

VHDX file size in   bytes

Create an   empty dynamically expanding VHDX file that is not yet initialized and not yet   NTFS formatted

4,194, 304

 

Initialize   the disk as MBR partitioned & NTFS format the volume

205,520,896

Copy a   single file of size 949,350,400 into the VHDX file

1,178,599,124

Delete the   file, make sure it is deleted from recycle bin as well

1,178,599,124

Copy the   file again

2,118,123,520

 

Note: The implication is quite obvious. Without any intervention, the VHDX fie does not neccesarily reuse the recently freed up disk space, even when the amount of new space required is exactly equal to the recently freed up space

The next experiment I consisted of using the PS cmdlet Optimize-Volume, again with the ReTrim option.

Operation

VHDX file size in   bytes

Create an   empty dynamically expanding VHDX file that is not yet initialized and not yet   NTFS formatted

4,194, 304

 

Initialize   the disk as MBR partitioned & NTFS format the volume

205,520,896

Copy a   single file of size 949,350,400 into the VHDX file

1,178,599,124

Delete the   file, make sure it is deleted from recycle bin as well

1,178,599,124

Run PS   cmdlet Optimize-Volume with Retrim option

1,178,599,124

Shut down   the VM

205,520,896

 Note: Shutting down the VM is not really an option in production systems, but it certainly is an option for people like my fellow MVPs running VMs on their laptops.

And now, let me describe the last, but most important experiment for this blog. I expect to write more blogs on this topic.

Operation

VHDX file size in   bytes

Create an   empty dynamically expanding VHDX file that is not yet initialized and not yet   NTFS formatted

4,194, 304

 

Initialize   the disk as MBR partitioned & NTFS format the volume

205,520,896

Copy a   single file of size 949,350,400 into the VHDX file

1,178,599,124

Delete the   file, make sure it is deleted from recycle bin as well

1,178,599,124

Run PS   cmdlet Optimize-Volume with Retrim option

1,178,599,124

Copy the   same single file again

1,178,599,124

 

Note: The implication again is quite obvious. Running the PS cmdlet Optimize-Volume allows the VHDX to reuse the newly freed up space.  

 

About these ads
Post a comment or leave a trackback: Trackback URL.

Trackbacks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: