Adventures in VM CloningThe 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.
- Prepare the VM for cloning. All software is installed, Windows Updates are applied. CCleaner has been run.
- Run [C:\Windows\System32\sysprep\sysprep.exe]. Select the "Generalise" option and leave all other defaults.
- The machine has now had its SIDs removed and has shutdown.
- Save these template .VHD file (disk images) somewhere safe. Do NOT restart a VM based on these original files.
- Copy the VM's disk(s) for as many VMs as you are creating.
- Create new VM(s), attaching the new disk copies.
- Start the new VM(s) up, attached to the console.
- When booting, the VM will re-detect devices and ask for language settings.
- When booted, login as Administrator
- Apply network settings (which are reset if you are using Static IPs).
- Rename the machine and join it to the domain if required
- Set Windows Update settings as required
- Check all services. We had problems with Analysis Services having lost directory permissions. These were reapplied.
Cloning a production machineIn 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.