domenica 11 ottobre 2015

HOWTO: Moving a Windows (XP) installation from a broken PC to a new one... using Virtualbox.

Move one hard disk from a broken PC to a new one, usually, does not suffice in order to get back our OS installation; the problem is the lacking of pre-installed drivers for chipset and peripherals (the new PC ones) that prevents the system boot.

Few days ago my father's motherboard broke. I had no time to: install a new operating system and reconfigure tons of programs,I decided to try a desperate recover of the old installation.

And.. I had an idea.

Using virtualbox in order to boot up my father's OS and prepare the old installation to the migration to the new hardware; I hoped that the old OS already had the drivers for the old emulated hardware.
In order to boot the old installation, Virtualbox can use a physical device like virtual device for a virtual machine, this is not a well known feature.

The Performed Task

I recovered the old windows XP SP3 installation, moving it from a broken Asus k8n motherboard, equipped with Athlon x2 4200+, to an Asus p5n-d with Core2Duo Q9300.
The system hard disk was a 1TB WD green model.
The Virtualbox system host was my mighty laptop, equipped with the Intel 4720HQ CPU, and Linux Mint operating system.

The Procedure

I'll refer to my laptop as PC-host.

Preparation

  • Take out the system hard disk (HD) from the broken PC
  • Connect HD to PC-host (for example via an external USB adapter)
  • Find out the assigned HD device name: dmesg or fdisk -l  linux commands (in my case it is /dev/sdb)
  • Mount the HD partitions and backup the data
  • Unmount the  HD partitions (mandatory)
  • give device access to the virtualbox user (for example via chmod 777 /dev/sdb)

Virtual machine setup

Create a new Windows XP (32bit) virtual machine(VM), but do not create ANY virtual disk, configuration details:
  • Chipset PIIX3
  • 2GB RAM
  • I have forgotten I/O APIC On, but I think this has no effect with winXP
  • Network NAT, PCnet-FAST III (Am79C973)
  • Pointing device: PS/2 Mouse
Create a virtual disk that connects to the block device:

This example is for my use case, Linux operating system and HD device /dev/sdb

VBoxManage internalcommands createrawvmdk -filename "myFatherDisk.vmdk" -rawdisk /dev/sdb

Add myFatherDisk.vmdk virtual device to the VM (you do it in the Virtualbox storage panel)

Recover and prepare OS

  • Boot the VM
  • Press F8 during boot in order to enter Safe Mode
  • Wait device driver installation to complete
  • Reboot
  • The VM might work fine, let's skip windows genuine registration
  • let's download the new motherboard/device drivers (in my case from ASUS page)
  • install the new drivers into VM
  • Disconnect HD from PC-host
Untested: you can also try disabling the WPA to avoid problems during migration, I think you can re-enable later. Or you can find a solution by your own (please read the next section about).

At this point you have the old OS already working as VM inside a new hardware (PC-host).

Move the HD to the new hardware

  • Connect HD to the new motherboard
  • Boot from HD
  • Press F8 during boot in order to enter Safe Mode
  • My case: Windows genuine activation request prevent you from proceeding and installing drivers; usb devices are not working yet, you need a connected ps2 keyboard in order to skip activation(*)
  • Wait device driver installation to complete
  • reboot
  • Clean installation, reinstall broken software (I reinstall video driver, just in case), install secondary lacking drivers, clean registry (for example via CCleaner)
  • Reboot few times :-D
  • Activate your windows
My father's new PC is ready!

Notes(*)

I was unable to skip the windows genuine activation when booting with the new hardware, this prevents the driver installation.
In order to skip it you need a working keyboard or mouse, but the new USB hub device is not initialized, yet.
Luckily I had an old ps2 keyboard and the motherboard connector.

There may be alternative (untested) solutions:
  • you can force the hardware device initialization first, by using the sysprep windows utility.  A possibile solution, may be using sysprep before disconnecting HD from PC-host and connecting to the new hardware. I have not deepened this road. Please refer to the instructions of the  syprep utilty.
  • Disable  windows genuine activation service, and re-enable it later.

In the event that you have a smarter solution to this problem, please share it with me.

Have fun