This project is read-only.

Expand a dynamic VHD

May 12, 2012 at 12:35 AM

Is it possible to expand an existing dynamic VHD? I am looking at DiscUtils.Vhd.Disk class but I don't see any methods that would help me. The Capacity property is read-only.

You can do this operation in Hyper-V manager (Edit Disk) and it is instant. So I guess it just bumps the maximum disk size. It does not expand any partitions on the disk, but I don't need that. You can also do this using WMI, here is a little PowerShell script as example:

$vhdPath = "D:\8328.vhd"
$vhdNewSizeGB = 64
$ImageMgtService = Get-WmiObject -namespace "root\virtualization" -class "Msvm_ImageManagementService"
$ImageMgtService.ExpandVirtualHardDisk($vhdPath, $vhdNewSizeGB * 1024 * 1024 * 1024)

Thanks!

May 13, 2012 at 5:00 AM

Not currently supported, but feel free to add a feature request (in the issue tracker), or even take a shot at implementing it.  Things are a bit hectic, so not sure when I'll be able to look at it.

 

Thanks,

Ken