Monday, May 12, 2008

Using a single base VHD to create many individual VMs

First of all, please note - this is a test and development trick. The use of differencing disks does cause a reduction in disk performance of a VM (a snapshot is also a differencing disk).

Setting Read only on the parent VHD is not critical in Hyper-V as it was in Virtual Server.

Here are the basic steps:
1) create your Base VM - base.vhd
2) prepare him with sysprep (or your tool of choice)
*it is at this point (or after) that you can tag base.vhd 'read-only'
3) create differencing disks using base.vhd as the parent.
* Use New -> Hard disk -> Differencing from the Hyper-V manager
4) create a new VM 'using an existing VHD' for each differencing disk

You are done.

In the end you get:
_ differencing disk 1.vhd
_ differencing disk 2.vhd
_ differencing disk 3.vhd

Base.vhd can never be used for a VM - so the VM that you created when you created him must be deleted.

The only reason for making the base.vhd read-only is that if it is modified at all, all the rest of your children differencing disks will be 'broken' - broken as in they will stop booting and will crash, just as if a hard drive failed.

VHD is block based and differencing disks contain a 'map' that references the parent - so parts of your VM disk reside within both VHD files (the parent and the child).


Zeesh said...

I am trying to run 6419A on HyperV. I got the baseVHDs and link VHDs but don't know how to set them up properly. The 6419A was made for virtual PC.

BrianEh said...

I cannot comment about any specific course (I am guessing that you are referring to a course number).

If the VHDs were built for VirtualPC, then you need to remove the VMAdditions from within the OS of the VM and you also need to install the Hyper-V Integration Services into the VM.

You should be able to do this on a copy of your base VHD (for safety).

Then you link off the differencing disks and create a new VM, but you point to the differencing disk, not the root VHD.

Anonymous said...

is there a possibility locate the Differencing disk that will depend on a Base VHD?. I am trying to locate the dependencies to delete the base.

BrianEh said...

Each differencing disk only knows about its parent (one step forward).
So you would need to use the "inspect disk" wizard on each to see if it is a differencing disk and also who is its parent / what is the path of the parent.