Tuesday, 1 May 2007

Transferring Files Between the Host and Guest in Virtual Server 2005

Microsoft Virtual Server 2005 makes life very easy to assist in the development of SharePoint projects (or any I.T Project), particularly when you want to develop or test on an environment that is close to the target deployment environment as a risk mitigation strategy.

I often hear of stories where developers have developed on their XP workstation using Visual Studio 2005 and tested their deployment on IIS 5.0 in XP, only to then spend numerous hours debugging their project after deploying to Windows Server 2003 IIS 6.0, wondering why on earth the solution doesn't function as it did on XP ...

But this article doens't talk about the pros or cons about MS Virtual Server 2005, rather this article explains a simple approach to transfer files between the HOST (computer on which Virtual Server has been installed) and the GUEST (virtual machine) - which is just like any other computer on the network - requiring virtual network card, virtual hard drive, CPU, RAM, etc.

Microsoft Loopback Network Adapter can be used to transfer files from a Virtual Server Host & the Guest machine without having to create an external network.

This article assumes that you have some knowledge of Virtual Server 2005 and that you have already setup a virtual machine - both host & guest running windows server 2003 SP1.

First you must intall Microsoft Loopback Adapter on the host computer.


  1. In the host operating system, right-click My Computer, and then select Properties. Depending on the style of the start menu, My Computer may be located in the Start menu.
  2. In the System Properties dialog box, on the Hardware tab, click Add Hardware Wizard.
  3. In the Add Hardware dialog box, click Next.
  4. When the Is the hardware connected? dialog box appears, click Yes, I have already connected the hardware, and then click Next.
  5. In the Installed hardware list, click Add a new hardware device, and then click Next.
  6. In the What do you want the wizard to do? list, click Install the hardware that I manually select from a list (Advanced), and then click Next.
  7. In the Common hardware types list, click Network adapters, and then click Next.
  8. In the Manufacturer list, click Microsoft.
  9. In the Network Adapter list, click Microsoft Loopback Adapter, and then click Next twice.
  10. If a message about driver signing appears, click Continue Anyway.
  11. In the Completing the Add Hardware Wizard dialog box, click Finish, and then click OK.
Reference: http://www.microsoft.com/technet/prodtechnol/virtualserver/2005/proddocs/vs_operate_ht_install_loopback.mspx?mfr=true

Now configure the loopback adapter.


  1. On the host operating system, open Network Connections, right-click the local area connection for Microsoft Loopback Adapter, and then select Properties.
  2. In the Microsoft Loopback Adapter Properties dialog box, verify that the Virtual Machine Network services check box is selected.
  3. Click Internet Protocol (TCP/IP), and then click Properties.
  4. On the General tab, click Use the following IP address, and then type the IP address and subnet mask (such as 192.168.1.1 and 255.255.255.0).

    Important

    You can use any Transmission Control Protocol/Internet Protocol (TCP/IP) address, but it is best to choose one from a reserved range of non-routable TCP/IP addresses. For example, TCP/IP addresses of the form 192.168.x.y, where x is a value from 0 through 255 and y is a value from 1 through 254, are non-routable. The value you choose for x must be the same on the host operating system and each guest operating system that is to be part of this virtual network. If your primary Ethernet connection uses one of these non-routable addresses, you must choose a different value for x to assign to Microsoft Loopback Adapter.
  5. Click OK, and then click Close.

    Notes

    To perform this procedure, you must be an administrator or a member of the Administrators group.

    To set up multiple network connections using Microsoft Loopback Adapter, use different subnets.

    Do not set a value for Default gateway.

Reference: http://www.microsoft.com/technet/prodtechnol/virtualserver/2005/proddocs/vs_operate_using_loopback.mspx?mfr=true

The key to making this work is to correctly set the IP settings of the loopback adapter.

In my case the IP address of my host computer is 10.140.7.32, mask 255.255.240.0. The IP address of my virtual machine is 10.1.1.11, mask 255.255.240.0.

On the host computer, I have set an IP address of 192.168.7.1 on the loopback adapter, a mask of 255.255.240 and no default gateway.















Now, create a virtual network from the virtual server administrator web page, name it "Loopback Network" and select "Microsoft Loopback Adapter" as the network adapter on the physical computer.

Once you have created the loopback network, edit the configuration of your virtual machine and add a new network adapter. - you will have to shutdown the virtual machine before you will be able to edit the configuration.


Set the new network adapter to connect to the loopback network, as show in the following.




Now start up your virtual machine and go into the network settings - you should see a 2nd network adapter - the one you just created.

Set the IP address of the loopback adapter (which I have called Host Network) to 192.168.7.2, and increase the last number as you add more virtual computers to this network if you also want to add loopback adadpters to them. For example, the next virtual machine will have an IP address of 192.168.7.3 for its loopback adapter. Remember we added an IP address of 192.168.7.1 to the host loopback adapter - so in essence we have created a network using 192.168.7.x.

To transfer files, map a drive to the host computer from the virtual machine using the hosts loopback adadapter address, so you can make a drive to "//192.168.7.1/c$" from the virtual machine for example.

Thats it!

Hope that helps.

Abdul.

No comments: