Hyper-V Virtual Machine (VM) Parent-Child Configuration Using Differencing Disks

Hyper-V Virtual Machine (VM) Parent-Child Configuration Using Differencing Disks

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
  3. Generalize the installation
  4. Prepare the parent virtual hard disk
  5. Create the differencing disks
  6. Create virtual machines that use the differencing disks

1. Create the Parent Virtual Machine Configuration and Virtual Hard Disk

  1. In Hyper-V Manager, right-click the virtual server on which you want to create the configuration. 
  2. Click New, and then click Virtual Machine. If the Before You Begin page appears, review it and then click Next.
  3. On the Specify Name and Location page, in Name, enter an appropriate name, but don't think too much about it because you will be deleting this one. 
  4. In Location, you can choose the default, or if you want to store the virtual machine in a different location (instead of default location %programfiles%\Microsoft\Windows\Hyper-V\ or starting in Windows Server 2008 R2 %programdata%\Microsoft\Windows\Hyper-V\, then select Store the virtual machine in a different location and enter the full file path. Again, this is something you will be deleting, so you might not want to worry too much about it. When you are ready, click Next.
  5. On the Assign Memory page, enter the amount of memory you want to dedicate to the virtual machine. The number you choose depends on the requirements of the operating system you are installing. You can always increase this later, so it isn't necessary to do a lot of planning here. Click Next.
  6. On Configure Networking, determine whether you want the machine connected to a network to start with. This is a personal choice, but if you want to run Windows Update and install specific tools or applications from a network, you may want to set Connection to an appropriate virtual network interface adapter that will allow you to connect to the network and/or Internet. Click Next.
  7. On Connect Virtual Hard Disk, you will leave the Create a virtual hard disk selected. Unlike the virtual machine configuration earlier, this is something you will keep. You need to be sure you pick a Location that has enough disk space and one that you will remember. This will be your parent.vhd, so for  Name you might want to type a descriptive name. For example, you might enter the name WS2008R2Parent.vhd as the name for an image of Windows Server 2008 R2. For Size, remember that Hyper-V is not going to consume the default 127 GB of disk space. The disks grow dynamically, so this is the maximum size that you ever want your vhd to grow to - people commonly leave the default setting for Size. Click Next.
  8. On Installation Options, determine how you want to install the operating system. If you have an ISO image of the operating system or even a physical CD or DVD, you can set that up. There are other options and these really depend on how you want to actually install the operating system. Click Next.
  9. On Completing the New Virtual Machine Wizard, review your selections and then click Finish.

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

  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.

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.

  1. Right-click the Hyper-V server you want to target, click New, Hard Disk. The New Virtual Hard Disk Wizard opens.
  2. If the Before You Begin page appears, review it and then click Next.
  3. On Choose Disk Type, select Differencing and then click Next.
  4. On Specify Name and Location, type an appropriate name. For example, APP1.vhd and then enter a specific location where you want to store the virtual hard disk. For example, you might store the vhd to C:\virtual\vhds\. Click Next.
  5. On Configure Disk, in Location, type or browse to the file path to the parent vhd that you created previously and then click Next.
  6. On Completing the New Virtual Hard Disk Wizard, review your selections and then click Finish.
  7. Repeat this procedure for the additional virtual machines you want to create that use the same parent (base) virtual hard disk.

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.

  1. In Hyper-V Manager, right-click the virtual server on which you want to create the configuration. 
  2. Click New, and then click Virtual Machine. If the Before You Begin page appears, review it and then click Next.
  3. On the Specify Name and Location page, in Name, enter an appropriate name. 
  4. In Location, you can choose the default, or if you want to store the virtual machine in a different location (instead of default location %programfiles%\Microsoft\Windows\Hyper-V\, or starting in Windows Server 2008 R2 %programdata%\Microsoft\Windows\Hyper-V\, then select Store the virtual machine in a different location and enter the full file path. Click Next.
  5. On the Assign Memory page, enter the amount of memory you want to dedicate to the virtual machine. The number you choose depends on the requirements of the operating system and applications that you plan on installing. Click Next.
  6. On Configure Networking, determine whether you want the machine connected to a network to start with. This is a personal choice, but if you want to connect to a network, select an appropriate Connection. You can also change this option even when the operating system is running through the Settings of the virtual machine, so it is not absolutely critical that you figure all of this out immediately. Click Next.
  7. On Connect Virtual Hard Disk, select Use an existing virtual hard disk. In Location, enter or Browse to the differencing virtual hard disk that you created for this virtual machine. For example, if you are setting up APP1, then you would enter the full file path to the APP1.vhd (including the name of the VHD, in this case App1.vhd).  Click Next.
  8. On Completing the New Virtual Machine Wizard, review your selections and then click Finish.
  9. Repeat the process above for each differencing disk you created.

 

Sort by: Published Date | Most Recent | Most Useful
Comments
  • 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.

    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

    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

  • Hi I think I might have found a limitation with the using parent disks i.e. their initial size seems to determine the maximum logical size of the child diff disk.  I am currently awaiting answer to this as I might have recreate my Parent disk with larger size

  • @DanTheManXX Yes, the differencing disk is relevant to the parent disk and its limited to the parent maximum size you selected when creating it.

    You could work around this by making the parent disk at maximum size while it's dynamically expanding disk and so you get the differencing disk also with the maximum size your Hyper-V can handle.

    Hope this reply help ;)

Page 1 of 1 (6 items)