Friday, April 22, 2011

Configuring Virtual Machines and Hosts

Last time, I covered setting up Windows 7 to run XP virtual machines. What came next was figuring out how to setup VirtualPC optimally.

First, make sure that Virtualization Technology is enabled in your BIOS, if such a setting exists. Without it, VirtualPC can't take full advantage of the host's hardware if this is not enabled. This would mean you can't run CAD, GIS, or play games, which need a closer relationship to available hardware. Since nearly everything to do with hardware is "emulated", hardware intensive apps won't run on VirtualPC without Virtualization Technology enabled.

Memory
The goal is to have enough memory for both the host and the VM, while minimizing paging operations. Robbing the host of too much memory is worse than robbing the VM. So the host should get the priority. If the host is slowed down, it will slow the VM down, so there’s no winning way to give a VM very much more than it will ever need.
1. First, log onto the host and launch all the applications you’re used to running. Let all initial processing (AV def update, AV initial scan, email sync with server, etc.) finish until the computer comes to rest.) You might want to launch maybe one or two more apps, especially if there’s an app you use maybe once every day, even if you don’t leave it running all the time. Especially launch any memory-hogs you use regularly.
2. Bring up Task Manager and go to the Performance tab. Look at the bottom under Physical Memory and note how much memory is available.


In this example, we have 2336MB.
Now subtract about 200MB for additional applications. This totals 2136MB available (max.) for the VMs to use.
3. Repeat this process for each virtual machine, but don’t just record “Available” – figure out how much is used.



In this example, the VM has been pre-configured on the host to allow 1024MB of memory to the VM. It is only using 593.3MB (1048048 – 454696 = 593352). Add ~35MB for additional applications. The VM actually needs 629MB.

Adding additional memory, above what your VM needs, will not speed it up. It will only allow you to run more applications. Most VMs are dedicated to 1-3 specific legacy applications, and no more. So it is best to allot barely more than the minimum. If your VM becomes sluggish, you might want to double-check your VM memory usage as time goes on. Newer versions of applications usually use additional memory, as the trend is towards code-bloat. If your host has more than enough memory, you might want to allow your VMs 100-200MB more, to allow for memory-hogging upgraded applications, like newer versions of IE, new OS Service Packs, etc.) as the years go by. This way you’re not hassled with VM configuration maintenance in the future.

4. So the last step is to reconfigure Virtual PC. Since 4GB on the host is a healthy quantity, I rounded 629MB upward to ¾ of a gig. I changed 1024MB to 768MB.



After making the change, and launching my VM, I see the host still has just over 1702MB available. The VM still has 203MB available.

Networking
- Dual NICs
Some machines have more than one NIC available. Our Server group advises against this practice, as it has caused issues with DNS and/or AD. However, it is possible to configure your host to use one NIC exclusively, while configuring your VM to use the other exclusively.
Since our Server group advises against dual NICs, I will only mention it, not detail the steps, since I don't have experience with it.

- No NIC Found
If your VM can’t find an available NIC, then make sure you have the latest version/patch-level of Virtual PC and that “Integration features” are enabled.



Then make certain the appropriate host computer’s NIC is selected in the VM settings…



"Turn off" versus "Shutdown"
“Turn off” is not accurate. This term refers to yanking the power cord. This is only good if the VM is attacked by a virus, or a similar panic situation.
“Shutdown” is a normal, controlled shutdown, where any open apps will be closed, and temporary files released.

Slow Explorer Access Between host and VM
There’s a problem with some VMs copying files from the host hard drive – phenomenally slow. There are a few possible fixes…

Method 1
The 1st method is for servers, not clients. Follow the hyperlinked text above if you want the details.
Method 2
Disable TCP task offloading in the registry of the host computer. To do this, add the following value.
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters]
"DisableTaskOffload"=dword:00000001
Restart your computer for it to take effect.
Method 3
Most NICs don’t have the choices detailed in Method 3, so don’t be surprised if Method 2 is the only one available.
If you do not want to disable TCP segmentation offloading on the whole system, and you want to only disable TCP segmentation offloading on the network adapters that Virtual Server guests use, you must not add the DisableTaskOffload registry entry that is described in Method 2. Instead, you can disable the task offload properties on the Advanced tab of the Properties dialog box of the network adapter.

To disable the task offload properties, follow these steps:
1. Click Start, click Run, type ncpa.cpl, and then click OK.
2. Right-click your network adapter, and then click Properties.
3. Click the General tab, and then click Configure.
4. Click the Advanced tab.
5. In the Property box, click the Offload TCP Segmentation property.
6. In the Value list, click Off, and then click OK.
7. If you also have the following task offload properties in the Property box, you must repeat step 5 to step 6 to disable these properties:
o Offload Receive IP Checksum
o Offload Receive TCP Checksum
o Offload Transmit IP Checksum
o Offload Transmit TCP Checksum
Sysinternals has a Secure-Delete utility that some say improves performance of VM’s. I’m not sure how or why it would, but for what it’s worth, they say to run the switch to clean empty space on the host hard drive where the VM’s VHD resides…
:: usage: sdelete [-p passes] [-s] [-q]
:: sdelete [-p passes] [-z|-c] [drive letter]
:: -c Zero free space (good for virtual disk optimization)
:: -p passes Specifies number of overwrite passes (default is 1)
:: -q Don't print errors (Quiet)
:: -s Recurse subdirectories
:: -z Clean free space
sdelete.exe -c C:

Hard Drives

It will give better performance for both the host and VM if the VM is on a different physical drive from the host OS. This is often not possible, but it is more ideal.
This may not be true for external drives – it depends on the overall data-rate. Alleged speeds are never reached, and some connections may be running at 1/20th the rated speeds, for whatever reason. Running from a mapped network drive is a very bad idea.
It’s also good to keep disc fragmentation to a minimum, on both the host and the VM.

No comments:

Post a Comment