I learned how to do this at TechEd 2004 in a lab led by Robert Larson, one of our resident Virtual Server gurus.
You can create a “base” virtual machine with the operating system and applications you want, and then copy its .vhd file to use for other virtual machines. When you do this, it’s important to run a tool called Sysprep on the base virtual machine. That way, when you start a virtual machine that uses a copy of the base virtual machine’s .vhd file, the guest operating system will be assigned a new SID, GUID, MAC address, and so forth when it starts up. This way you won’t end up with network conflicts between different virtual machines that use the same copied .vhd file.
- Do not perform this procedure on the host computer!! Perform it only within the guest operating system of the virtual machine you want to clone.
- Microsoft does not support using a tool other than Sysprep for cloning virtual machines. For more information, see this Knowledge Base article: http://support.microsoft.com/Default.aspx?id=162001.
Step 1: Install the Setup Manager files in your guest operating system
- Set up a base virtual machine by installing the operating system, service pack, patches, applications, and so forth that you want to clone.
- Start the guest operating system and log on as a local administrator.
- From the guest operating system, go to the Microsoft Web site and download the appropriate Sysprep version. Extract the files to a folder such as C:\Tools on the guest hard disk. You can obtain the SysPrep files from the following locations:
Windows 2000: http://www.microsoft.com/windows2000/downloads/tools/sysprep/default.asp
Windows XP: http://www.microsoft.com/downloads/details.aspx?FamilyID=7a83123d-507b-4095-9d9d-0a195f7b5f69&DisplayLang=en
Windows XP SP2 and Windows Server 2003: http://www.microsoft.com/downloads/details.aspx?FamilyID=3e90dc91-ac56-4665-949b-beda3080e0f6&displaylang=en&Hash=RWRPDM9
Step 2: Create an answer file
Note: This procedure applies to the Sysprep version for Windows Server 2003. You’ll need to modify the steps for other versions of Sysprep. The files that you extracted from the Microsoft Web site include a help file named Deploy.chm that has specific information for your version. It’s a good idea to read the help file and become familiar with this tool and figure out how to customize the following steps for your own environment and purposes.
- In the Tools folder on the local disk of the guest operating system, double click Setupmgr.exe to start the Setup Manager wizard.
- Click “Next.”
- Select “Create New” and click “Next.”
- Select “Sysprep Setup” and click “Next.”
- Select the type of guest operating system and click “Next.”
- Select “Yes – Fully automate the installation” and click “Next.”
- Type a name and organization, click “Next.”
- Accept the default display settings by clicking “Next.”
- Select your home time zone and click “Next.”
- In Product Key type the product key and click “Next.”
- In licensing, select the type of license for the guest operating system, and click “Next.”
- Type a computer name for the guest operating system and click “Next.”
- Set the administrator password and click “Next.”
- To ensure that the password will be set, the machine’s password must be blank. Press Right-ALT + DEL and click “Change Password.” Type the old password and leave the new password blank. Click “OK.”
- Select “Typical Settings” and click “Next.”
- Leave the machine in a workgroup and click “Next.”
- Customize the next few screens of additional settings as necessary. If you don’t know what they’re for, accept the defaults.
- In “Identification String” type the computer name and click “Finish.”
- Specify C:\Tools\Sysprep\sysprep.inf for the location for the .inf file.
- Click “Cancel” to close the Setup Manager wizard.
- You now have a C:\sysprep folder with your sysprep file and copy stored at C:\tools\sysprep\sysprep.inf.
Copy Sysprep.exe and Setupcl.exe from C:\Tools\Sysprep to C:\Sysprep.
Step 3 – Sysprep the guest operating system
- Close all windows in the guest operating system.
- Click “Start” and then “Run.”
- Type C:\sysprep\sysprep.exe and press Enter.
- This starts the Sysprep process. Click “OK” to clear the warning dialog.
- Select “Do not reset grace period for activation.”
- Make sure that the shutdown mode is “Shutdown.”
- Click “Reseal.”
- When prompted about regenerating SIDS, click “OK.” The guest operating system will be Sysprepd and will automatically shut down.
- Remove the base .vhd file from the virtual machine, and in the file system, make the base.vhd file read-only. You need to do this because you do not want to start a virtual machine by using this base .vhd file. If you do, it will undo the whole process that you just went through.
You can now make copies of this .vhd file and attach them to different virtual machines. After you copy the .vhd file, you need to remove the copy’s read-only attribute. When you start a virtual machine with a copied .vhd file, it will receive a unique SID and other identifiers. You can also use the base .vhd file as the parent drive image for several differencing drives. The unique identifiers for each guest operating system built in this way will thus be written into the differencing drives, and not the parent.
Note: The fourth time you run Sysprep on the same media, you receive the message, “Your grace period limit has been reached and will not be reset.” For more information, see http://support.microsoft.com/default.aspx?scid=299840.