Bringing your Win XP installation up in Linux
Please be aware this is a "Work in Progress".
So you have an existing installation of Windows XP with lots of software and and you want this to run in Linux, right?
You do this using a virtualisation package called VirtualBox
You will also need your live CD image which you would have download from here (this is a direct link to the UK 32-bit version.)
Currently looking at http://blarts.wordpress.com/2007/12/06/how-to-run-virtualbox-using-a-physical-partition-using-ubuntu-feisty-fawn/...
...which seems to have good (but piece meal) instructions
Also http://www.virtualbox.org/wiki/Migrate_Windows
Also http://www.justsoftwaresolutions.co.uk/general/importing-windows-into-virtualbox.html...
...has an interesting and possibly robust way of doing it
Also hhttp://ubuntuforums.org/showthread.php?t=1106180...
...from a Ubuntu forum
Also http://windowsitpro.com/mobile/article/articleid/76145/jsi-tip-4839-how-do-i-move-windows-xp-to-different-hardware.html...
...shows some technical depth and some robust processes
I will be testing this on a deliberately broken and recovered version of Windows XP.
I will "break" it by moving the installed hard disc to a new computer and allow it to blue screen (through bad hardware recognition) then recover it using a different install disc to the original.
Next I deliberately infect it with viruses and install a virus program to remove these.
The reason for this is because I know you will not be doing this with a clean install of Windows XP.
You will have used it for a few years and probably have had to fix it due to some crash or virus infection a some point in it's life.
In fact you may well be doing this because your Windows XP is infected or unstable in some way right now.
NOTE: You need to prepare your windows installation first, by creating a new hardware profile
I will add instructions soon on that.
Also you should make sure you are not running VirtualBox or any virtual machines first.
IMPORTANT: I would always use a live CD to protect yourself from damage to your PC installation.
The reason is that you would be booting your real hard disc, which you would be already using, inside a virtual machine.
The virtual machine would write back to the disc at the same time as your currently running operating system
which would result is corruption, loss of data and could render your PC unbootable and unrecoverable.
Using a live CD protects you from this happening, since you would not originally use your real hard disc to boot.
Paste these commands into a terminal and it will eventually boot your hard disc into VirtualBox:
sudo aptitude update
sudo aptitude install -y virtualbox-ose # This was just 'virtualbox'
sudo usermod -a -G disk $USER
sudo -u $USER -i
mkdir -vp /home/$USER/.VirtualBox/HardDisks/
cd /home/$USER/.VirtualBox/HardDisks/
VBoxManage modifyvm "harddisc" -hda none
VBoxManage closemedium disk sda.vdi
rm -vf sda.vdi
VBoxManage unregistervm "harddisc" -delete
VBoxManage createvm -name "harddisc" -register
VBoxManage modifyvm "harddisc" --memory 256 --acpi on --nic1 nat --ioapic on # Changed in v3
PARTITIONS=`VBoxManage internalcommands listpartitions -rawdisk /dev/sda |awk 'BEGIN{printf "1"} $2=="0x07"{printf ",%d", $1}'`
VBoxManage internalcommands createrawvmdk -filename sda.vdi -rawdisk /dev/sda -partitions $PARTITIONS -register
VBoxManage modifyvm "harddisc" --hda "sda.vdi" # This no longer works
VBoxManage startvm "harddisc"
I added some intelligence to only allow access to the first parition (assuming this contains the OS loader, grub) and any NTFS partitions, but hide anything else.
This is an example session (with some cutting '. . .'):
gnorth@graham-workstation:~$ sudo aptitude update
Writing extended state information... Done
Ign cdrom://Xubuntu 9.04 _Jaunty Jackalope_ - Release i386 (20090420.1) jaunty/main Translation-en_US
. . .
Get:30 http://archive.ubuntu.com jaunty-updates/multiverse Sources [1349B]
Fetched 9756kB in 17s (561kB/s)
Reading package lists... Done
Current status: 132 updates [+132], 14 new [+14].
gnorth@graham-workstation:~$ sudo aptitude install -y virtualbox
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Note: selecting "virtualbox-ose" instead of the
virtual package "virtualbox"
The following NEW packages will be installed:
dkms{a} fakeroot{a} libaudio2{a} libmysqlclient15off{a} libqt4-dbus{a}
libqt4-designer{a} libqt4-network{a} libqt4-qt3support{a}
libqt4-script{a} libqt4-sql{a} libqt4-sql-mysql{a} libqt4-xml{a}
libqtcore4{a} libqtgui4{a} mysql-common{a} patch{a} qt4-qtconfig{a}
virtualbox-ose virtualbox-ose-source{a}
0 packages upgraded, 19 newly installed, 0 to remove and 132 not upgraded.
Need to get 20.6MB/20.9MB of archives. After unpacking 73.3MB will be used.
Writing extended state information... Done
Get:1 http://archive.ubuntu.com jaunty-updates/main libqtcore4 4.5.0-0ubuntu4.1
. . .
Get:17 http://archive.ubuntu.com jaunty/universe virtualbox-ose-source 2.1.4-dfsg-1ubuntu3 [630kB]
Fetched 20.6MB in 36s (559kB/s)
Selecting previously deselected package libqtcore4.
(Reading database ... 114257 files and directories currently installed.)
Unpacking libqtcore4 (from .../libqtcore4_4.5.0-0ubuntu4.1_i386.deb) ...
. . .
Unpacking virtualbox-ose-source (from .../virtualbox-ose-source_2.1.4-dfsg-1ubuntu3_all.deb) ...
Processing triggers for man-db ...
Setting up libqtcore4 (4.5.0-0ubuntu4.1) ...
. . .
Setting up virtualbox-ose-source (2.1.4-dfsg-1ubuntu3) ...
* Reloading kernel event manager... [ OK ]
Adding modules to DKMS build system
Doing initial module builds
Installing initial modules
Done.
* Stopping VirtualBox kernel module... [ OK ]
* Starting VirtualBox kernel module... [ OK ]
Processing triggers for libc6 ...
ldconfig deferred processing now taking place
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Writing extended state information... Done
gnorth@graham-workstation:~$ sudo usermod -a -G disk $USER
gnorth@graham-workstation:~$ sudo -u $USER -i
gnorth@graham-workstation:~$ mkdir -vp /home/$USER/.VirtualBox/HardDisks/
mkdir: created directory `/home/gnorth/.VirtualBox/HardDisks/'
gnorth@graham-workstation:~$ cd /home/$USER/.VirtualBox/HardDisks/
gnorth@graham-workstation:~/.VirtualBox/HardDisks$ VBoxManage modifyvm "harddisc" -hda none
VirtualBox Command Line Management Interface Version 2.1.4_OSE
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
gnorth@graham-workstation:~/.VirtualBox/HardDisks$ VBoxManage closemedium disk sda.vdi
VirtualBox Command Line Management Interface Version 2.1.4_OSE
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
gnorth@graham-workstation:~/.VirtualBox/HardDisks$ rm -vf sda.vdi
removed `sda.vdi'
xpuser@xp-laptop:~/.VirtualBox/HardDisks$ VBoxManage unregistervm "harddisc" -delete
VirtualBox Command Line Management Interface Version 2.1.4_OSE
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
gnorth@graham-workstation:~/.VirtualBox/HardDisks$ VBoxManage createvm -name "harddisc" -register
VirtualBox Command Line Management Interface Version 2.1.4_OSE
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
Virtual machine 'harddisc' is created and registered.
UUID: 1b178f06-e715-431c-9a6f-9f6b4a0a7b2d
Settings file: '/home/gnorth/.VirtualBox/Machines/harddisc/harddisc.xml'
gnorth@graham-workstation:~/.VirtualBox/HardDisks$ VBoxManage modifyvm "harddisc" -memory "256MB" -acpi on -nic1 nat -ioapic on
VirtualBox Command Line Management Interface Version 2.1.4_OSE
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
gnorth@graham-workstation:~/.VirtualBox/HardDisks$ PARTITIONS=`VBoxManage internalcommands listpartitions -rawdisk /dev/sda |awk 'BEGIN{printf "1"} $2=="0x07"{printf ",%d", $1}'`
gnorth@graham-workstation:~/.VirtualBox/HardDisks$ VBoxManage internalcommands createrawvmdk -filename sda.vdi -rawdisk /dev/sda -partitions $PARTITIONS -register
VirtualBox Command Line Management Interface Version 2.1.4_OSE
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
RAW host disk access VMDK file sda.vdi created successfully.
gnorth@graham-workstation:~/.VirtualBox/HardDisks$ VBoxManage modifyvm "harddisc" -hda "sda.vdi"
VirtualBox Command Line Management Interface Version 2.1.4_OSE
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
gnorth@graham-workstation:~/.VirtualBox/HardDisks$ VBoxManage startvm "harddisc"
VirtualBox Command Line Management Interface Version 2.1.4_OSE
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
Waiting for the remote session to open...
Remote session has been successfully opened.
After what appeared to be a successful boot, this happened:
Then it wouldn't boot, it wouldn't get past this:
I have a feeling I may have messed this up by mounting the partition used as the C: drive. Even though I umounted it before using the VM, I think the disc caching may have messed this up.
So do not mount any used partitions from the disc into the host OS
Even if you umount them before using them in the VM the OS caches it and will write this back later.
All was not lost.
I used the XP install disc to recover and I have a working system again.
This currently only works in the VM.
I think I only restored that HW profile.
You see this on the screen:
I seem to remember this was something to do with the C:\boot.ini
I tried the whole process again with another "used" copy of WinXP and this happened:
So what's interesting here is this is the exact same error as the shot of the laptop screen.
So we have the same error now in the VM but a working real copy.
This is explained and a fix is available from both the VirtualBox how-to and the MS knowledge base article to which links
So there appears to be a fix for this:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;314082 describes it
as having the wrong drivers for the hard disc caused by moving the hard disc to another computer, ...
...which makes some sense since that's probably how the OS sees it.
It describes a method using a booted version of Windows, which is not very helpful since you get the stop error trying to boot Windows even in safe mode.
They could suggest using BartPE (http://www.nu2.nu/pebuilder/),...
... but that would be suggesting a quality non-Microsoft solution and they can't have that!
SO I use this patching tool to patch the registry IDE settings and Voila!
It was obtained from the VirtualBox article shown near the top of this page.
I can boot the laptop (in the image above) natively as well as in a VirtualBox VM. Cool.
Unfortunately the patch is in german (instructions and errors).
I have translated it to english and will add it to this page (probably tomorrow, 21/07/09)
Closer inspection of MergeIDE.zip reveals that it simply implements in batch script the instructions from the Microsoft article above