Cloning a VM on Hyper-V without shutting it down

{note: this post is deprecated, it is now possible to do “live cloning” using VMM 2012 R2, See my newer post below}

Create clone of running VM using VMM

My OLD post:

If you use SC VMM’s own VM cloning functionality, you see two major problems:

  1. You have to shut down that VM, and
  2. The original VM gets destroyed.

Of course this is not acceptable if you are trying to create a dev VM out of a production VM.

Here is how you can clone a VM without these problems:

  1. Using VMM, create a checkpoint (snapshot) of that VM. Wait for the process to finish. This quieses the VHD, making it ready to be copied.
  2. Go the the HV server and copy the VHD to another location, say temp.
  3. Delete the VM’s snapshot, you do not need it anymore….and is a good practice to delete snaps ASAP.
  4. Create a new VM, leaving the NIC disconnected. I leave the NIC disconnected because when you boot this VM, there is a possibility that there will be an IP address conflict (not 100% sure about this, though)
  5. Copy the VHD sitting in temp to the directory which was created by the new VM creation process.
  6. Attach the VHD you just copied to the new VM
  7. Boot the VM and logon as local admin
  8. Run Sysprep from C:\Windows\System32\sysprep
  9. Check the “generalize” checkbox, choose reboot option (default)
  10. Change the IP the VM to something unique
  11. Add to domain, if needed.
  12. Done!

 

Notes:

  • I am copying the VHD in temp instead of moving it so that I can create more clones. You can just move that VHD if you have no need for more clones.
  • Also, it is better to make a VMM template from the copied VHD. I did not have time to do it because people needed the VM like, yesterday Winking smile But now that that VM is ready for them, I am free to create a new VM from the VHD in temp, then use VMM to create a template. That syspreps automatically and creates a template in VMM’s library which then can be used to deploy new VM clones easily.

Troubleshooting Windows Remote (WinRM)

Here are a few commands which can be run to troubleshoot Windows Remote (WinRM) connectivity (These commands may need to be run on an elevated CMD):

This shows you which port and IP addresses WinRM is listening to:

winrm e winrm/config/listener

This checks if WinRM has some problem:

winmgmt  /salvagerepository

This shows you the configuration:

winrm get winrm/config

 

I ran these commands on my Hyper-V nodes and VMM server, while troubleshooting connectivity / permission related errors.

Hyper-V 2012 Access Denied

While trying to connect from a Windows 8 Enterprise client machine to my Windows Server Hyper-V 2012 server via the Hyper-V Manager, I kept getting this error message:
“Access denied. Unable to establish communication between Client and Server”.

I found a way to fix this. Here is how:

  1. From the command prompt of the  client open a command prompt and type DCOMCNFG
  2. Go to: “Component Services > Computers > My Computer”.
  3. Open Properties for “My Computer” and select the COM Security tab.
  4. In “Access Permissions” area click the “Edit Limits” button.
  5. Select the “Anonymous Logon”-group and make sure the “Remote Access” is set to Allowed.

Now your client will connect successfully to the server.

Note that for server management “Server Manager >> Computer Management” you still need a firewall rule on the server or simply disable the firewall completely [not recommended] using this command:

netsh firewall set opmode mode=disable