VMWare: Migrating Windows XP and 2000 to a Virtual Machine

Submitted by Hannes Schmidt on Sun, 10/02/2005 - 19:38.

The other day I decided that I wanted to switch my laptop's German language version of Windows XP to the English language version. I could have reinstalled Windows XP from scratch but that would have meant losing all my settings and configurations and, since I have fine-tuned my system, many hours of work would have gone down the drain. Furthermore, I wanted to maintain the German version for certain tasks. What to do?

I went to the shop, bought a new hard disk and installed an English language version of Windows XP on it. I also bought a USB hard disk enclosure for the old hard disk that had German Windows XP on it. I then tried booting the German Windows from the USB hard disk. Obviously, that didn't work because Windows expected the hard disk to be attached to an IDE controller. The infamous "Inaccessible boot device" blue screen occurred. Also, dual booting is not really my thing because it takes too long to switch from one operating system to the other.

Going virtual

I needed a creative solution to this dilemma. I knew about the fact that VMware had the ability to use physical hard disks in virtual machines. Why not simply configure a virtual machine that would boot from the physical USB hard disk? To the virtual machine it would not appear as a hard disk attached to an USB controller, but rather as one attached to a SCSI controller. Unfortunately, the virtual machine was not able to boot the German windows because it didn't have a driver for VMware's` virtual SCSI controller. On the other hand, I was able to boot windows from the German recovery CD using the F6 function key and noting the virtual SCSI controller driver from a floppy disk, as described on VMware's web site. That made me wonder what would happen if I just replaced the driver file for the original IDE controller with the one for the virtual SCSI controller.

Apples instead of oranges

The IDE driver file is called atapi.sys. If I used that name for the SCSI driver file, I would be able to fool Windows into using the SCSI driver instead of the ATAPI driver without having to modify the registry. There are many ways to accomplish this, including hooking up the old hard disk to another Windows system and making the modifications there. However, since I had already booted the virtual machine into Windows' recovery console and loaded the SCSI driver, I made the changes from within the recovery console. I rebooted the virtual machine and – voil – it booted straight into Windows! I noted that the system replaced the fake IDE driver with the original, so I made sure not to reboot the system before I had the SCSI driver for VMware's virtual SCSI controller installed properly.

The VMware Tools contain an optimized version of that SCSI driver. (It's not possible to use the driver from the floppy disk image, because it only works when loaded into the installer via F6). To install the tools, VMware mounts a CDROM image into the virtual CDROM and Autostart launches the VMware installer inside the virtual machine. Unfortunately, I wasn't able to install VMware tools, probably because the virtual CDROM was IDE instead of SCSI. Because I had just replaced the IDE driver with a SCSI driver, the CDROM didn't work either.

I managed to get the VMware tools to install anyway using a roundabout method, though it would probably be better to do the following: either configure the VM to use a SCSI CDROM (I didn't test this myself) or put the image (i.e. the windows.iso file in your VMware program files directory) on the old hard disk and mount it inside the VM using your favourite virtual CDROM tool, e.g. Virtual CD, Nero, DaemonTools or Alcohol. You can also burn the image and copy the installation files onto the old disk. Whatever you choose, you must make sure that you are able to access the VMware tools installation files the first time you boot the VM from your old disk. You only have one shot, because Windows restores the original atapi.sys

Stepping through

Let me briefly outline what needs to be done to boot an existing Windows from a raw disk in a virtual machine. This is for advanced users, so I won't mention every mouse click.

  1. Before you detach your old hard disk, boot it one last time and create a new hardware profile as described here.
  2. Detach the old hard disk and put in the new hard disk. Install your new Windows. Install VMware Workstation. This is your host.
  3. Attach your old hard disk as a second IDE drive or through a USB/Firewire enclosure. The host's Windows will automatically create a drive letter for every partition on the old disk.
  4. Either
    1. put VMware's windows.iso onto the old hard disk (do this only if there is a virtual CD tool like DaemonTools or Alcohol installed in the old system),
    2. mount windows.iso into a virtual CD drive on the host and copy the CD's content into a directory on the old hard disk (do this if DaemonTools or Alcohol is available on the host) or
    3. burn windows.iso and copy everything from the burned CD into a directory on the old hard disk. Do this if you have a CD burner but no virtual CD tool.

If you have neither a CD burner nor a virtual CD tool, you need to download and install DaemonTools (it's free) and then do 4b.

  1. Use the Disk Management console (Control Panel - Administrative Tools - Computer Management - Storage - Disk Management) to remove drive letters from every partition on the old hard disk. This is important! You must make sure that host and guest never access the drive simultaneously. By removing drive letters you are telling the host not to mount these partitions anymore.
  2. Download the virtual SCSI driver floppy image here.
  3. Create a new virtual machine and configure it to use your old disk as a raw device as described here. VMware lists raw devices in a rather ambiguous way – the devices are named PhysicalDrive0, PhysicalDrive1 and so on. If you have difficulties picking the right physical disk when configuring the VM, disconnect all USB and Firewire devices except your old hard disk and try again. You might have to restart VMware for it to detect that disk devices were detached. You can also identify your drives using the Disk Management console . The disk listed as Disk0 in Disk Management will be referred to by VMware as PhysicalDrive0, Disk1 is PhysicalDrive1 and so on.
  4. Mount the downloaded floppy image into the VM's virtual floppy drive, insert the Windows Installation CD into your CDROM drive and power the VM on. If you let it boot from the disk, it will briefly enter the graphical Windows logo screen and BSOD (blue screen of death) then reboot – so don't do it.
  5. Instead, boot the VM from CD (hit Esc during POST and select the CDROM drive). When a message appears at the bottom of the screen telling you to hit F6 if you want to load additional drivers, do it. Follow the instructions to load VMware's SCSI driver from the floppy drive.
  6. Activate the recovery console and
    cd C:\WINDOWS\SYSTEM32\DRIVERS
    ren atapi.sys atapi.old
    copy a:\vmscsi.sys
    ren vmscsi.sys atapi.sys

    If your old disk was attached to a SCSI or Serial ATA controller, you can't use atapi.sys. You need to find the driver file for your type of disk controller and copy vmscsi.sys over that file. The recovery console command LISTSVC might give you an idea what the name of the driver is. Look for entries with SERVICE_BOOT_START, which represents drivers to be loaded early on in the boot process. The disk controller driver must be one of them.

  7. Reboot the VM by typing “exit” at the recovery console prompt. The VM should boot straight into the old system.
  8. Install VMware tools from the directory/disk image create in step 4.
  9. Reboot again.

You've been warned!

First warning: never, ever attempt to access the old disk from host and guest simultaneously as it will cause you to lose data!

Second warning: if your old disk is attached via USB or Firewire, don't unplug the old disk while the VM is running. I guess this one is obvious, though the next one isn't.

Third warning: if your old disk is attached via USB or Firewire, don't pause the VM before powering the host off the host, putting it into standby/hibernation, or detaching the USB drive. If you want to shut down/standby/hibernate the host or detach the old disk drive, shut down the VM completely and eject the drive using the "Safely Remove Hardware" taskbar icon. This is a rather drastic limitation and I'm sure it can be weakened, but I tend to be overly cautious when my data is at risk.

That's it for today, folks. Enjoy your new, old, virtualized Windows and stay tuned.

( categories: VMware | Windows | Administrator )
Submitted by Anonymous on Fri, 09/02/2011 - 09:45.
Sweet article! Thank you, I tried converting an XP machine to Virtual PC using this, but obviously ran into licensing problems as well (mine is an OEM machine.) Some great newer options I've also tried: Disk2vhd, which does HAL migration, but still needed help with the storage drivers you mention. I also tried SmartMigrate, which did HAL migration AND the storage drivers, too. I'm still testing the VM, but my problems may have more to do with Virtual PC than anything.
Submitted by Anonymous on Wed, 01/21/2009 - 06:14.
Thank you for this really great article, it works like it should ;)
Submitted by Anonymous on Thu, 11/15/2007 - 08:02.

I can verify that this scenario works even with Virtual VMWare SCSI discs. You only need to copy the contents of your original physical HD to the virtual HD. Any backup or imaging tool should suffice (gparted, ghost, pba-vm). I won't go into details here. Just backup the original machine to a network storage. Then restore it inside VMWare virtual machine to a virtual disc. If the disc doesn't boot, use FIXMBR and FIXBOOT commands in the recovery console.
There were no problems with video, audio or network. The VMWare tools contain drivers for all of them.
-- jb

Submitted by Anonymous on Sun, 09/09/2007 - 13:53.

Great article -- But I don't understand something, why use SCSI for the physical hd? Doesn't vmware support ide for physical disks?

If you can scrounge enough temporary disk space (and newer drives have plenty), you could create a virtual ide disk and copy all the files over to it -- maybe do a sector copy... And then all the problems of data corruption, sleep mode, etc. would go away.

Did the change in video and sound hardware cause you any problems?

Thanks for the cautionary notes, it tells me never to use vmware physical disk access, except perhaps to make a copy of it and only then with a UPS attached.

-- Codeslinger