Citrix PVS and DiskPart Fun

Today I stumbled across an error I had not seen when using the Windows DiskPart command line tool. I use Citrix XenDesktop with streamed images from Citrix Provisioning Server to provide desktops to a set of our users. Part of the best practice is when creating a new VHD file on Provisioning Server is to mount the new disk and set the partition offset to 1024:

DISKPART> create partition primary align=1024

However, when issuing the command I would receive the following error:

Virtual Disk Service error:
There is not enough usable space for this operation

After receiving this error I issued the following command:

DISKPART> list disk

Disk ###   Status          Size           Free            Dyn    Gpt

Disk 0          Online         68 GB         0 B
Disk 1          Online         100 GB     1024 KB
Disk 2          Online         0 B             0 B
Disk 3          Online         0 B             0 B
Disk 4          Online         18 GB        0 B

Disk 4 is the new VHD file I am attempting to work with. Notice under the Free column it it listed as 0 B. I ran the help command for DISKPART to see what other options are available. I stumbled across the Clean command with the a description of:

CLEAN – Clear the configuration information, or all information, off the disk.

Again after selecting disk 4 I issued the clean command and ran another list disk command this time with much better results:

DISKPART> list disk

Disk ###   Status          Size           Free            Dyn    Gpt

Disk 0          Online         68 GB         0 B
Disk 1          Online         100 GB     1024 KB
Disk 2          Online         0 B             0 B
Disk 3          Online         0 B             0 B
Disk 4          Online         18 GB        18GB


Notice that Disk 4 is now listed with 18GB free. I again ran the command to create the partition and set the alignment, this time with success:

DISKPART> create partition primary align=1024

DiskPart succeeded in creating the specified partition.