How to install Windows OEM into a Virtual Machine
For everybody who uses a Unixoid Operating System (eg. Linux, BSD, OpenSolaris) as primary system and Windows only as a second thought that might sometimes be needed, it is often very annoying that Windows OEM tends to be bundled to a specific hardware and won't install on anything else - including a virtual machine running on the right system. The good news is that this problem can be solved.
A little legal warning: the Windows license bundled with your hardware is supposed to run on exactly one machine. Depending on your jurisdiction there might be some levity of whether it has to be the same machine. Don't ask me for more detailed advice, I am not a lawyer - just be warned that there are limits to what you can do.
You will need to install dmidecode, a little util to decode BIOS information, and virtualbox version 2.1 or newer including all the necessary modules. As far as I'm aware this will not work with any other virtualization system, like VMWare or Xen.
A little hint on the side: experiment a little with a virtual Linux or other free operating system before you jump into installing an unwilling Windows. This way you get a better feel for how VirtualBox handles.
First you need to create a virtualbox environment for Windows. The virtual harddisk should be at least 15GB big for Windows XP and at least 25GB big for Windows Vista. Use growing disk images - that way it does not hurt that much. You should also use virtual PCnet FAST-III or Intel adapters, since Windows does no longer carry drivers for the older PCnet-PCI II adapters. Make sure you decide right away whether you want ACPI and IO-APIC active or inactive - switching it off later will brick Windows, switching it on later will have no effect - Windows installs different kernels for each combination.
Fully create the VM, but don't start it yet. Be prepared to spend the better part of a day on this task.
When Windows is bound to hardware it really is bound to the BIOS of that machine or more precisely what this BIOS tells the system about its name and vendor. You can find out all about this with a simple command: dmidecode -t0 tells you all about the BIOS itself, and dmidecode -t1 all that the BIOS knows about the hardware it is running on (so called System Settings).
Then copy what you see into the newly created VM's configuration:
sh$ VBoxManage setextradata "My VM" \ "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSVendor" \ "Host BIOS Vendor"
The first parameter (setextradata) tells VBoxManage to enter this data into your configuration. Replace "My VM" with the name of your new VM. The third parameter is the key under which it is entered and the fourth parameter needs to be replaced with the appropriate value from dmidecode. Possible keys are:
Hint: many OEMs make up the version number from digits only, but VirtualBox will complain that it is supposed to be a string - just add a space to it.
Hint 2: The virtual machine description is a XML file in $HOME/.VirtualBox/Machines - you can edit it with any editor, but be careful not to corrupt it.
Now for the lengthy part: insert the Windows OEM installation CD into your drive, mount it into your VM from VirtualBox and then start the VM. If there are no typos in your configuration you should be able to install Windows into this VM - it will tell you before it copies anything onto your virtual hard drive.
VirtualBox provides a few things that make life easier. I recommend to install the VBox guest additions inside your Windows guest, among other things that will remove the need to grab and release the lock on your mouse everytime you switch between Windows and the host system and it will make the guest more flexible in regards to screen resolution.
VirtualBox provides shared folders - this allows you to write data onto a virtual network share and makes data exchange between host and guest easier. For Windows this requires the guest additions to be installed. The shares are available under \\vboxsvr\sharename.