Before we begin, I´d like to point out the obvious: You want to clone a VM that is as clean as possible (without needing to install all the software on each clone of course). So clone your VM before creating any sites, since all references will be broken when you change the name.
This has been tested with a VM containing the following software:
- Windows Server 2008 R2
- SQL Server 2008 Express
- SharePoint 2010 Enterprise
- Visual Studio 2010 Premium
- Office Professional Plus 2010
First, the best way to clone the VM for use in your Hyper-V setting. Contrary to what you might expect, this is not by using the export/import functions of Hyper-V Manager. This is actually meant for backup/restore.
The best way I have found is to just stop the VM you want to clone, copy the VHD, create a new VM definition and attach it to the copied VHD.
Next, the VM must be renamed. These steps are based on the MOSS 2007 cloning steps outlined here: http://www.sharepointdevwiki.com/display/public/Cloning+a+SharePoint+Virtual+Machine
- Stop the SharePoint Search services(s). I stopped both the “SharePoint Foundation Search V4” and “SharePoint Server Search 14” services to be sure.
- Go to System Properties and rename the VM, but don’t restart yet.
- Open “SQL Server Management Studio” and connect to “(local)”.
- Run the following query:
EXEC sp_dropserver '<old_name>' GO EXEC sp_addserver '<new_name>', 'local'
- Run the “renameserver” stsadm command:
stsadm -o renameserver -oldservername <old server name> -newservername <new server name>
- Now restart the VM.
- Rebuild Central Administration:
psconfig -cmd adminvs -provision -port 12345 -windowsauthprovider onlyusentlm
- Restart IIS.
- Open Central Administration and delete the applications that are based on the old machine name.
Aaaand, you’re good to go.