Extending a PVS vDisk

Posted on 2011/11/06

Ever need to increase the size of a Provisioning Services (PVS) vDisk, for instance when an application upgrade needs more disk space than planned when creating the vDisk? Well, if so the process I use is fairly simple to complete and preserves the existing data.

With the older vDisk formats (PVS 5.x and earlier) you can use the VHD Tool executable available on Microsoft’s MSDN website at http://archive.msdn.microsoft.com/vhdtool. The VHD Tool can be used to create, repair, extend, or convert a VHD. For this process, we are going to use it to extend the the existing PVS vDisk image.

Before beginning you will need a vDisk that is not in use by any PVS target devices. You can copy the exisiting vDisk or just shutdown all the target devices that are currently locking the one you would like to extend.

WARNING: While this process is designed to keep any existing data on the vDisk and to just extend the NTFS volume, the risk of corrupting the vDisk file is always present due to failures outside the process control. Therefore, be sure to take a full backup of the vDisk before continuing.

1. Use VHD Tool to extend the size of the existing vDisk by supplying as paramaters to the binary both the VHD file name and the size in bytes you would like the vDisk.

vhdtool.exe /extend “<pathToVdisk>\filename.vhdNewSizeInBytes

Example to extend c:\vdisks\w2k8-base.vhd to 120 GB [120*1024*1024*1024 = 12884901880 bytes], use this command-line.

vhdtool.exe /extend “C:\vDisks\W2k8-BASE.vhd” 128849018880

2. Wait for the extension operation to complete, it could take a a while. The exention below took 30 minutes to complete when moving from a 72GB to 120GB vDisk, probably because I use the fixed-size VHD format. I suspect dynamic VHD’s might extend faster.

Using VHD Tool

If you are using a version PVS 6 or later, the vDisk format changed, so the VHDTool will only corrupt your vDisk file. Instead use the Powershell cmdlet Resize-VHD. This cmdlet can be found as part of the Hyper-V module.

Resize-VHD -Path <PathtoVHD>” -SizeBytes <FinalSizeInBytes>

For example, this Powershell command will extend the vDisk to 40GB:

Resize-VHD -Path “c:\vdisks\MyVDisk.vhd” -SizeBytes 42949672960

Since the VHD most likely represents a boot or system volume, you cannot extend it from within the operating system when streaming it from a PVS server; however, you can mount that VHD on another computer as a secondary drive and from there perform the extension. Any Windows Server 2008 or later server should work, I tend to use the PVS servers which run Windows Server 2008 R2 in my environment.

3. From the PVS server, mount the VHD file through the Disk Management MMC plug-in and the Attach VHD command

4. Right-click on the newly mounted VHD (vDisk) and choose Extend Volume… from the context menu. Run through the “Extend Volume” wizard selecting the new disk and the new size on the second dialog. Click Finish when you are done.

Extending the volume via Disk Managment

Running the Extend Volume Wizard

5. Detach the VHD by right-clicking on the disk in the MMC and choosing Detach VHD from the context menu.

If you are not modifying an existing vDisk, go ahead an import the new vDisk into the PVS console. If you were modifying the vDisk, performing a Refresh action at the PVS console should immediately reflect the new disk size.

Just boot your target devices off the new vDisk and enjoy the extra disk space.

If you have comments feel free to add them below. If you found this article useful and would like to be notified of future blogs, please follow me on Twitter @pwilson98.