How do I clone the virtual disk of running VM on Hyper-V 2012 -


i want clone virtual disk of running vm on hyper-v 2012.

i know snapshotting vm generate diff disk (file extension .avhdx). subsequent writes snapshot, , parent read only.

however, parent may snapshot, means cannot copy parent.

how obtain single file contains virtual hard drive’s data prior snapshot?

put way, how export parent of current snapshot single .vhdx file?

ideally, know how using hyper-v v2 wmi api.

hyper-v 2012 , later supports live merge of snapshots not export of running vm.
hyper-v 2012 r2 supports live export. so, upgrade , move on, nothing see here.

however...

if take snapshot of vm, can add differencing disk parent disk of snapshot, create vm that, export vm, destroy vm, destroy differencing disk.

it seems round-about, way know of "cloning" running hyper-v vm (as vhd becomes issue, settings can copied , new vm created, settings don't need 'cloned').

if vm not have snapshots, need create 1 make work. 'cloning' snapshot while running vm state allowed write avhdx known 'now'.

since copy being created never powered on, cpu , ram not matter.

because not snapshot, export hyper-v gives differencing disk plus parent.
if exported snapshot single virtual disk, since hyper-v special things avhdx files.
if want single file, merge diff in export. merge ends breaking configuration of exported vm, since differencing disk deleted have rename it.
again, doing copy of disk in clean (and proper) way.

yes, lot of work running export. , avoid file locking issues virtual disks.

no time complete code, walked through powershell verify possible.

$snap = get-vmsnapshot "datest"  ps c:\windows\system32> $snap.harddrives  vmname controllertype controllernumber controllerlocation disknumber path                      ------ -------------- ---------------- ------------------ ---------- ----                      datest ide            0                0                             d:\datest\server2012.vhdx   ps c:\windows\system32> new-vhd -differencing -parentpath $snap.harddrives[0].path -path d:\test\test.vhdx   computername            : sweetums path                    : d:\test\test.vhdx vhdformat               : vhdx vhdtype                 : differencing filesize                : 4194304 size                    : 42949672960 minimumsize             : 42948624384 logicalsectorsize       : 512 physicalsectorsize      : 4096 blocksize               : 2097152 parentpath              : d:\datest\server2012.vhdx fragmentationpercentage :  alignment               : 1 attached                : false disknumber              :  isdeleted               : false number                  :    ps c:\windows\system32> new-vm -name test -path d:\test -vhdpath d:\test\test.vhdx   name state cpuusage(%) memoryassigned(m) uptime   status             ---- ----- ----------- ----------------- ------   ------             test off   0           0                 00:00:00 operating   export-vm -name test -path d:\newtest -passthru  # fullname of parent disk renaming later  merge-vhd 'd:\newtest\test\virtual hard disks\test.vhdx' -force  rename-item 'd:\newtest\test\virtual hard disks\server2012.vhdx' 'd:\newtest\test\virtual hard disks\test.vhdx' 

i have blog of now..


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -