If you need to install more than one Virtual Machine using the same O.S. with Virtual PC, creating each virtual machine and installing the O.S. separately is very time consuming. To speed up the process, it is possible to create 1 virtual machine, install the Operating System, all other applications common to all virtual machines and then clone it.
The first virtual machine and its clones should be created as a stand alone machine (belonging to the workgroup “WORKGROUP”) and, if needed, add them to a domain after the cloning process. I did not try to clone a virtual machine that was already belonging to a domain. It might work but as I did not test it so I will not comment on it.
To install the Virtual Servers, you will need of the following software:
– Microsoft Virtual PC 2007
– An Operating System, Windows Server 2003 is used in this example.
For Windows Server 2003, you can either use the disks or .iso files as Virtual PC allows you to use .iso files directly as virtual disks.
1. Install Virtual PC.
Firstly, you need to install Virtual PC on your host machine. Virtual PC is free and can be found here.
Virtual PC can host client operating systems such as Windows XP but also server operating systems such as Windows Server 2003 – even if the documentation does not mention about Server versions of Windows.
There is another Virtualization product from Microsoft: Virtual Server – the current version being Virtual Server 2005.
Virtual Server 2005 and Virtual PC use the same technology under the hood but Virtual Server is more oriented to real world production usage, it performs better, scales better and has more administrative tools so that administrating all the virtual servers is easier.
It is nevertheless more complicated and not needed for most testing scenarios or for private use. It is easier to use Virtual PC when the host machine is either a desktop or a non production server.
In my opinion, Virtual Server should be used only when your goal is to implement virtualization in your production environment.
2. Creating the Virtual Machines.
As said earlier we need to first create a “base” virtual machine on which all other virtual machines will be cloned.
Each virtual machine clones needs to be renamed but just changing the machine name is not sufficient, the cloned machine also needs a new SID, GUID, MAC Address and so on. This is especially important for COM components such as MSDTC. There is a tool provided by Microsoft that does all these tasks: sysprep.
Note that once a machine is “sysprepped”, the new SID, GUID and so on are given only AFTER the machine reboots for a first time.
2.1 Creating the Base Virtual Machine
In this step we will create a base virtual machine and install its OS, Windows Server 2003. You may additionally install other applications that you want to have in all your cloned virtual machines.
2.1.1 Create a Virtual Machine.
Download in install Virtual PC, run the Virtual PC Console and create a new virtual machine. The new virtual machine wizard asks you for 2 important configuration settings:
Memory allocation.
The memory you should reserve for the virtual machine depends on how many virtual machines will run in the same time and how much memory your host machine is equipped with.
If you have 1 Gb of memory and plan to install 2 virtual servers on it so 320 Mb per virtual machine is a good choice. If you have 2 Gb, chose 640 Mb.
It is important to know that the entire block of memory will be allocated to the virtual machine when you start it and fully released when you stop it.
If you create more virtual machines than your machine has memory for, the virtual machine will refuse to start.
So, if all virtual machines must be able to run in the same time, the rule of thumb is trivial; just divide your amount of memory by the number of virtual machine + 1 (for the host machine). If you need to run more programs on your host OS, you might want to give less memory the to guest OS and more to the host.
Note that the minimum amount of memory for installing Windows Server 2003 is 256 Mb.
Hard disk allocation.
When asked to choose the size of the virtual hard disk, you can keep the default value as it does not really matter. By default, the size of the file containing the virtual hard drive (.vhd file) will NOT be size of the virtual hard disk but rather the size of the data contained in the virtual hard disk.
2.1.2. Set up the Base Virtual Machine
Install Windows Server 2003.
Once a virtual machine is created, you can click on “start” and the virtual machine will boot up in a new window. You will see a BIOS-like startup sequence displayed and you can install Windows Server 2003 from there. You can click on “CD” on the menu of the Virtual Machine windows and either chose “Use Physical Drive” or “Capture ISO Image”. After that, click on “Ctrl+Alt+del” in the Action menu of the Virtual Machine window so that it reboots on the installation disk. Note that the shortcut on the keyboard for that is “Right Alt + Del”.
When asked for Networking Configuration, just chose “Typical setup” and continue.
Install Virtual Machine Additions.
After Windows Server 2003 is installed you should install Virtual Machine Additions. This helps improving performance and also resolves issues in the handling of the mouse. Indeed, before installing this component, you might notice difficulties in having the mouse pointer exiting the virtual server windows. You can always bring back focus on your host OS by doing an “Ctrl+Alt+del”.
To Install Virtual Server Addition, click “Action” in the top menu of the windows containing the virtual machine and then chose “Install or Update Virtual Machine Additions”.
Install Service Pack
You should download and install the last Service Pack for Windows Server 2003 (SP2 at time of writing).
Lastly, you should install other common components / applications that you need on all your cloned virtual machines.
Tip: You can copy files or folder from your host machine to your guest machine and vice-versa simply by drag and drop.
Alternatively, you can setup a share folder. To do this, right click on the folder icon on the lower right corner of the window in which the guest OS is running and click “Share Folder…”
2.1.3. Sysprep the base virtual machine.
Before cloning the base virtual machine, it is important to run a tool called Sysprep on it. That way, when you create a virtual machine that uses a copy of the base virtual machine’s .vhd file, the cloned guest operating system will be assigned a new SID, GUID, MAC address, and so forth the first time it boots. This way you won’t end up with network / COM conflicts between different virtual machines that used a copy of the same base .vhd file.
You can get sysprep from 2 places:
– The Download center of Microsoft, here for Windows Server 2003 SP2. The download is an .exe file, run it and it will put a cab file, deploy.cab in your C:\WINDOWS\system32 folder. Sysprep is located in that .cab file.
– The file sysprep.exe is also located in the CAB file DEPLOY.CAB in the SUPPORT\TOOLS folder of the windows install disk.
To sysprep the cloned machine follow the next steps:
1. Start the base virtual machine and login as local administrator.
2. Download or copy the package containing sysprep into the virtual machine hard drive so that it is installed in the virtual machine (NOT the host machine!). Once you have access to the file DEPLOY.CAB on the virtual machine, extract all its files to a location, C:\Tools for example.
3. Create an answer file. The answer file contains the configuration settings used by sysprep. Sysprep comes with a help file called “deploy.chm” (also located in the deploy.cab package) which explains how to create the answer file for the specific version of Windows you are using (each version of Windows having a different version of sysprep). You can generate and answer file using a tool, the Setup Manager Wizard (setupmgr.exe).
Steps to create an answer file:
3.1. Start the Setup Manager wizard, setupmgr.exe, located in C:\Tools (the location where were extracted the files contained in deploy.cab).
3.2. Click “Next”.
3.3. Select “Create New” and click “Next” to create a new answer file.
3.4. Select “Sysprep Setup” and click “Next”.
3.5. Select the version of the Windows you are creating an answer file for, Windows Server 2003 Standard Edition in our case and then click “Next”.
3.6. Select “Yes – Fully automate the installation” and click “Next.”. So that we are not prompted for any information when “sysprepping” the cloned Windows.
3.7. Type in a default User Name and optionally an Organization for the cloned Windows, click “Next”.
3.8. Accept the default display settings by clicking “Next”.
3.9. Select your time zone and click “Next”.
3.10. In Product Key type the product key and click “Next”.
3.11. In licensing, select the type of license for the guest operating system, and click “Next”.
3.12. Type a computer name and click “Next”.
3.13. Set the administrator password and click “Next”. To ensure that the password will be set, the virtual machine’s password must be blank. Press Right-ALT + DEL (or click on CTL+ALT+DEL in the Action Menu of the virtual machine) and click “Change Password.” Type the old password and leave the new password blank. Click “OK.”
3.14. In the networking components settings, select “Typical Settings” and click “Next”.
3.15. Leave the machine in a workgroup (you can join a domain later) and click “Next”.
3.16. The remaining screens are less important so I will skip them. On the last screen, click “Finish”.
3.17. Keep the default location and name of the generated answer file (C:\Tools\sysprep.inf for our example), click “OK”. This is because the sysprep.inf file and sysprep.exe needs to be located in the same folder.
3.18. The answer file is now created, click on “Cancel” to exit the wizard.
4. Sysprep the Operating system. In this step we will run sysprep with its answer file so that the machine is fully renamed and reconfigured to avoid any clash between the base machine and the cloned machines.
Steps:
4.1. Run sysprep.exe located in C:\Tools
4.2. Click “OK” to clear the warning dialog.
4.3. In the option zone at the bottom of the window, check the “Don’t reset grace period for activation” box.
4.4. In the dropdown list, Make sure that the shutdown mode is “Shutdown”
4.5. Click “Reseal”
4.6. When prompted about regenerating SIDS, click “OK”. The guest operating system will be “sysprepped” and will automatically shut down. Once shutdown, do NOT restart the base virtual machine.
4.7. Copy the base .vhd file from the virtual machine into a folder you will use to store your base virtual machine. Then, in the file system, make the base .vhd file read-only.
It is important to know that from now on, the base vhd file should never be rebooted in a virtual machine. Instead, it should always be copied first to create a new virtual machine. If you rebooted on the original base vhd file, it would not be possible to reuse it as a base file again. This is because the virtual machine OS is assigned a new SID, GUID, MAC address, and so forth ONLY the FIRST time it reboots.
So, it is advised to make the base .vhd file read-only so that it can not be booted/modified accidently.
2.2 Creating other Virtual Machines by cloning the Base Virtual Machine.
Once the base virtual machine is ready, you can clone it to create new virtual machines.
My host Operating System being Windows XP, all virtual machines (guest Operating System) are by default located in My Documents\My Virtual Machines, each virtual machine having its own subfolder.
2.2.1 Cloning the virtual machine.
1. Under My Documents\My Virtual Machines, create a new subfolder with the same name as the new virtual machine you are about to create. For this example let’s call it “VirtualServer2”.
2. Copy the base virtual machine’s virtual hard disk file (.vhd) into that subfolder, rename it to match the cloned virtual machine name (i.e. VirtualServer2.vhd) and remove the read-only attribute on the renamed vhd file.
3. Open the Virtual PC Console and click on “New”.
4. When asked for the name and location of the virtual server, just type in the name of the virtual machine you chose, “VirtualServer2” in our example. The wizard will find the folder you created in step 1 and create a VirtualServer2.vmc file it it.
Vmc files are the file containing the configuration of the Virtual Machine. If you open it using notepad you will see that it is just an XML file.
5. Chose the Operating system “Windows Server 2003” and adjust the memory settings to your preference and click “Next”.
6. When arriving on the “virtual hard disk option”, make sure that the radio button “an existing virtual hard disk” option is selected so that you can select the virtual hard disk you copied in step 2.
Note that you might want to select the option to enable undo disk. With undo disks, at the end of a session, you can chose to either commit the changes you made to the virtual hard disk or cancel the changes. This gives you the possibility to not save the state of your Virtual Machine in case you did something wrong, thus revert back to the state you were when you started that session.
7. When the new Virtual Machine is created, start it and it will receive a unique SID, GUID and other identifiers.
You are now done and can repeat the operation to create other cloned virtual machines.
Final Remarks.
It is also possible to not sysprep the base virtual machine but sysprep all the cloned virtual machine individually instead.
I have read that 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.”. If that occurs you might be able to re-sysprep that machine or to work from a base virtual machine that is not sysprepped yet.