Wednesday, 3 October 2012

Adventures in VM Cloning

Adventures in VM Cloning

The post describes how to clone a Hyper-V VM.  In this instance, an SQL Server 2012 Database Server running on Windows Server 2008 R2 in a Hyper-V Core 2008R2 VM host.  Note that you should do this on a fresh install, NOT a copy of a production machine as various details of the machine being cloned are lost during the process.
  1. Prepare the VM for cloning.  All software is installed, Windows Updates are applied.  CCleaner has been run.
  2. Run [C:\Windows\System32\sysprep\sysprep.exe].  Select the "Generalise" option and leave all other defaults.
  3. The machine has now had its SIDs removed and has shutdown.
  4. Save these template .VHD file (disk images) somewhere safe.  Do NOT restart a VM based on these original files.
  5. Copy the VM's disk(s) for as many VMs as you are creating.
  6. Create new VM(s), attaching the new disk copies.
  7. Start the new VM(s) up, attached to the console.
  8. When booting, the VM will re-detect devices and ask for language settings.
  9. When booted, login as Administrator
  10. Apply network settings (which are reset if you are using Static IPs).
  11. Rename the machine and join it to the domain if required
  12. Set Windows Update settings as required
  13. Check all services.  We had problems with Analysis Services having lost directory permissions.  These were reapplied.
And that should be it.  Loads of time and bandwidth saved.

Cloning a production machine

In this case, we cloned a VM that we needed to have running again.  We took the wrong route and ran the above process against a production box. DO NOT do what we did.

If you MUST clone a production VM, export the production VM using Hyper-V Manager first and then run this process on an import of the export VM.

No comments:

Post a Comment