Category Archives: PVS

Expanding a Citrix PVS VHD Image

Ah, Citrix Provisioning Services… argumentatively one of the most ingenious technologies when it comes to Citrix’s XenApp/XenDesktop suite. PVS gives administrators the ability to install application updates, perform image maintenance, maintain version control, etc. without ANY service interruptions to production virtual desktops. On top of that, the cache-to-RAM/overflow-to-disk option (7.1) gives storage administrators a huge relief, since all VM “writes” are written to a cache pool, located on the RAM of the virtual machine! (Read more here):

However, I have noticed one major flaw in PVS, and that is the ability to expand the base image VHD (the read-only copy that everyone is steaming from). Is it doable? Yes. Is it supported by Citrix? No (CTX118608). Is it way more difficult than it should be? Maybe. That really depends if you have decided to go to a 16MB vs. 2MB dynamic block size. Although you [theoretically] get better performance out of the 16MB block size (and sacrifice a small amount of storage, since you’re eating up the entire 16MB block, per each written block), you do lose the ability to natively manage the VHD utilizing diskpart or Hyper-V, because Windows is not compatible with the 16MB-blocked VHD! Does Citrix have this documented anywhere? Absolutely not.

If you’re lucky enough to have the 2MB block size, you can simply create a new merged base of your image, rename the VHD and PVP files, and delete the LOK file. You will then want to delete the version in the Versions window. This will delete the version from the PVS database, but since you’ve renamed it, it will not delete the VHD.

Afterward, run diskpart:

Select vdisk file=”[Location of VHD]”
list vdisk
expand vdisk maximum=[#ofMB]

You can then exit diskpart and expand the partition by mounting the VHD and expanding it in disk manager. Then take the disk offline and unmount it. Afterward, you can import the disk back into PVS.

Now, the really tricky part is expanding the VHD when you have the 16MB block size. If you try and mount the VHD like we did the 2MB-blocked one, you’ll get an error about the disk being corrupted. The only way is to convert this back to the 2MB VHD. So, how can we do that?

First, you will need to utilize a tool called CVhdMount.exe, in combination with the disk tools found in Hyper-V. Chances are, your PVS server does not have the Hyper-V role installed, so you will need to put this tool on your Hyper-V server. This tool can be found in Program Files\Citrix\Provisioning Services on your PVS server. You will also need to install the drivers found in Provisioning Services\Drivers on your Hyper-V server so that it can work with these special VHDs. Copy both the CVhdMount.exe and drivers folder to the Hyper-V host. The rest of the instructions are on Hyper-V.

Next, right-click cfsdep2.inf and hit install. Then, in device manager, add legacy hardware manually, as a storage controller.  Click Have Disk… and point it to CVhdMp.inf. This will install the Citrix Virtual Hard Disk Adapter so that CVhdMount.exe has the instructions on how to operate.

Afterward, run CVhdMount.exe -p 1 “[path to VHD]

You’ll get a magical message that the bus interface has been opened with device serial #1. Now, open up disk manager, and you will see that the disk is there! Set the disk to Offline so we can perform the VHD conversion, without risking the chance of corruption.

Next, in Hyper-V manager, select New > Hard Disk and create a dynamic VHD. Instead of creating a new blank virtual disk, copy the contents of an existing physical disk (your magically attached VHD!). This could take awhile, depending on the specs of your Hyper-V host. After the new 2MB VHD is created, edit the disk using Hyper-V manager to expand it to the new appropriate size.

Copy the VHD over to your PVS storage, import it in the PVS Console, and you should now see your new 2MB-blocked VHD!