Windows Can’t Handle the Hardware…

How to run Windows XP truly seamlessly on hardware with few available drivers, by proxying it though Linux’s better hardware support.  Using Virtualization as the hardware compatibility layer.  [Used VirtualBox on Ubuntu for the impatient]

You can’t buy computers with Windows XP on them anymore, but some business’s want to keep using it. They don’t see the benefit in upgrading to Windows 7 and have roadblocks preventing them from moving to Linux.

What you need:
* Valid Windows XP License(s)
* Ubuntu Media and ability to get VirtualBox
* Removable media for testing (usb sticks, cdroms, etc)

1. Base Setup.  First off install Ubuntu.  I’m using the default edition (gdm needs to be installed).    Remove applications that won’t be useful for you. (I only left Accessories and Firefox).  Oh, and of course install VirtualBox, I suggest adding the repository from Virtualbox’s website.

2. Set up a Windows XP VM in the default account how you would like it.  Remember to give it the majority of the resources of the machine, but not more than let’s say about 80-85%.

3. Now it’s time to set up the ability to auto login to VirtualBox!
This file allows WinXP to be a session option along side Ubuntu/Classic Gnome etc.  With autologin and no password required, this is how we make that part seamless (options in Users and Groups).

/usr/share/xsessions/WinXP.desktop

[Desktop Entry]
Encoding=UTF-8
Name=WindowsXP
Comment=My Virtual WindowsXP
Exec=/opt/bin/WinXP
Icon=
Type=Application

4. Create the VM launcher script
This launches the VM and also keeps a very important script running only when the VM still exists…

/opt/bin/WinXP

#!/bin/bash
VirtualBox –startvm WinXP –fullscreen &
sleep 2
/opt/bin/AddUSB.sh &

while [ “$(pgrep VirtualBox)” ]; do
sleep 2
echo “Doing”
done
killall AddUSB.sh

5.  Create the USB adding script.

VirtualBox doesn’t currently have the ability to set up automounting of all USB media with no user interaction (at least with a Linux Host and Windows guest).  This script works around that by listing available usb devices and then adding them to the host.  Due to being run every two seconds it only introduces a small delay.  Installing “inotify-tools” is required.

/opt/bin/AddUSB.sh

#!/bin/bash

VBoxManage list usbhost | egrep “UUID:|Product:” | grep -v Mouse | grep -v Keyboard | grep Product: -B 1 | grep -v Product: | cut -c21- > /tmp/MountThese
for i in `cat /tmp/MountThese`;do VBoxManage controlvm ‘WinXP’ usbattach $i;done
rm /tmp/MountThese

while inotifywait /var/log/syslog; do
VBoxManage list usbhost | egrep “UUID:|Product:” | grep -v Mouse | grep -v Keyboard | grep Product: -B 1 | grep -v Product: | cut -c21- > /tmp/MountThese
for i in `cat /tmp/MountThese`;do VBoxManage controlvm ‘WinXP’ usbattach $i;done
rm /tmp/MountThese
done

Any comments/suggestions very welcome!

3 thoughts on “Windows Can’t Handle the Hardware…”

  1. Hi, I’m doing a how-to presentation for our monthly LoCo meeting, and though your guide to add virtual Windows to GDM would be a very cool thing to feature.

    I’ve got a couple of questions about it:
    1. What happens when you shutdown Windows?
    2. How can you switch out of the Windows GDM session and log in to Ubuntu (if we ever need to)?

  2. 1. What happens when you shutdown Windows?
    > It goes to the GDM login screen.
    2. How can you switch out of the Windows GDM session and log in to Ubuntu (if we ever need to)?
    > Add another account so that you can switch to it, then switch your desktop choice. This certainly could use some work though, it can get quite annoying if you miss-click.

Leave a Reply

Your email address will not be published. Required fields are marked *