One way to optimize disk space and reduce the number of times that you have to install and update a released operating system is to create parent child configurations using differencing disks in Hyper-V. For example, if you need to install a test lab that will employ three Windows Server 2008 R2 installations: one configured as a domain controller, another configured as an Exchange Server, and a third configured as a SQL Server, you could use a Parent-Child Differencing disk configuration to save the time of installing and updating the Windows Server 2008 R2 installation for all three of those virtual machines. The basic order for performing this task is to perform the following activities.
1. Create the Parent Virtual Machine Configuration and Virtual Hard Disk
2. Install the Operating System, updates, and common software
Install the operating system and anything else you want on the virtual machine that you just created. Typically people will run Windows Update and get all the latest updates. If you are using a non-Microsoft operating system, you will have to figure out how to do the equivalent or skip it. Another idea is to place any common tools and drivers on the image as well. Once that is all done, you are ready to generalize your installation
3. Generalize the installation
To ensure that you create a new machine identity, you should generalize your installation.
To do that for Microsoft operating systems, that means running sysprep. If you are using a non-Microsoft operating system, you will have to figure out how to do the equivalent or skip it. Sysprep is a built-in utility for most current Microsoft operating systems. Instead of launching into an entire instructional on sysprep, you can see How to Use Sysprep: An Introduction. The simple usage of the tool is to simply type sysprep from an elevated Command Prompt or the Run dialog box and read the dialog box. Review the Sysprep dialog box, select the appropriate options, and then run it. Leave the virtual machine shut down/off.
4. Prepare the parent virtual hard disk
5. Create the differencing disks
The work that you've done up to this point is about to start paying dividends. You can now install multiple versions of the operating system, not eat up nearly as much disk space, and not have to actually install that operating system again to get a bunch of different systems. For example, if you installed Windows Server 2008 R2 and fully updated it, you can now create a differencing disk for an Active Directory Domain Services (AD DS) domain controller, another for SQL Server, another for Exchange, and so on. You don't have to keep installing the base operating system. Just be absolutely sure that you make and save a copy of that parent virtual hard disk, if that file becomes corrupted or otherwise damaged (even started up and modified) you lose all the virtual machines that have differencing drives associated with it.
Create new differencing disk for each virtual machine that you plan to install. In this scenario, you will be creating three and pointing each new differencing disk (child) to use the one that you marked as read-only on the parent.
6. Create virtual machines that use the differencing disks
The final activity in this process are to create virtual machines that you will keep. This is very similar to the first activity in this article, except here you will be selecting an already existing virtual hard disk, which is one of the differencing disk you created in the previous activity. Also, you will be keeping these, so selecting a file and folder structure that makes sense to you is more important.
Kurt L Hudson edited Revision 13. Comment: Updated the link to SYSPREP as requested in comments. Also mentioned that the default path has changed since 2008 R2.
Richard Davis edited Revision 12. Comment: just a spelling nit-pick
FZB edited Revision 9. Comment: typos
FZB edited Revision 8. Comment: typo
FZB edited Revision 7. Comment: typos
FZB edited Revision 6. Comment: typo
Kurt Hudson MSFT edited Revision 4. Comment: Just fixed the intro text a bit
Kurt Hudson MSFT edited Revision 3. Comment: fixed typo whey to when
AdDocTeam MSFT edited Revision 2. Comment: Based on comments from RBeekelar, I have updated the discussion of vmc files to xml. VMC was from Virtual PC and Virtuals Server.
Kurt Hudson MSFT edited Revision 1. Comment: Updated to finish detailed instructions
Kurt Hudson MSFT edited Original. Comment: Updating information. Still have some details to add in here.
Pretty good post - I guess VDI solutions with a differencing disk follow a pretty similar series of steps
The default location you list: %programfiles%\Microsoft\Windows\Hyper-V\ doesn't show up when I use Windows Server 2008 R2. Rather, the default location is %programdata%\Microsoft\Windows\Hyper-V\.
This was rather confusing until I turned on "Show Hidden Files" in the folder options. Everything else is perfect. Just wanted to let folks know about this small change I stumbled across re: your article!
Dave Franklyn
If deemed suitable, one can skip steps 3 & 4, it will still work for testers.
To do that for Microsoft operating systems, that means running sysprep. If you are using a non-Microsoft operating system, you will have to figure out how to do the equivalent or skip it. Sysprep is a built-in utility for most current Microsoft operating systems. Instead of launching into an entire instructional on sysprep, you can see How to Use Sysprep: An Introduction . The simple usage of the tool is to simply type sysprep from an elevated Command Prompt or the Run dialog box and read the dialog box. Review the Sysprep dialog box, select the appropriate options, and then run it. Leave the virtual machine shut down/off.
1.You no longer need the parent virtual machine configuration files or folders. In Hyper-V manager, right-click the entry for the virtual machine and then select Delete. Confirm the deletion by clicking Delete. This should remove all the extraneous files, leaving you only with the virtual hard disk. However, you can go check the file path to ensure the folders and .xml files were removed. Just be sure not to remove the .vhd file, because that is the one you want. That is your parent virtual hard disk from which you will create the differencing disks.
2.Locate the virtual hard drive file, vhd, and set that as read-only. To do so, right-click the actual file, click Properties, then select the Set the virtual hard drive (.vhd) file as read only. This will help prevent you or someone else from accidentally modifying it.
Link to a more recent description of Sysprep technet.microsoft.com/.../hh824816.aspx