Thursday, June 17, 2010

Test machine using boot from VHD

Another option to my last post on SharePoint test machine setup is to boot from a VHD file. A VHD is a Virtual Hard Disk, a file that is used as a hard disk on a Virtual PC or Hyper-V Virtual Machine.

I followed the instructions on Marin Frankovic's blog about it, and it was very easy to create an easy-to-rollback, boot-from-vhd test environment. That's what I did:
  1. I used Marin's post to install a fresh Windows 2008 boot.
  2. I then created a differencing vhd based on the new W2K8 boot, using diskpart and running the diskpart command create vdisk file=c:\testdiff.vhd parent=c:\test.vhd maximum=size_in_mb type=expandable (or fixed). This is nice because you can create a initial differencing VHD from a base VHD, put aside a copy of this differencing VHD, and "destroy" your new boot with tests. When you want to rollback the "destruction", just throw away the differencig file your were using, and start with a fresh new copy from the VHD you put aside before.
  3. Next I added the boot entry to this differencing vhd. On a command prompt:
    a. bcdedit /copy generates boot entry copies. There's plenty of references on this, google for some.
    b. Run the following to point the new boot entry to the differencing VHD:
    bcdedit /set {boot_identifier} device vhd=[c:]\path_to_vhd\vdhfile.vdh
    bcdedit /set {boot_identifier} osdevice vhd=[c:]\path_to_vhd\vhdfile.vhd
    bcdedit /set {boot_identifier} detecthal yes
    (the boot identifier is shown when you generate the boot copy with bcdedit /copy. It can also be seen f you run bcdedit with no params)
And that's it. Your tests boots now can use the full power of your machine, RAM & CPU, instead of sharing the (precious) hardware with the host OS, as VM's do. Just remember: boot from VHD is supported only if your OS is W7 Ultimate or Enterprise, or W2K8 R2.

1 comment:

  1. Thanks a lot. I am new to SharePoint and your post solved my issues, when i installed SharePoint in my Windows 7.

    ReplyDelete