Pages

Monday, April 25, 2011

SharePoint Development Environment: Virtual Machine Or Virtual Hard Disk (VHD) with Dual boot

It’s true that SharePoint team has made the SharePoint rich enough to be useful in any organization. But they have taken less care of developers (my personal opinion). Developing with SharePoint was really a nightmare in old days (in SharePoint 2007) and the situation has not been changed that much today. I reminisce the days back in 2008 when four members of our SharePoint team worked in a single SharePoint server by logging in remotely. When one developer needed to reset IIS he needed to to inform others either he may interrupt some others’ debugging session.

From that nightmare development experience of my first SharePoint project, I’ve come to a better place. Now I’ve Core I7, 8GB ram laptop. But I used to work in Virtual Machine till few months ago and I had got slower disk access in Virtual Machine. So compiling, debugging and deploying was relatively slow. I don’t want to install SharePoint in my laptops’ Windows 7 and I hope fewer (possibly fewest)  people want to do so.

I’ve personally found developers who are coming to SharePoint Development from Asp.net, has got it difficult to get used to this environmental complexity. Anyway I’ve come to know about Virtual Hard Disk (VHD) solution few months ago and I’ve found it really a healthy approach. Let’s dig it deeper.

SharePoint Development in Virtual Machine

If you use Virtual Machine or any other virtual solution, you will have to realize that you will not the full processing power of your computer in SharePoint development. Even if in my Core I7 with 8GB ram, I get the development in Virtual Machine slower. If you do a lot of debugging and deployment you may loose your patience soon. However the real benefits include you can save virtual machine state. You can backup your virtual machine and restore.

SharePoint Development with Virtual Hard Disk (VHD)

Though I knew the concept of  Virtual Hard Disk about a year about ago, I didn’t get interested about it till few months ago. Basically the concept if you will have a Hard Disk (virtual obviously) and you will mount that virtual disk as a drive in your computer. Then you will install OS in that drive and add that OS in boot menu in your computer. So you will have more than one operating system in your computer but the OS will be in Virtual Hard Disk (which is a .vhd file). I’m going to describe it in details:

Create and Initialize a Virtual Hard Disk

For your information, the following option for creating VHD file from “Computer Management” is only available in Windows Server 2008 R2 and Windows 7. I’ve not explored if the option shown below is available for other operating systems.

  1. Open the “Computer Management” from Administrator tools and right click on the “Disk Management” and click “Create VHD” as shown below:

    image
    Figure 1: Create VHD option in disk management

  2. Then in the New VHD window, enter appropriate value as shown below:

    image

    Figure 2: Create new VHD settings page

  3. After that you will find a new disk is added as shown below:

    image
    Figure 3 New disk created for VHD

  4. So you have found you new VHD as new disk but the disk need to initialized. To do right click on the new disk and click initialize as shown below:

    image
    Figure 4: Initialize Virtual Hard Disk

  5. However when you’ll try to initialize the disk you will prompted for partition style. Its recommended MBR as shown below:

    image
    Figure 5: Create MBR partition in new VHD

  6. After that you will find the disk (disk 1 in above figure) online. After that create a new volume in that virtual disk as shown below:

    image
    Figure 6: Create new sample volume in Virtual (but online) disk.

  7. In the “New Sample Volume Wizard”, you can go with default settings and finally you will get a new drive in your computer which is virtual.

 

Mount a VHD and Install OS

