Clone virtual machine with Server 2008 R2 and Hyper-V?

7,166

I can't answer your question directly, but perhaps help a bit anyways. First of all, I was going to do some exporting and importing when rebuilding out two Hyper-V servers as a cluster when R2 came around with Live Migration support. I tried exporting and importing, but could not get it right. I found no simple answers to why either, so I simply ended up creating new VMs and attaching the VHDs on them. That worked fine, just make sure you don't have any snapshots.

That said, if you are going to be seriously using Hyper-V I recommend you go with SCVMM. SCVMM lets you manage, template and provision VMs in a very nice UI. I think the pricing is reasonable for what it offers. It also lets you clone VMs easily.

(WARNING: I got lunch and a donut from MS yesterday and I may still be biased. Donuts do that to me.)

Share:
7,166

Related videos on Youtube

bwerks
Author by

bwerks

Updated on September 17, 2022

Comments

  • bwerks
    bwerks over 1 year

    I've recently just started working with Hyper-V, and so far it's quite nice. However, I've been running into problems with what seems like it should be the most basic of workflows. I've set up a baseline Server 2008 R2 configuration, and exported it with the intention of using the export for cloning. I entered "C:\Exports\" as the export folder.

    However, I run into problems when I try to import the image. From the Hyper-V manager, I select "Import Virtual Machine" and in the resulting window I entered "C:\Exports\BuildServer\" as the folder, set the radial to "Copy the virtual machine (create a new unique ID)" and checked the checkbox for "Duplicate all files so the same virtual machine can be imported again." Doing so results in the following error:

    "Import failed. Import task failed to copy file from 'H:\Exports\BuildServer\Virtual Hard Disks\BuildServer.vhd' to 'C:\Hyper-V\Virtual Hard Disks\BuildServer.vhd': The file exists. (0x80070050)"

    Have I somehow messed something up in configuration? Or is this a known thing? I've read it should be possible to clone VMs by copying them in the filesystem but I'd prefer to keep things in the management Ui if possible.

  • bwerks
    bwerks about 14 years
    This is good to know! I can certainly agree that there's little documentation, official or social, to explain why this doesn't work. I'm a little disappointed that a product with so few features can't at least manage to get it right. I'm a very small organization, so I don't know exactly how deep my VM usage will go, but for now it seems I can get SCVMM through MSDN so I'll certainly give it a shot. Thanks for the tip! As for your solution without SCVMM, can I assume that you were copying the vhds before attaching them? Why are snapshots bad? Is snapshot information stored in the vhd?
  • Gomibushi
    Gomibushi about 14 years
    Yes, Hyper-V without SCVMM is not a very good virtualization solution. Yes, I turned off the VM, copied the VHD to the new server storage. Made a new VM, and selected to attached the VHD(s) identically as they were on the original VM. In short I dropped the XML config files and the few other files and just moved the VHDs. Mind you, I would never risk mounting it like that without a backup. Once you see it runs fine (and it should), then you are clear.
  • Gomibushi
    Gomibushi about 14 years
    Snapshots are bad period. A snapshot is a basically differencing VHD so you can revert to the original state (the VHD). Snapshots should never be used in production in my opinion, except for trying out an upgrade or new config, and having a quick way of reverting back. I still would make a proper clone of the VM too. You should never run off a snapshot permanently, but they are excellent for lab use and experiments.