none
How to Clone VMs in Hyper-V

    Question

  •  

    I was playing around with Hyper-V but I didn't see an option to clone VMs.

     

    Is there any way to clone VMs in Hyper-V

    Sunday, January 13, 2008 5:23 AM

Answers

  • For now, I just do copies of the vhd at the file system level using Windows Explorer. I create a new container folder, copy a vhd from an existing container folder, and use the wizard for creating a new virtual machine. Within the wizard, I point to the copied vhd within the new folder that was created.

     

    This won't be suitable by itself for a production environment because the machines will be exactly the same, same name, same sid. You can run sysprep to change the name and the sid. Or rename the machine and use NewSID http://technet.microsoft.com/en-us/sysinternals/bb897418.aspx, which is not officially supported by Microsoft.

     

    I've been copying vhd files and creating new machines with complete success. Sometimes I use NewSID, sometimes sysprep, usually neither.

    Sunday, January 13, 2008 9:37 PM
    Moderator
  • We do not have a clone option built in. 

     

    You can somewhat implement your own by exporting and importing VM's.  Just be aware that you have to export a VM multiple times if you want to import it multiple times, ie once you import a VM that was exported you can't re-import from that same directory.

    Sunday, January 13, 2008 7:07 PM

All replies

  • Hi,

     

    I also couldn't find the clone option in the Hyper-V Manager. Within SCVMM there is a Clone virtual machine option, that will do the trick when SCVMM is available for Hyper-V. Until than manually copying is the solution i think..

     

    The clone VM option is a nice feature to add to the Hyper-V Manager in mine opinion.

     

    With regars,

    Ruben Spruijt

    Sunday, January 13, 2008 3:34 PM
  • We do not have a clone option built in. 

     

    You can somewhat implement your own by exporting and importing VM's.  Just be aware that you have to export a VM multiple times if you want to import it multiple times, ie once you import a VM that was exported you can't re-import from that same directory.

    Sunday, January 13, 2008 7:07 PM
  • For now, I just do copies of the vhd at the file system level using Windows Explorer. I create a new container folder, copy a vhd from an existing container folder, and use the wizard for creating a new virtual machine. Within the wizard, I point to the copied vhd within the new folder that was created.

     

    This won't be suitable by itself for a production environment because the machines will be exactly the same, same name, same sid. You can run sysprep to change the name and the sid. Or rename the machine and use NewSID http://technet.microsoft.com/en-us/sysinternals/bb897418.aspx, which is not officially supported by Microsoft.

     

    I've been copying vhd files and creating new machines with complete success. Sometimes I use NewSID, sometimes sysprep, usually neither.

    Sunday, January 13, 2008 9:37 PM
    Moderator
  • Internally we do essentialy what Paul is decribing we copy down a sys-preped vhd with an auto answer file built in, create a new VM and boot it.  This ensures we get a new SID/computer name/etc...

     

    Monday, January 14, 2008 4:41 PM
  • Hello,

     

    This thread is a great help. 

     

    Would someone mind walking a newbie through this in a little more detail, though?  I've built a VM and I want to run 4 identical VMs on the host machine (only difference is hostname and IP).

     

    I copied the VHDs, renamed them and created a new VM to use them.  It's all good.  I boot it up, change the name and IP, all good.  However, when I try to start the original VM (when the 2nd is running), I'm told that the "MS Emulated IDE controller failed to power on with error "The process cannot access the file because it is being used by another process.""

     

    So, what would be the steps here?

     

    1. Build the first VM.

    2. Create the 2nd VM.

    3. Boot up #2, change name, IP and run NewSID.

    4. Reboot.

    5. Successfully fire up #1 as well?

     

    Thanks for the time, anyone.

     

    Cheers,

    Diana

    Tuesday, January 15, 2008 12:23 AM
  • Diana, I've followed the steps you outlined successfully several times. I haven't seen the error you described. Please clarify, did you see that error after following those steps?

    Tuesday, January 15, 2008 5:26 AM
    Moderator
  •  John Paul Cook wrote:

    Diana, I've followed the steps you outlined successfully several times. I haven't seen the error you described. Please clarify, did you see that error after following those steps?



    Hi John,

    Thanks for the response.  I should have been more clear.  I'm asking if those are the steps I should take in order for this to work properly.

    My attempt that generated the error included all the steps minus the NewSID part. 

    So, sounds like if I add the NewSID step I should be okay.

    Thanks,
    Diana
    • Proposed as answer by Vincarama Thursday, June 30, 2011 10:56 PM
    Tuesday, January 15, 2008 5:38 AM
  • No, you should be okay without using NewSID.

    Tuesday, January 15, 2008 11:56 AM
    Moderator
  • UPDATE:  So, the issue seems to be the CD/DVD drive.  Server1 has this attached as "Physical Drive D:" but it won't let me do the same for Server2.  I removed the CD/DVD pass-through and it started no problem while Server1 was running.

     

    Guess that makes sense as it's a physical entity ...

     

    Thanks,

    Diana

     

    --------------------------------------------------

    Original post from earlier:

     

    Hrm, okay.

     

    Here's exactly what I did:

     

    1. Created a VM called Server1.  Got it up and running, joined the domain, all is good.  Shut it down.

    2. Created a folder called Server2 and copied the VHD from Server1 folder to Server2 and renamed appropriately

    3. Created a new VM called Server2 and pointed it to the copied VHD

    4. Started Server2 (while Server1 off), logged in, setup network, changed name, made sure it was part of domain

    5. Restarted and running fine.

    6. Started Server1 and got the error right away about the MS Emulated IDE Controller failed to power on with error "the process cannot access the file b/c it is being used by another process".

     

    Is there a SID attached to the IDE controller that needs my attention?  Server1 uses all four available IDE connections.  Three drives and the CD/DVD drive.  Server2 will do the same.  Two of the drives are pass-thoughs (each server has its own unique pair.)

     

    Appreciate the help.

     

    Thanks,

    Diana

    Tuesday, January 15, 2008 4:31 PM
  • First don't save the vhd and vmc file in the profile path like MS does by default. Normally I create a folder like C:\VMdrives or D:\VMdrives and in there I create sub folders for each client - like d:\vmdrives\WellingtonRealty
    In each folder I save the vmc and vhd - to clone just do CTRL+C CTRL+V and rename the folder what you want. import and boot the machine with no external network so there is not name conflict - change the name and run newsid - clone is complete.
    Wednesday, January 16, 2008 12:35 AM
  • Will this become available once released?

     

    Does the export take care of the SID issue?

     

    I don't mind copying as others have been, but I don't want to introduce unnecessary issues or complications in our testing and would almost rather build a new machine as needed to avoid that.   We're primarily testing with Windows 2008 so I'm not sure how the newsid type programs are going to work.

     

    Hyper-V needs to one up VMWare in all aspects to really gain support.  This is one I hope gets some attention.

    • Proposed as answer by blizzster Friday, October 29, 2010 8:36 PM
    Wednesday, January 16, 2008 2:24 PM
  • Newsid does work however Microsoft does not support it and prefers you use sysprep to change the sid.  I use newsid
    Wednesday, January 16, 2008 2:36 PM
  •  VFS wrote:
    Newsid does work however Microsoft does not support it and prefers you use sysprep to change the sid.  I use newsid

     

    So you are saying that both NewSID and Sysprep work just fine in Windows 2008 Server?

     

    I've used them before with other OS's but didn't want to mess around with the new one until someone else confirms they are compatible.

    Wednesday, January 16, 2008 3:27 PM
  • Microsoft does recommend sysprep so this is acceptable - I have used newsid and have not yet had a problem. I would recommend testing to be sure but keep in mind all the 2008 server platforms are beta so this opens the door for foolishness. I do have one 2008 server in production but it is not supported as yet.
    It is my feeling the only way to prove or disprove it to try it. I have never had an issue using newsid on 2000-2003 and have done  hundreds of these.
    If you are doing a lab / test env you should try differencing disks as this is a solid testing model that creates new child systems unique in sid and name.
    I have not tried this in HV but it works exceedingly well in MSvs.
    Wednesday, January 16, 2008 3:40 PM
  • Automating cloning / sysprepping of virtual machines is something that we will support through the use of SCVMM with Hyper-V.

     

    Cheers,

    Ben

    Wednesday, January 16, 2008 6:30 PM
    Owner
  •  

    Hi VFS,

     

    I just tried your method (I keep the VHDs and VMs in seperate folders like you do) but when I try to import the copied (and renamed) folder I get this error:

     

    "A server error occured while attempting to import the virtual machine.

     

    Importing the computer system from file 'V:\VServ4\' failed.

     

    The operation was passed an invalid parameter."

     

    The Hyper-V-VMMS event viewer shows an Event ID: 18080.

     

     

    In any event, I'm finding that "exporting, renaming folder, importing, renaming machine, connecting network" is doing the trick for now, but I wanted to try your method.

    Wednesday, January 16, 2008 7:57 PM
  • When are you coping the folder before or after the import?

     

    My recommened steps would be:

     

    Assume 5 desired copies of given VM (MyVM):

    1. Export MyVM to a new folder (MyVMCopy<copy number>)
    2. Import From MyVMCopy<copy number>
    3. Goto 1

    This will prevent copying the folder.

    Thursday, January 17, 2008 7:33 PM
  • I normally just copy the vhd and vmc files - never export only import or most of the time I will just create a new machine and add the vhd later.
    Friday, January 18, 2008 1:20 AM
  •  

    Does this apply only to machines that have already joined a domain?  We made copies of a base VM before joining it to our domain, and every copy seems to work fine.  I havent checked their SIDs, but thought each was given a new SID once it joined the domain.

     

    Thanks,

    Sean

    Wednesday, February 20, 2008 3:57 PM
  • On workstations or servers it's best practice to disjoin - boot with internal network only, then rename. Once up with new name the sid on workstations will change as part of the joining. On servers I believe the sid must be changed via newsid or sysprep although I have not been doing this and it still seems to be fine. I have 5 clones running in my lab all are domain members and one is a dc yet I never changed the sid and no conflicts - I am not saying this is good practice I am only saying in my case it seems fine. I would be interested in any known issues in this, my lazy approach.
    Wednesday, February 20, 2008 4:09 PM
  • you have to be careful with using imporitng and exporting for cloning.

     

    Exporting will neatly put a VM into a single folder (as snapshots can be in one place, vhd in another, configuration someplace else).

     

    However, importing will attach to a VM at the place it resides - the VM is not copied anywhere, it is just loaded and run from the place that the folder exists.

     

    To resolve this, the easy way is to clone a VM by preparing the golden VM with newSID or sysprep (there will be SID and manchine name issues between the copied VMs) copy the single VHD into how ever many you want, create new VMs using the wizard and attaching each to a unique VHD.

     

    This is essentially the process that SCVMM uses for deployment and cloning.

     

    Thursday, February 21, 2008 3:53 PM
    Moderator
  • Hi Ben,

     

    Will this also be something we can write provisioning code against using PowerShell, C#, etc?

     

    Thank you.

     

    Chris

    Thursday, March 20, 2008 7:04 PM
  • Yes.

     

    Cheers,

    Ben

    Thursday, March 20, 2008 7:20 PM
    Owner
  • Brian,

    I tried using NewSID on an x64 VM, and it crashes every time.  The first time it went down it was a DEP issue, and after creating an exception for it on a new VM and running it again, it crashed again - this time with a generic error message.

    Have you been able to successfully use NewSID on an x64 VM?

    Thanks.


    Mike Malter Mike Malter & Associates, Inc.
    Monday, April 20, 2009 9:26 PM
  • Hi Mike,
    We got this error while trying to use version 4.1. We went back to an older version, from 2005 and did not get this error anymore. I also found that if you delete  HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Wow6432Node
    you shouldn't get the DEP issue. Here is another post about your issue:
    http://forum.sysinternals.com/forum_posts.asp?TID=14370

    Thom Foreman MCSE, Security, Exchange
    Monday, May 04, 2009 8:59 PM
  • NewSID has been retired, and the official stance is "It is OK to have duplicate SIDs" - here is an excerpt from the SysInternal's blog post:

    "I realize that the news that it’s okay to have duplicate machine SIDs comes as a surprise to many, especially since changing SIDs on imaged systems has been a fundamental principle of image deployment since Windows NT’s inception. This blog post debunks the myth with facts..."

    http://blogs.technet.com/b/markrussinovich/archive/2009/11/03/3291024.aspx

    Tuesday, June 01, 2010 3:37 PM
  • I also read that artical. For servers I will proceed with using SYSPrep.  I could imagine  DC with the same SID might be a bit of a problem.
    Friday, January 13, 2012 8:14 PM
  • Has anyone tried using windows server backup to male clones/templates? I am thinking of doing so and then doing a sysprep. Any thoughts?
    Friday, May 24, 2013 8:04 PM
  • In order to successfully clone a VM in Hyper-V 2008, 2008 R2, 2012 or 2012 R2 in an environment without System Center or Windows Deployment Services you should do the following.

    1. Create what I have seenrefered to as a golden image. This Virtual Machine should be created in Hyper-V just the same as you would create any Virtual Machine. For this exercise we will name the VHD WS2k8r2Golden. Install any software that your company uses on ALL of the servers in your environment. Run Windows Update thoroughly. Do not install any Services.

    2. Run SYSprep using the Out of Box Experience and shutdown options. (Note: NewSID is not a Microsoft Supported solution for generating a new SID.)

    3. Once the VM has fully powered down navigate to the storage containing WS2k8R2Golden.vhd and Create N + 1 copies, where N is the number of Virtual Machines you would like to build as "Clones" of the VM we just created.

    4. Rename the N copies of WS2k8R2Golden to something meaningful such as "<name_of_server>OS" where name_of_server corresponds to the names you will be giving to each of the servers you will be building from these "clones".

    5. Begin the New Virtual Machine creation wizard but rather than create a new VHD select use an existing VHD, Navigate to the <name_of_server>OS.vhd file you are looking for and select it.

    6. Power on the VM and follow the shortened OOBE created after a SYSprep.

    7. Run Windows Update AGAIN. (This is a good habit to form, the next time you create a VM from one of these clones     

    8. Install the services needed on name_of_server.

    9. Repeat steps 5 through 8 N times.

    I have chosen to use quotations around Clones because the resulting Servers will only be nearly Identical, the use of SYSPrep will make changes to the SID, a true 1 to 1 clone of a server will create you serious issues down the line especially when the two machines are joined to the same domain.

    In order to create a clone of an existing production server it is best to power down the server copy the VHD file(s) and rename them accordingly once this is done it will be safe to turn the original server back on as long as when you build the new machine you disable the NIC's untill you have run sysprep in the manner above. If you would like more information on this process please post to this thread.


    Brendan Quinn

    • Proposed as answer by Brendan Quinn Wednesday, December 11, 2013 2:48 PM
    Wednesday, December 11, 2013 2:47 PM
  • These steps are fine and dandy, but I need to make 150 replicants.  There must be a more automated way of doing this.
    Tuesday, March 04, 2014 4:22 PM