Once you have your Virtual Hard Disk (VHD) ready you can try to install an OS in the VHD. To do so insert a Bootable CD/DVD in the CD/DVD-ROM and reboot your computer. To boot from CD/DVD make sure boot from CD/DVD enabled. I had tried to install Windows Server 2008 R2 in VHD. The process is described below:

  1. First, let the OS to start from bootable disk. Then when the following window comes up, press Shift + F10 to bring command prompt.
    image

    Figure 7: Windows Server 2008 R2 installation window.

  2. When the command prompt comes up (after press Shift + F10), type diskpart and press enter. And then type list volume and press enter to see all volumes available.
    image
    Figure 8: Use diskpart command to list volumes.

  3. You will find from “list volume” command that your drive letter is shifted by a letter (so, C becomes D, D becomes E and so on). Now type Select vdisk file=”VhdFilePath” as shown in the image below:
    image
    Figure 9: Select VHD file command

  4. Now you have selected the vhd file and you need to attach the file. To do so, run the command “attach vdisk” as shown below
    image
    Figure 10: Attach Vdisk command

  5. You have selected vdisk and attached it. Now close the diskpart by typing Exit and then close the command prompt by typing exit again.
  6. Now you can click Next in the “Install Windows” wizard as shown in figure 7. As you have attached the vdisk in the system, Installer will show the vhd as an disk and you can then choose to install OS in that vhd disk.
  7. When the Installation options come to choose the drive where to install OS, you can choose the VHD mounted disk (as shown in the image below). However you may get an warning saying “Windows Cannot be installed…” if you select the VHD for installing OS. Ignore the warning and install the OS in the vhd mounted disk.
    image
    Figure 11: Select VHD disk to install OS

  8. And when the installation will be finished, you will find your another OS is added in your boot menu.

So the final output is a file (VHD file) which is used for dual boot. You can copy the vhd file and attach it to another pc.

 

Attach an Existing VHD to boot option

Now say you have a vhd file and you need to attach the vhd file in boot option in your pc. You can do so with command. Fortunately, there’s GUI tools available to edit boot loader options. One such tool I’ve used is EasyBCD. I’ve shown below how to add a VHD file in boot menu.

  1. Run EasyBCD and click “Add New Entry”.
  2. From the bottom click “Virtual Disk” tab and then select the vhd file from disk.
  3. Finally click “Add Entry” to add the entry in boot option.

The following image shows process in a glance:

image

Figure 12: Add VHD file in boot option with EasyBCD

 

Now when you will restart your pc, you will find the new newly added entry is in boot option. Be cautious while you edit your boot menu. Improper editing of boot menu may fail your booting system.

 

Conclusion

If you are working with SharePoint frequently (as I do), you need to care about every minutes you are loosing for working in Virtual Environment. Since few months ago I had used Virtual Environment in my powerful laptop (Core-i7, 8GB RAM). However, disk access in VM environment is slow and as Visual Studio performance is somehow related to disk access (as during build a lot of disk read/write access operations are performed) so finally performance was a major problem.

Now I’ve moved my work to VHD and I’ve two VHD files (one for SharePoint Foundation and another is for SharePoint Server). I’ve three OS in my boot options: Windows 7 (installed with my laptop), SharePoint Foundation and SharePoint Server. I can remove any boot option from my boot menu any time with EasyBCD. And most of all, with VHD option, I get the full power of my laptop. If you guys have doubt about VHD option, I’ll ask you to give VHD option a try and I do believe you will like it. You will have to like it. FYI, I’m not a marketing guy anyway so maybe it’s hard for me to convenience you.

Please post your feedback.

6 comments:

  1. Very nice post, thanks for this amazing info ill recommend your blog to all of my college friends,

    ReplyDelete
  2. What does it cost to install 3 OSs and 2 different SharePoint installs, just to develop, especially in licensing fees?

    Basically I'm looking for more cost effective solution for a team of 15 people.

    ReplyDelete
  3. very informative content,especially for the beginners... I would like to ask what is the basic difference between the two versions of share point??

    ReplyDelete
  4. Actually the difference is much broader and not possible to describe in few letters. However, you can google for information. Thanks for the query

    ReplyDelete
  5. here is a much easier way...

    http://www.howtogeek.com/75286/how-to-dual-boot-windows-7-and-8-without-re-partitioning-using-vhd/

    ReplyDelete
  6. You are tutorial is nice and thanks for explain this


    SharePoint Development

    ReplyDelete

Note: Only a member of this blog may post a comment.