Diary and notebook of whatever tech problems are irritating me at the moment.


Improving Windows XP guest in VMware Player

I use XP in VMware Player to run some CAD applications on my Ubuntu system. I don't actually have to use XP for them as they function under Wine but I've been too busy to reinstall them and recreate their configurations. This setup works more or less but there are a few bugs and performance problems I've had to find workarounds for.

The first thing you need is RAM obviously. XP will function with 256MB of memory allocated to the VM but you'll need more for any app larger than Notepad. The host desktop (Gnome in my case) also needs a lot, how much depends on what native apps you have running. Open up Firefox with a bunch of tabs with Flash, Java, and Acrobat plug-ins active and you can easily use up 1GB total. For the VM you want to allocate enough for your guest applications but not exceeding what the host can provide else what the guest thinks is RAM will be paged out to disk by the host and it gets incredibly slow. If your host is a bit short on RAM then try switching to a lighter desktop like XFCE (Xubuntu), LXDE (Ubuntu Lite), Openbox, or even just xterm. If you're building a new system and plan to use VMs a lot then I recommend getting at least 2GB of RAM.

If you have a lot of memory available then you can improve speed in a XP guest by disabling the paging file. You'll find a lot of web sites warning against this but it's no more risky then running out of both RAM and disk space with the paging file active. If your guest apps use more than whats available then you will get an out of memory error either way, except with a paging file active you will often trash the registry in the process as it can't be written to. To turn it off go to Start > Control Panel > System (or press the logo key + Pause), Advanced > Settings (Performance) > Advanced > Change (Virtual Memory). In the Virtual Memory window select "No paging file", Set, Ok, then apply the setting (in Windows terms "apply" means reboot). Afterwards you may notice that the Windows Task Manager (Ctrl-Alt-Delete or logo key + R and then run taskmgr) will still show PF Usage >0 in the performance tab. Ignore it. I'm not sure if it's including some other non-memory related temporary file usage or is just an estimate but the important thing is that the hidden pagefile.sys in the root of the drive is gone and the setting can be confirmed in the registry.

Because I do a lot of file management from both Nautilus and the VMware guest I set up a shared folder and redirected the Windows special folder "My Documents" to the share. To set up a shared folder in VMware Player you need to manually edit the guest's vmx file. Here is a sample of the entries:

sharedFolder.option = “alwaysEnabled”
sharedFolder0.present = "TRUE"
sharedFolder0.enabled = "TRUE"
sharedFolder0.readAccess = "TRUE"
sharedFolder0.writeAccess = "TRUE"
sharedFolder0.hostPath = "/home/user/vmware/shared"
sharedFolder0.guestName = "shared"
sharedFolder0.expiration = "never"
sharedFolder.maxNum = "1"

You may have to enable it from the Player controls bar under Player > Shared Folders. The shared folders show up as a network location "\\.host\Shared Folders\shared". To set My Documents to this location right-click My Documents > Properties > Target then enter the path in the Target box and move your existing files there if desired. All of your applications should now be able to access the files the same as from the original location. I emphasize "should" as special folder usage in Windows is a Microsoft "suggested" practice that is not enforced by file system permissions. Some apps access the My Documents folder directly by an absolute path like "C:\Documents and Settings\User\My Documents" and they will ignore the target change. It also doesn't affect apps written in the "traditional" DOS programming style with behavior like writing user files to the same directory as the application executable.

This method eliminates having to synchronize files between the guest and host. You could also set up a Samba share on the host or another system and redirect My Documents to that instead but you will need centralized logins between your Linux and Windows systems to prevent permissions problems. One behavior you need to be aware of when using using shared folders is that VMware will often lock the files while the guest is running.

One problem I discovered with shared folders is that there is a long delay in accessing them. I found out the delay is caused by Windows trying to find a system named ".host" on the network and the solution is to define it as local host. Browse to the directory "C:\WINDOWS\system32\drivers\etc". If there is no "lmhosts" file present then copy lmhosts.sam to lmhosts. Edit it with Notepad and add the line " .host". Apply it (reboot again) and the delay should be gone.

I'm using a multi-head (non-Xinerama) monitor setup where I can run a VMware guest full screen on one monitor and have the Gnome desktop (or another VMware guest) on the other. One problem that I've encountered is that the Ctrl, Alt, and Shift keys would occasionally stop responding and eventually any Linux app I tried to type into would crash. This is a known bug in VMware and the solution is to run "setxkbmap". Since even a terminal window can crash when the problem is occurring I found it easiest to create a custom application launcher on the Gnome panel so I can just click it with the mouse. The fix is instantaneous and doesn't require VMware to be shut down.

Another oddity with Player on my multi-head system is that if it's running on the secondary monitor and I switch to a VT (Ctrl-Alt-F1, etc.) the vmplayer process disconnects from vmware-vmx process and the guest window is gone when I switch back. It doesn't happen on my primary monitor. If I run Player again it will reconnect to the running VM if I tell it to run the same one again so it's not fatal, just annoying.

I mentioned above about running two VMs at the same time. To save time you can use the same base VM and make duplicates of it for each with some minor modifications. You can also use them on different PCs. Regardless, there are some caveats to running multiple XP VMs simultaneously.

First is licensing. Make sure you have a valid license for each one. It's possible to change the product key after installation which will allow you to re-authenticate with Microsoft if necessary. This will save you from having to perform a reinstall of XP from scratch on each system. One thing to remember about VMware - it doesn't virtualize everything (the host's CPU for instance) and some parameters like the VM's MAC address are unique to each guest. These can be used by Windows Genuine Advantage to identify the system. Changing them can cause a revalidation prompt.

Second, some things must be different with each guest, the VM directory (obviously) and the aforementioned MAC address. The MAC address needs to be different in order for your DHCP server to assign a unique IP address to each one. By default Player uses an auto-generated MAC address which appears to be based on the VM UUID. Copying a VM will result in the same UUID and MAC address. To change it you need to change the UUID or set the MAC address manually in the vmx file, either of which can set off WGA revalidation. VMware also requires a different address range, 00:50:56:00:00:00 - 00:50:56:3F:FF:FF, for static values. Example:

ethernet0.addressType = "static"
ethernet0.Address = "00:50:56:3F:FF:FD"

Another parameter you may want to change is the displayed name of the VM which is shown in the "recently used" VM list in Player:

displayName = "Windows XP Professional - Testing"

On one of my systems Player would start misbehaving some time after installation. The guest VM would operate way too fast which would cause XP to freeze during boot probably due to timing problems with devices between the guest and host. This bug is caused by VMware misidentifying the host's maximum CPU speed due to power management or maybe ACPI problems. Minor timing problems often show up as creeping RTC (real time clock, aka "time of day") errors. The solution is to manually set the speed in "/etc/vmware/config". For a 2.53GHz CPU (cat /proc/cpuinfo):

host.cpukHz = 2530000
host.noTSC = TRUE
ptsc.noTSC = TRUE

There are many other parameters you can tweak in the vmx file. Some I've found usefull are ide1:0.fileName = "/dev/scd0" which had to be changed when IDE device names changed in recent kernels and the various "present" and "startConnected" parameters for specifying the default state of devices.

About Me

Omnifarious Implementer = I do just about everything. With my usual occupations this means anything an electrical engineer does not feel like doing including PCB design, electronic troubleshooting and repair, part sourcing, inventory control, enclosure machining, label design, PC support, network administration, plant maintenance, janitorial, etc. Non-occupational includes residential plumbing, heating, electrical, farming, automotive and small engine repair. There is plenty more but you get the idea.