WinXP using VirtualBox
From Linuxcentre Wiki
Due to having to run some Special Needs software for up to 10 users that is only available on Windows, we have devised a method for running this on the school Linux netbooks.
We would like the following features:
- Ability to undo any changes the user makes while logged in or the ability to lock-down the desktop.
- Ability to create and restore the Windows image when it crashes or gets messed up.
- Full microphone and speaker support.
- Powerful enough to use the required software.
There were several options:
- Use the server to run some virtual Windows instances in Xen/KVM.
- FAIL: This could have been possible if microphone and speakers worked via remote desktop properly - they didn't it was a pain.
- Run the software in WINE on the netbooks.
- FAIL: The software required glitched under Wine in some obscure cases.
- Run virtual machines with Windows on the netbooks directly.
- SUCCESS: The below procedure was used to build a very slim Windows XP image to run under VirtualBox.
Contents |
Build guide
Prepare the USB sticks
- Label the USB stick (fat32) as 'WINDOWSXP' (you only need to do this to label the USB sticks - not on every laptop!) ref. This is important since the netbooks will treat USB sticks with this label differently.
- Add these lines to /etc/mtools.conf:
drive p: file="/dev/sdc1" mtools_skip_check=1
-
- Run this command to change the label:
mlabel u:WINDOWSXP
Install VirtualBox
- Install Oracle version of VirtualBox.
- Get your WindowsXP installation disk copied to an ISO - it reads faster.
- Use nLite to create minimal XP image ref
- Create new Windows XP VM in vbox called 'WindowsXP'
- Install using newly created slimline Windows XP iso
- Install required applications
- Make the disk immutable (i.e. persistent image - no changes will stick): ref
# show storage devices vboxmanage showvminfo 'WindowsXP' # temporarily remove it vboxmanage storageattach 'WindowsXP' --storagectl 'IDE Controller' --port 0 --device 0 --medium none # make immutable vboxmanage modifyhd /media/WINDOWSXP/WindowsXP.vdi --type immutable # add disk image back to VM vboxmanage storageattach 'WindowsXP' --storagectl 'IDE Controller' --port 0 --device 0 --medium /media/WINDOWSXP/WindowsXP.vdi --type hdd # boot as usual
- Open virtualbox GUI
- Change any preferences you need
- Create a desktop launcher using: Machine->'Create Desktop Link' (optional)
- Close virtualbox
Setup unionfs
Unionfs is used to allow the USB sticks to be mounted read-only and have VirtualBox see it as read-write. This way we can ensure that USB stick partition corruption cannot occur. If you mount the partition read-write and the USB stick is pulled during a write to the filesystem the USB stick will often become unusable until it is reformatted.
Install unionfs
apt-get install unionfs-fuse
Setup Mountpoints
- Create some mountpoint directories as root:
mkdir /mnt/vbox mkdir /media/WINDOWSXP mkdir ~pupil/.VirtualBox/rwtmp
- Add this to /etc/fstab:
# create user mountpoint at /mnt/WINDOWSXP used for unionfs mount below LABEL=WINDOWSXP /media/WINDOWSXP vfat ro,nosuid,nodev,noexec,uid=1000,gid=1000,user,shortname=mixed,dmask=0077,utf8=1,showexec,flush,noauto 0 0 unionfs-fuse#/home/pupil/.VirtualBox/rwtmp=RW:/media/WINDOWSXP=RO /mnt/vbox fuse allow_other,use_ino,suid,dev,nonempty,cow,auto 0 0
- Disable opening a nautilus window when a USB stick is inserted (optional, but this is confusing for users when the insert the Windows USB stick) as 'pupil' user. In gconf-editor uncheck '/apps/nautilus/preferences/media_automount_open'
Running Windows
- Reboot the netbook
- Plugin the Windows USB stick
- Click the VirtualBox desktop icon
- Windows boots!
- Ensure you have sufficient Windows licenses to run the number of sticks you create - there is always a catch!.
To shutdown, just shutdown in Windows.
Updating Windows Image
- Manually mount USB stick read-write on /mnt/vbox
- Make the main vdi file normal (i.e. not immutable)
vboxmanage storageattach 'WindowsXP' --storagectl 'IDE Controller' --port 0 --device 0 --medium none vboxmanage modifyhd /media/WINDOWSXP/WindowsXP.vdi --type normal vboxmanage storageattach 'WindowsXP' --storagectl 'IDE Controller' --port 0 --device 0 --medium /media/WINDOWSXP/WindowsXP.vdi --type hdd
- Make the changes to the image by booting the image
- Make the main vdi file immutable
vboxmanage storageattach 'WindowsXP' --storagectl 'IDE Controller' --port 0 --device 0 --medium none vboxmanage modifyhd /media/WINDOWSXP/WindowsXP.vdi --type immutable vboxmanage storageattach 'WindowsXP' --storagectl 'IDE Controller' --port 0 --device 0 --medium /media/WINDOWSXP/WindowsXP.vdi --type hdd
- unmount
Merging the Snapshot files in non-immutable mode
I tried all sorts of ways but the cleanest way to merge the snapshot files into the main base VDI image is to clone it.
- Find the UUID of the latest snapshot file for your image using vboxmanage list hdds and by listing the files using ls -alrt /mnt/vbox/Snapshots/.
- Clone it to a new VM (this can take quite a while...):
vboxmanage clonehd <your UUID> /mnt/vbox/WindowsXP-v2.vdi
- Create a new VM using the same settings as before.
- When prompted, use an existing image and use the new cloned image.
- Tweak the settings of the new VM to be same as the old one.
- Delete the old VM.
- Move the old VDI file and snapshots into a backup directory (you can delete them later).
- Start the VM
- Shutdown the VM
- Make immutable as above.
To make the new vbox file load without the xml file knowing about it first: Open the ~/.Virtualbox/Virtualbox.xml file, remove any lines with a UUID mentioned and save it. (you can now add this to the homedir image for the netbooks).
To launch a new VM that has not been added, just run VirtualBox /mnt/vbox/WindowsXP-v2.vbox. It will not auto-start but at least this maintains backwards compatibility.
Notes about limitations
- Using an immutable image ensures that changes are not written to the USB stick.
- Temporary changes to the Windows disk are written to the netbook disk. This is limited in space so it could run outr of space. However this disk space is cleared upon rebooting the netbook.
- The graphics aren't terribly fast but enough for the requirements as we know them. I've installed the 3D acceleration in safe mode from the guest additions iso and switched it on in the VM settings but this does not seem to help much.
- Need to add the Oracle VirtualBox extension from their website so that USB2.0 works.
- Not tested Webcam yet. The built-in one probably will work since it is USB based. Will need to ensure driver is added to windows.
- The whole thing might work better from a faster USB stick or SD card. Currently boot time is approx 30 seconds and shutdown is 8 seconds.
- The virtualisation capabilities of the Atom N270 processor is very limited. It cannot do full virtualisation since it does not have the vmx extensions. This will make things slow compared to a processor that does.
- I've only allocated 512MB to the VM so this will limit things somewhat. The Host only has 1GB DRAM after all.

