Working with Multiple Virtual Machines in Hyper-V

< Back to Insights
Insights  <  Working with Multiple Virtual Machines in Hyper-V

As a consultant who works on many different projects, it is always a good idea to keep projects separate.  The best way to keep things separate is to create multiple virtual machines.  This can pose a few problems, like the time it takes to build a virtual machine and get it fully configured.  And all that hard drive space just to have multiple virtual machines with the same software installed.  In the long run, the benefits of multiple virtual machines out-weigh these costs.  You not only get to archive out-dated projects, freeing up valuable/precious hard drive space, but you do not cross contaminate your projects.  We’ve all said this: “it works on my machine“.  Well there is a reason for that.  Maybe you changed a setting in the registry, or modified some permissions while working on another project on the same virtual machine.  “I know I did something with the registry, but I can’t remember what.”

Using multiple virtual machines solves that issue, but what about your time and space?  If you haven’t solved the Einstein-Rosen bridge, you should try using differencing drives to alleviate some of the wasted time and space.

A differencing disk is a virtual disk which points to a “parent” virtual disk. So when you create a virtual machine with a differencing drive, you are starting with a baseline image (parent) and any changes made in the virtual machine are saved to a separate virtual disk (child). Any subsequent virtual machine you create with a differencing drive, you can also point to the “parent,” since it remains unchanged. This saves space, since anything stored on the “parent” virtual disk is shared between the children. Using differencing disks also saves time since you don’t need to install a new operating system, any security updates, or any commonly used software. You just point to the baseline image and go.

Create Parent Image

  1. Create a new virtual machine using Hyper-V manager.
    • Install your operating system, the software you will share from VM to VM, and all the security updates they entail.
  2. Run the SysPrep.exe utility.
    • SysPrep /oobe /generalize /shutdown
  3. Remove the virtual machine from Hyper-V Manager.  (You don’t need to run this directly anymore).
  4. Make the .VHD/.VHDX file read-only.  This is important!  Any change to the base image will render virtual machines created off of it invalid.

Create Virtual Machines

  1. Create a new virtual machine using Hyper-V Manager but choose the “attach a virtual hard disk later” option.
  2. Right click the newly created virtual machine and go into the “Settings…”
  3. Click on the IDE Controller 0 and click to add a new hard drive.
  4. Click the “New” button to create a new drive and select the “Differencing” disk type
    • Choose the parent disk that you created before.
  5. Start the machine, enter in the product code and start developing.

With that you have just saved your future self some time, since creating new virtual machines will take no time at all. No need to copy an already existing SysPrep-ed image. No need to copy anything! All you need to do is point to a disk that already exists.

In addition, you can create a differencing disk which points to a differencing disk.  So if you have projects which use different technologies, like SharePoint and BizTalk, you can start by creating a base image with just the operating system on it.  Then, you can create two disks, one for SharePoint and one for BizTalk, which both point to the baseline operating system image.  Then, when creating a new virtual machine, you can just point to either the SharePoint disk or BizTalk disk, both of which also share the same disk.

Continue the Conversation with Our Team
Get in touch with us.

Contact Us