Expand VHD window 2003 is no longer moving into the new space
i using powershell script expand vhds. @ 1 time able expand drives , windows 2003 move newly added space. no longer working new space seen unpartitioned space. know there several work around fix issue can tell me why funtionality changed.
here script have been using
thanks in advance
sc
# expand vhd
param(
[string]$vhdpath = $(throw "must specify full path vhd"),
[string]$vhdsize = $(throw "must specify expansion add vhd (in mb)"))
# size in bytes
$mb = [system.uint64] $vhdsize*1024*1024
#obtain msvm_imagemanagementservice class
$imagemgtservice = get-wmiobject -class "msvm_imagemanagementservice" -namespace "root\virtualization"
# create dynamic vhd
$result = $imagemgtservice.expandvirtualharddisk($vhdpath,$mb)
#return success if return value "0"
if ($result.returnvalue -eq 0)
{write-host "operation completed sucessfully"}
#if return value not "0" or "4096" operation failed
elseif ($result.returnvalue -ne 4096)
{write-host "operation failed"}
else {#get job object
$job=[wmi]$result.job
#provide updates if jobstate "3" (starting) or "4" (running)
while ($job.jobstate -eq 3 -or $job.jobstate -eq 4)
{write-host $job.percentcomplete
start-sleep 1
#refresh job object
$job=[wmi]$result.job}
#a jobstate of "7" means success
if ($job.jobstate -eq 7)
{write-host "operation completed sucessfully"}
else
{write-host "operation failed"
write-host "errorcode:" $job.errorcode
write-host "errordescription" $job.errordescription}
}
hi,
if extend vhd file through script or gui such hyper-v manager, symptom encountered expected behavior.
for example, original vhd 30gb, extend 50gb, after extend, able find 20gb’s unallocated disk space @ end of disk.
by way, system behavior, need extend yourself, or can create new partition/volume.
in addition, if have 1 partition(c: drive) within windows server 2003 vm, not able extend system partition directly, because don’t support extend system partition in windows server 2003. more information, can refer following post.
extending boot partition hyper-v vm disk
vincent hu
Windows Server > Hyper-V
Comments
Post a Comment