Windows

Convert Windows XP into a Windows 7 Virtual Machine with Disk2vhd

Greg Shultz shows you how to use Disk2vhd to move your Windows XP installation into Windows 7 and then run it with Windows Virtual PC.

Would you like to be able to still run Microsoft Windows XP while you get familiar with Windows 7? Well, moving your existing Windows XP system to a virtual machine that you can run in Windows 7 is a relatively easy procedure with the Disk2vhd tool from Microsoft's Windows Sysinternals team: Mark Russinovich and Bryce Cogswell.

In this edition of the Windows Desktop Report, I'll show you how to use Disk2vhd, which is a free tool, to move your Windows XP installation into Windows 7 and then run it with Windows Virtual PC.

This blog post is also available as a TechRepublic Photo Gallery and TechRepublic download.

What is Disk2vhd?

As its name implies, Disk2vhd is designed to create VHD versions of physical disks. This tool can be used to convert systems running Windows XP SP2 and up as well as Windows Server 2003 and up.

To perform this task, the Disk2vhd utility makes use of the Windows Volume Snapshot feature built in to the operating system. When you run Disk2vhd, it first creates a volume snapshot image of the hard disk. It then exports that image into a VHD that you can then add to Windows Virtual PC as well as to Hyper-V Manager.

If you'll be using Windows Virtual PC, keep in mind that it supports a maximum virtual disk size of 127GB. If you create a VHD from a larger disk it will not be accessible from a Windows Virtual PC virtual machine. Another thing to keep in mind is that Windows Virtual PC doesn't support the Multiprocessor Specification, and it will not be able to boot VHDs captured from multiprocessor systems.

Preparation

In order to ensure a successful virtual machine transition, there are several tasks that you'll want to perform on your Windows XP system in preparation for the operation. Let's take a closer look.

  • Backup: You'll want to back up your system using Windows XP's Backup Utility or a third-party disk imaging tool, such as EASEUS Todo Backup, which is a free package that I used for my test configuration. That way if anything goes awry, you can restore your Windows XP system and get right back to work. Just to be on the safe side, you may also want to back up all your data on CD/DVD or on an external hard disk. While it may sound like overkill, having an extra backup of your data will give you peace of mind.
  • Optimization: You'll want to make sure that your Windows XP system and hard disk are in tip-top shape by running Disk Cleanup and Disk Defragmenter. Doing so will help make the operation run quickly and smoothly. By running Disk Cleanup, all unnecessary files will be removed, such as trash in the Recycle Bin and Temporary Internet files. By running Disk Defragmenter, your hard disk will be ready for optimal performance.
  • Windows Update: You'll want to run Windows Update on your Windows XP system and make absolutely sure that all current updates are downloaded and installed.
Stay on top of the latest Microsoft Windows tips and tricks with TechRepublic's Windows Desktop newsletter, delivered every Monday and Thursday. Automatically sign up today!

My example configuration

In my example, I'll be using two different computers: one computer running Windows XP SP3 and one computer running Windows 7. I'll run Disk2vhd on the XP system and create the VHD on an external hard disk. The drive on this XP system is using about 40GB on an 80GB hard disk. I'll then move the virtual machine over to Windows 7 and run it there using Windows Virtual PC.

Getting Disk2vhd

You can get and use Disk2vhd in one of two ways. You can download Disk2vhd from the Windows Sysinternals page on the Microsoft TechNet site. Or you can run immediately Disk2vhd from the Live.Sysinternals.com site. Either way, the utility does not require installation, which means that using it is as easy as launching the executable.

Converting the system

I decided to run Disk2vhd from the Live.Sysinternals.com site for this article. Once I clicked on the link, I immediately saw the Internet Explorer File Download - Security Warning dialog box, shown in Figure A.

Figure A

As soon as the download commences, Internet Explorer displays the File Download - Security Warning dialog box.
When you click the Run button, the download begins, as shown in Figure B.

Figure B

The actual download is really quick.
Once the download is complete, the executable begins to launch, which triggers the Internet Explorer - Security Warning, shown in Figure C.

Figure C

As soon as the executable begins to launch, Internet Explorer displays a Security Warning dialog box.
You'll then need to accept the Sysinternals Software License Terms, as shown in Figure D.

Figure D

You are encouraged to read through the Software License Terms.
When you get to the main user interface, you'll see that Disk2vhd automatically selects all the available volumes/drives, sets a default location, and chooses a name for the VHD file. You can choose a different location and name if you want. In fact, the procedure will go faster if you select a different hard disk besides the one on which you are creating a VHD. Then, select the Prepare for Use in Virtual PC check box. As you can see in Figure E, I chose only the main drive and selected an external hard disk. When you are ready, click the Create button.

Figure E

You can choose specific drives as well as a different location and name.
You'll then have to sit back and wait. Depending on how large your hard disk is and the location of your destination folder, the process can take a while to complete. As the process chugs away, you'll see the progress, as shown in Figure F.

Figure F

The progress gauge keeps you apprised of the conversion procedure.
For instance, my XP system with about 40GB on an 80GB drive took just a little over two hours to complete the conversion and transfer to an external USB hard disk. When the operation is complete, you'll see the screen shown in Figure G.

Figure G

My example system took a little over two hours to convert to a virtual machine.

Running XP in Windows Virtual PC

Once you copy the virtual Windows XP system's .vhd file over to the Windows 7 system, you'll then open Windows Virtual PC and launch the Create a Virtual Machine wizard, as shown in Figure H.

Figure H

You'll launch the Create Virtual Machine wizard.
In order to reduce the amount of initial tweaking, I configured my virtual machine to have the same amount of RAM as its physical counterpart, as shown in Figure I.

Figure I

You'll specify the amount of RAM that you want your Windows XP virtual machine to have.
When prompted to add a virtual hard disk, select the Use an Existing Virtual Hard Disk option and then use the Browse button to locate your .vhd file, as shown in Figure J. When you've done so, just click the Create button.

Figure J

Select the Use an Existing Virtual Hard Disk option and then locate your vhd.
Once the Create a Virtual Machine wizard is complete, then just reopen Windows Virtual PC, locate the new virtual machine, and launch it. Of course, I had to do a bit of tweaking in order to get my XP system running, and because XP was now running on a new system, I had to reactivate Windows XP. However all that was relatively painless, and I was able to run my existing Windows XP installation in Window 7, as shown in Figure K.

Figure K

Windows XP is running inside of Windows Virtual PC in Windows 7.

What's your take?

Will you use this Disk2vhd to virtualize your Windows XP system? Have you used Disk2vhd before? If so, what has been your experience? As always, if you have comments or information to share about this topic, please take a moment to drop by the TechRepublic Community Forums and let us hear from you.

About

Greg Shultz is a freelance Technical Writer. Previously, he has worked as Documentation Specialist in the software industry, a Technical Support Specialist in educational industry, and a Technical Journalist in the computer publishing industry.

45 comments
BobMeiroff
BobMeiroff

I needed to create a VHD of a XP machine that is running legacy software that is old and only works on xp. So I used disk2vhd to create a VHD. Installed it into VM and now it wants a product key. No Joy!!!!

When I called MS some idiot tells me that he wants to remote into the MV to see if he can activate it. So if you can't activate the software why does MS even have this option??????

BobMeiroff
BobMeiroff

Tell then, what is the purpose of creating a VM if you can't use it.

yveslt
yveslt

Will this work with an OEM Windows XP? Keys are usually tied to some hardware signature so the key that initially installed XP my very well fail to be accepted once the disk image has been moved over to Virtual PC or Hyper-v.

tony
tony

A trick I have used in similar cirumstances - before doing the conversion, make sure that remote access is enabled and the networking is NAT or at least if fixed IP will work on the network. Then after the conversion to a VM, it is possible to use Remote Desktop Connection as an alternative means to be able to log on to the VM. This then allows you a bit more chance of fixing things. As an aside, I have a small USB keyboard (a bit smaller than a Kindle) that I keep in my toolbox for when I get to machines where the keyboard is not responding and frequently plugging this in, waiting for a few seconds for the driver to sort itself out and then you have control. It is possible (potentially) to do the same with VMs, but only if USB is supported e.g. VirtualBox and Virtual PC, but not Hyper-V. You may have to configure the properties of the VM to "patch" the extra USB keyboard across. Can't guarantee any of this will work in your circumstances, but it may point you to other possibilities.

CHRISWAMBO
CHRISWAMBO

All, Ever notice that if you create .vhd image (i.e. Windows 7), using Disk2vhd and then import the Disk2vhd Windows 7 .vhd to Windows 2008R2 Hyper-V Role, Windows 2008 Server doesn't recognized it. I get a failured that you can import virtual machine only if you use Hyper-V to create and export it. Chris

desvio
desvio

You say "Of course, I had to do a bit of tweaking in order to get my XP system running," in addition to reactivating XP. What exactly do you mean by getting it to run? Were you getting a BSOD due to chipset changes. Did you have problems with hal.dll? Was it a simple screen resolution change? You gave 3 seperate screenshots to show a fairly techincal audience how to download a file from the internet, but gave no details on what people likely want to know - How to "Convert Windows XP into a "-WORKING-" Windows 7 Virtual Machine with Disk2vhd.

mwheeler906
mwheeler906

It doesn't work if you have Win XP 64

richard_volk
richard_volk

Mr. Shultz, I have read your artical on XP to Win7 using Paragon GoVirtual. Which would you recomend, Disk2vhd or Paragon GoVirtual? thanks

rrm_computer
rrm_computer

I have Win 7 Pro and can't see the Windows Virtual PC on my start menu. Is this something I have to install as part of the Windows install?

Rodo1
Rodo1

I'll just keep running real XP...

DWalker88001
DWalker88001

I believe that you can't legally keep running the Windows XP installation in a virtual machine under Windows 7 forever, and also keep running XP on the old computer. Which means you also can't give away, or sell, the old computer with the working XP license on it. Once you re-activate XP in the virtual machine, according to the letter of the XP license, you need to completely wipe the old computer's XP operating system. The XP license lets you run XP on ONE computer. You probably won't go to jail for this, especially if you're using the XP system in the virtual machine only for a short time, but then again, I am not a lawyer...

bus66vw
bus66vw

Or will Microsoft allow reactivation of Windows XP OEM versions? If that was allowed would not your old computer's OS with the original installation become an illegal copy? Does this mean "Before you even think about trying this you must have a retail version of XP that can still be reactivated"?

Rob C
Rob C

MS would not know KISS if they sat on it (think about where you can be kissed). Can one do similar with NON MS software ? That is - run an 'image' of your XP in W7 ?

Simply_jperson
Simply_jperson

in this Procedure.,do i need windows 7 installer?.,thanks.,

Chaz Chance#
Chaz Chance#

As one of the apparent minority that bought into Vista, I want to know if there is any support for running Vista VMs in W7. As I own software that runs in Vista but declares that it won't run in XP, I have an investment in the answer. Supposedly knowledgable vendors seem suddenly uninformed about W7. I recently returned an order with W7 as OEM after it failed to run two thirds of my legacy software, which the vendor had claimed would all run under W7. (Sure, I might have tried some work-arounds, but it is the principle of the thing: If you say it will, and it doesn't, I get angry.) Interestingly, vendors tell me that they are still supplying machines with XP as an OEM install, but I can't buy machines with Vista as an OEM for love nor money!

salam
salam

Nice article as usual. However, is it possible to attache tha hard drive wgich contains XP to another machine and run DisktoVhd or it should be run from the machine that XP runs on? why I am asking because I have a laptop which is not powering on and I need to do the image from another machine. Also, my hard disk is 160GB, partioned to C:, E: and F: Is it possible to do it

galactica84
galactica84

Will my games run in this virtual machine ? Is it the same as the Windows XP Mode included in Windows 7 Professional ?

antiFud
antiFud

Hi Greg, Great article! One minor correction: you can convert multiprocessor images to run in Virtual PC. When you select the Prepare for Use on Virtual PC option on a multiprocessor system, Disk2vhd converts it to a uniprocessor configuration in the VHD.

Mark W. Kaelin
Mark W. Kaelin

Will you use this Disk2vhd to virtualize your Windows XP system? Have you used Disk2vhd before? If so, what has been your experience?

munimatrix01
munimatrix01

Hi Greg, I agree with Desvio, it would be extremely helpful if you would discuss the sort of tweaking that was needed. I have come across a # of issues I have fortunately and painstakenly have figured out. I will try and provide as much info as possible. I read an article that said that you can convert your XP computer to a VHD and that it was possible to load it up as guest virtual OS on Win 7 in virtual pc. I have successfully converted my XP sp3 laptop to a vhd, but when I try and open it up on the win 7 machine under virtual PC is when the problem starts. I can see the guest OS booting up with out any problems, but then it stops at the logon screen where I can see the username and the I beam blinking in the password field waiting for me to enter a password. I also see the cursor off to the side of the logon window. The thing is I cannot access the logon field or even move the cursor in the guest environment. I can still move the cursor around from the Host machine, but for what ever reason it seems as if the cursor from the host is not intergrating into the guest OS. the keyboard also does not seem to register either. It's as if i can view the guest OS in some sort of read only mode. but that's it, nothing more. Not much i can do with that other than close out of it. another observation I have made when is start up the guest OS it goes through the normal boot screens where you can actually select from a dual boot which some how has been created. It either gives you something like vhd xp professional as the first choice to choose from or the second one that reads as your standard windows XP professional boot. In any case the keyboard still works at this point. I have been able to select both boot options, but once it takes me back to the logon screen is where I get stuck. I have also noticed during the boot that I can also select f8 and try to access it through safe mode. I have gotten as far as selceting the mode, but once it gets me back to the logon screen everything is always in a frozen raqd only mode. I can access the virtual pc menu bar w/out any problems, but not the guest OS. Please any help on trying to figure this out would be greatly appreciated. I feel that I am so very close, but can't see why this is happening. Thank you for your time.

Rob C
Rob C

Two suggestions - I have nagged and complained for years, but this site still will not blank the Title Box, when a fresh post (at the top level) is added. If it was blanked, you would be forced to add a meaningful Title. Then there would be a chance that the kind (for posting those links) Mr Shultz, will notice your post. Because it was not blanked you inherited the generic Title, and there is a fair chance that he, like me, is not going to click every post, to see if it is of any interest to him. ( I hope the moderator reads this, and organizes for the Title Box to be ALWAYS BLANKED ) My second suggestion, would be to have Mr Schultz post displayed, when you click the Reply button. That will mean that your post will be shown as a child of Mr Schultz post, and he is much more likely to see it. And when you add a child reply, the Title Box will be blank, and that will force the entry of a meaningful Title

DWalker88001
DWalker88001

If the old license is an OEM license, you are not legally allowed to reactivate it on the new "computer" which is a virtual machine. I am sure of this part! It might work technically, but legally the OEM license is tied to the old hardware (which generally means the old motherboard). If the XP license is a retail license, you can legally reactivate it in the new virtual machine as long as you wipe the old computer and don't sell or give it away with XP still running. If the XP license is an MSDN or volume license, different rules apply.

rindi1
rindi1

That depends on which PC the VM is running on. If it is the same PC on which you originally had the OEM version activated on, then it is possible. But if you want to move the OEM XP installation from your old PC to a new one running Windows 7, and want to run that XP version of your old PC on that new PC, then no, you can't.

Spexi
Spexi

It work with all versions of Windows. Don't know how it looks like with versions before Win2000 but everything there after should work fine in make virtual. All versions can be reactivated once again, for every user that means a genuine product key that shows that this copy is mine. Both OEM and retail. In XP it is possible to avoid the reactivation process if it's already done by take backup on wpa.dbl and wpa.bak in old OS. Later on when the virtual copy is made and it starts asking for activation this can be prevented by copy and paste these files back to C:\WINDOWS\System32 folder.

rindi1
rindi1

Sure, you can use VMware's Player, which is also free and performs better than Virtual PC. There is also a converter tool on the VMware site. Or another Option would be Oracle's VirtualBox... The only reason one would want to use m$'s VPC is because when it is used as "XP Mode", you can start Apps within XP to directly show on your Windows 7 Desktop, without the XP desktop in the background (although XP still is running).

petremure
petremure

Of course, there are many other offering this free service, VMware and Paragon among them...

Rob C
Rob C

Can Vista upgrade to W7 ? Would that solve your problem ? If so, see if you can get some web site to start a petition. The petition should state that Vista obviously was a Beta for W7 Consequently, MS should provide a free upgrade to W7, for all Vista owners. Get enough signatures, and MS will do it, to shut you all up. "Now who could argue with that" (Blazing Saddles, in the church)

rindi1
rindi1

Sure the converter can be run on another PC, but if the OS you are converting is an OEM version, then you will only be able to run the VM, once converted, on the original PC.

Greg Shultz
Greg Shultz

...the same as Windows XP and yes your games should run on your virtual machine just fine.

SvenVdS
SvenVdS

Thank you, I was wondering the very same thing while reading the article. Which current pc/laptop hasn't got at least 2 cores? Too bad about the conversion to uniprocessor though, but at least now I know it's still useable.

theHankster
theHankster

At the end of 2009, I decided to upgrade my laptop with a new hard drive, more memory, and Windows 7, so I tried this. I had a number of issues, including the replacing the hal.dll, just to get the VHD to boot. There are a few lingering quirks, such as I can't drag and drop files between the desktop and the VM nor mount a "shared" folder in the VM. In the end, I didn't use it much as just about everything I needed works on Win7, so it just sits on an external hard drive for those "just in case" times.

dcbohn
dcbohn

One question I have is that my source hard drive is 70% available (unused), do any of these solutions allow me to resize the partition or do I need to use a 3rd party product first.

salam
salam

Yes, Itied it, run Disk2VHD, checked the 3 partitions, the tool was successful in creating the the VHD but when I try to create a new VM with VPC on win 7 I get an error "Can not attach hard drive"

glentech
glentech

There is a limit of 127GB for the vhd size. If you have a larger size you need to run VHD Resizer on it to reduce it to 127GB or smaller.You can find it here - http://goo.gl/qpsC You may also need to replace the hall.dll file on the VHD with halacpi.dl_ from the XP install disk. I converted a HDD but ended up not using it. The performance and stability wasn't good enough to use it. And that's on a new Dell system. I still feel like this can be a good way to use legacy XP apps.

rindi1
rindi1

There could be an issue with the keyboard driver not being loaded properly within your VM. To counter against that, before coverting your PC to a VM, try either removing the user's password, or configure it to login automatically (use "run", then enter "control userpasswords2" without the quotes. This should open up a specialized user management utility where you can select the user account that should automatically login. Then you need to enter that user's password twice. After that reboot the PC and check whether it automatically logs in. If it does, convert it again and then try it as a VM. Once it is inside Windows, it should find and install new drivers, and after some time you should be able to use the keyboard. After that make sure you install the Virtual PC integration tools and reboot. Once all that is installed and running, you can use the command above again to remove the autologin, or add a password again.

Greg Shultz
Greg Shultz

...there are other similar methods. For more information see my other articles: Move your entire Windows XP installation into Windows 7 with Paragon Go Virtual http://blogs.techrepublic.com.com/window-on-windows/?p=2859 Move your entire Windows XP installation into Windows 7 with Zinstall XP7 http://blogs.techrepublic.com.com/window-on-windows/?p=2770 Move your Windows XP installation into Windows 7 with VMware http://blogs.techrepublic.com.com/window-on-windows/?p=2649 Create a Windows XP and 7 dual-boot system staged for an easy migration http://blogs.techrepublic.com.com/window-on-windows/?p=1728

Rob C
Rob C

I raise Puppy "to PRAISE it, not to BURY Windows" (Marc Antony) I love Puppy, and I love the way it 'Persists' Data (Installed Programs, Settings, Downloads). NB I am not raising Puppy as an alternative to Windows. Do all VM's allow you to 'Persist' everything ?

Who Am I Really
Who Am I Really

Chaz already answered that: [i] As I own software that runs in Vista but declares that it won't run in XP, I have an investment in the answer. ... I recently returned an order with W7 as OEM after it failed to run two thirds of my legacy software, which the vendor had claimed would all run under W7[/i] the vista only software won't work in XP nor in win7

salam
salam

It is a standard win xp MSDN OS

jamey123
jamey123

I'm pretty sure it strips the drivers and OEM stuff out for the most part. I know that's how VMWares works.

Chaz Chance#
Chaz Chance#

Sure, as long as you shut down your virtual computer nicely.

Rob C
Rob C

Once I have the XP clone running within W7, and I install more programs, download files (into XP, which is running within W7), will all that be there tomorrow when I turn my PC on ?

Spexi
Spexi

They will be an almost identical clone of the real OS with all installed software and settings if do it like in this tutorial with a cloned copy from the old OS. It is also free and up to anyone to create a new clean OS in a new machine exactly the same as it was inside a real computer and begin from scratch too if using original CD or iso