Creating virtual environment for testing purposes–Best practices

by Marin Franković on 14 July, 2010

Driven by an article posted by my fellow MVP, Ilija, I decided to share with you my practical knowledge and experience in creating testing environment by utilizing virtual machines and Hyper-V role of Windows Server R2. This article will describe best practices in creating virtual machines as fast as possible and managing them with ease. I will not be talking about SCVMM 2008 R2, because this article covers a scenario of one user creating his own testing environment (such as myself Smile).

Basically, there are two ways you can create virtual machines. Well, three, I you take into account Ilijas “wrong” attempt.

Copy syspreped VHDFirst one is to create one VHD file, install virtual machine into it, patch it and then use Sysprep with OOBE and shutdown switches specified.
NOTE: It is not recommended to use NewSID for generating new SIDs, since Microsoft does not recommend it any more nor it is supported. If you are interested in deeper explanation, you can read Mark Russinovich’s blog post on SIDs. So, what you are left after that is one VHD file with installed and Syspreped installation image. All you have to do now is to copy that VHD file and every time you

create virtual machine from it, you will get new and fresh OS installation. Drawback of this technique is that you will lose lots of disk space, since every copy of a VHD file is full OS installation. For speed purposes, it is recommended to use fixed size VHD files. Although you could use one physical hard drive to store all your virtual machines, it is a good practice to have at least RAID 0 or RAID 5 implemented.

Base & DifferentialSecond solution will save you lots of disk space, but it will also require (as a good practice) you to have more than one physical hard drive if you want to have reasonable speed of virtual machines. This time, we will be using one “base” VHD file and multiple differential VHD files that will use “base” VHD as parent. In my experience, best thing to do is to store “base” file on one physical drive and differential files on another physical drive. So, as in the first example, install OS in one VHD file, patch it and use Sysprep with OOBE and shutdown switch. Make sure that you add “read only” attribute to this file via its properties in Windows explorer. This time we will not copy VHD file to create multiple virtual machines. We will create differential disks that will use first VHD as parent, by using the same wizard we used to create “base” disk. Couple of things to note. This way you will use less space and virtual machines may be faster if you have more physical disks. On the bad side, if you use one physical disk, virtual machines may be slow, and when using Hyper-V console to export virtual machines that use “base” disk, you will end up with lots of VHD files. For example, if you have one “base” disk, and three differential disk that are connected to that “base” disk, when you export them, you will end up with three “base” disks and three differential disks.

I personally use second option. I have two fast external drives on which I store “base” VHDs and another one for differential VHDs.


{ 0 comments… add one now }

Leave a Reply

Previous post:

Next post: