27 de gen. 2010

How to Convert a Physical Hard Drive to a Virtual Machine

Recently, I was working on a customer’s computer which had a bad motherboard. The customer opted to go with a new computer instead of repairing the old one. Naturally, I copied all the documents, Outlook pst files, etc. to the new computer, but I thought, wouldn’t it be nice if I could create a virtual hard disk of the physical drive that I or the customer could actually boot into? However, I could not find a method to create a .vhd file from an existing hard drive, so I gave up the idea. The next day I attended a Microsoft Across America event in Gettysburg, and the Microsoft rep in his presentation mentioned that he had made a .vhd file of his wife’s old computer using a program called WinImage. I quickly jotted the name down, and today I had a chance to download the program and it does exactly what I’m after. With that lengthy introduction here are the steps you need to do to convert your physical hard drive into a Virtual Machine or .vhd file for use in Microsoft Virtual PC 2007 or a similar program.

Just for the record the physical drive I was imaging had Windows XP installed on it. The procedure is going to vary slightly for other versions of Windows.

1. Download and install WinImage. WinImage is free for 30 days after which there is a nominal $30 onetime charge. Definitely worth it.
2. Attach the physical hard drive to the computer on which you loaded WinImage. You can do this either by plugging it directly into the motherboard via an empty SATA or IDE port, or you can use a USB adapter such as this one from Amazon, which is by far the easier method.
3. Open the WinImage program. If you are running Windows Vista, make sure you run the WinImage (Administrator)mode which can be found under the WinImage folder under All Programs.
4. In WinImage, click the Disk menu item and then select “Creating Virtual Hard Disk Image from physical drive“.
5. Make sure the “Include non removable hard disk(s)” box is checked, and then select the hard drive that you would like to make an image of. You can either make a fixed size or dynamically expanding hard disk. I would recommend the dynamically expanding option. Click OK.
6. Select a location to store the .vhd file, and click Save. Be sure you have enough disk space.
7. At this point, WinImage will begin converting the hard drive to a .vhd file. This process could take an hour or more depending on the size of your hard drive, and how it is connected. Just be patient. :) Once the process is complete, your new .vhd file is ready to be opened with Microsoft Virtual PC. If all goes well, it will boot fine into Windows and you won’t have any problem at all. If so, you are good to go, and you can ignore the rest of the steps. However, most likely Windows XP will lockup or freeze while booting. In this case, proceed to step 8.
8. Ok. So you managed to create the .vhd file, but now regardless what you try Windows XP will not boot properly. Typically, the problem is the drivers that Windows is trying to load on startup. Here is what you need to do. Grab the closest Windows XP cd and pop it in. Start the Virtual PC, and in the CD menu, select Use Physical Drive. In the file menu select Reset.
9. Press any key when you see the “Press any key to boot from CD…” message. Once setup had loaded, type “R” which will load the Recovery Console. Enter the number of the windows installation you want to log onto. Most often its 1. Enter the administrator password if you have one, otherwise hit “enter”.
10. At the command prompt, type “CD System32″ , hit enter. Then type “expand D:\i386\HALACPI.DL_” , hit enter again. Finally, type “copy HALACPI.DLL HAL.DLL”, and hit enter. Type Y for yes on the overwrite file confirmation message. (*cd drive letter may vary)
11. Reboot the Virtual Machine. If everything works the way its supposed to you should see it boot into Windows. Likely, you will have to reactivate Windows before it will allow you to actually log on. Congratulations, you now have a virtual image of your physical drive.
12. Optional: Depending on how big your .vhd file is, you may want to compress the image. Check out this post for tips on that. Or this one.


If you still have difficulties you can check out the following websites which helped me tremendously.

Using Virtual PC for computer migration
Tips for migrating a physical computer to a virtual machine (part 2)
Tips for migrating a physical computer to a virtual machine (part 3)
Tips for migrating a physical computer to a virtual machine (part 4)

Disclaimer: Your mileage may vary. Make sure you have current backups before attempting any major changes to your computer. I’m not responsible for any problems that may occur from following or not following these steps. You also are responsible to make sure you have the appropriate Microsoft Software licenses for your virtual machines.

Update 10/13/2008 – If you get a blue stop screen with an error 0×0000007B try expanding hal.dl_ to the \system32 folder instead of halacpi.dl_.