Let's say we have 64GB of Dynamically Expanding VHDX. After installing the OS, the "dynamically initialized" space is something around 10GB. Now, I know that I'm gonna need about 25GB more space - e.g. a total of 35GB.

QUESTION: How can I force the initialization of either part (e.g. the 35G) or the rest of the VHDX file?

MOTIVE: When the virtualized system undergo some additional software installation, the process is slower, because in addition to installing the files, the VHDX needs to initialize the additional space. So I'd like to be able to initialize the space in advance and when the time comes, the installation of the additional software won't take forever.

  • Better way: create your static size VHDX harddisk first, so you won't have to bother with that. – Lenniey Oct 6 '17 at 7:23

The easiest way would be to run any disk benchmarking tool that will create a test file of a desired size forcing the VHDX below to expand.

You can use Microsoft DiskSPD for this purpose: https://gallery.technet.microsoft.com/DiskSpd-a-robust-storage-6cd2f223

The command line will be something like that:

Diskspd.exe -b64K -d10 -h -L -o1 -t1 -s -w100 -c20G c:\io.dat

Where -c20G is the desired size and c:\io.dat is the file path.

After deleting the created test file you will free the space but the VHDX remains floated.

Hope it helps.

  • 1
    Indeed, this sounds very clever, but the file didn't get actually created. It is reported by the FS of size 20GB, but the size of the VHDX is currently ~8GB. – Bozhidar Stoyneff Oct 6 '17 at 9:04
  • 1
    Seems like it was not enough time for application to fill the file. Increase -d parameter to ensure there is enough time to perform all the needed writes ;-) – Net Runner Oct 12 '17 at 6:17

Please use sysinternal sdelete with the z switch.

sdelete -z <driveletter:>

The z switch zero fill empty space with zero, thus your image will grow to 100% of it size.

Note, to cut the space after its with the diskpart compact vdisk command you could do it, it cut free space marked as zero from the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.