Shrink vDisk VHD file

When you created a dynamic vDisk with Citrix Provisioning you like this file to be as small as possible, but when you remove files from the vdisk the size doesn’t shrink. To Shrink the file please use the following steps.

Before Size

Size before sDelete and Diskpart

Start the vDisk in maintenance mode and download sDelete from the Sysinternals site: here.

sDelete zero’s out empty vDisk areas and reduce storage.

After you logged on to the server which is associated with the vDisk, start an elevated command prompt. Go to the folder where you extracted the sDelete.exe folder en use the following command:

sDelete -c -z c: (where c: is the OS disk) (when you have multiple partition within one vDisk you need to use sDelete on all these partitions).

Note: sDelete can take a long time to run depending on the size.

sDelete

Using sDelete -c -z

After sDelete is completed you can shutdown the server and log-on to the Provisioning server.

On the Provisioning Server open an elevated command prompt to use Diskpart to shrink the file, follow the following steps.

  • Start Diskpart
  • Select the vDisk with the following command: Select vDisk file=”vdisk file”
  • Then use Compact vDisk to shrink the vdisk file
  • Close the command prompt
Using Diskpart

Using Diskpart

Now the vDisk has the smallest size possible for this vDisk. As you can see the file is approximately 1Gb smaller.

Size after sDelete and Diskpart

Size after sDelete and Diskpart

banner