Home > vhd, virtual server, virtualization, vmware, windows > Reliable, Free P2V Solution

Reliable, Free P2V Solution

If you have ever had to take on a Physical-to-Virtual (P2V) migration of a server or other machine, you know that you generally have a fine balance of the following triangle of factors: cost, complexity, and reliability. It seems like the only way to get an easy and reliable solution is to throw gobs of money at either a VMWare infrastructure or something like Platespin. Don’t get me wrong: from what I’ve heard they both offer excellent solutions in that field, but it simply isn’t cheap. I had to find out the hard way, but there is another way.

The problem I was facing was that within my first month at a new job (still working there; awesome shop), I was tasked with a P2V conversion on a server, with no virtualization infrastructure in place in the organization. Since we were new to virtualization at the time and were just dabbling to start, keeping costs low (or non-existent) would also be a plus. I had to research and present a solution, figure out how it works, and get it done. We are very much a Microsoft shop, and the preference was for a Microsoft solution; so, Virtual Server it is. No problem there, as VS is free and so helped on the cost side. Now that we had the virtualization platform figured out, we just needed some way to get it from the physical box into virtual hard drives (VHD’s) with the whole thing still operational at the end. Here’s where the problems began.

Now, this was late 2006, and even in the last year virtualization has come a long way. Doing a little digging, however, I found out that Microsoft had actually released a free P2V too called the Virtual Server Migration Toolkit (VSMT). Naive as I was, I was excited that I had found an all-Microsoft solution that was still free and so fit the bill for the project. So…remember that triangle of cost/complexity/reliability that I was talking about? While VSMT is low on the cost, it cranks the complexity factor WAY up! I also discovered that the reliability portion was not really all there. If any of you have had the traumatic experience of working with VSMT, you’ll know what I’m talking about. For those fortunate souls unacquainted with it, here’s a brief glimpse into VSMT:

It requires Microsoft Automated Deployment Services (ADS), which is basically an MS solution for deploying Server 2003 to bare metal servers over the wire; fair enough. ADS in turn requires Windows Server 2003 Enterprise Edition and DHCP with a PXE environment. The gist is that the source machine (the machine you are trying to perform the P2V on) boots with a PXE image sent out by the ADS server. This puts the machine into a state where the ADS server controls it. At this point VSMT enters the picture. You then have to design what is best described as a workflow of various VBS and XML-based scripts that prepare the machine for cloning to an image, capture data from the machines hard disks to an image on the ADS server, again run some scripts against the image to take care of things like making the HAL and kernel generic, and then create a Virtual Server configuration file (.vmc) for the whole setup. Granted I was new to this game at that point, but I spent the better part 2 weeks on this project, with various failures ranging from the initial capture phase, blue screens on my ADS server, having to manually find/replace variables in scripts because they weren’t expanding properly, among other things, and all with virtually zero support available either from MS sites or from the community at large (as no one was apparently crazy enough to try to use the thing). I later attended a Technet conference on Microsoft’s virtualization solutions in Vancouver. When I mentioned to one of the presenters in a Q&A section that I had successfully completed a P2V using VSMT, he expressed actual surprise at the fact that someone got the whole thing to work! A few months later, the VM started logging disk errors and failed to back up successfully, and we ended up scrapping the VM and building a new one from scratch. Like I said, low cost but high complexity and low reliability.

So, when I heard that Microsoft was releasing a Beta of Systems Center Virtual Machine Manager (SCVMM, although it was just VMM at that point), I jumped at the chance to try this thing out. Point and click P2V? Sign me up! I later discovered that Beta1 did not yet include P2V functionality, so my hopes at a simple P2V solution faded again. These days, of course, you can get yourself a copy of the full version System Center Virtual Machine Manager for around $500 US, but unfortunately that still does not completely satisfy my “cheap-to-free” preference.

When the next P2V project rolled around, I was desperate to find something, anything that would avoid the VSMT debacle. I even started looking outside of the Microsoft camp to anything that could get our physical box running as a VM, and lo, I was rewarded! Enter VMWare Converter. VMWare had been kind enough to release a simple, free P2V utility that can run on pretty much any version of Windows, including client OS’s like XP, and was a simple wizard-driven point-and-click process without all the infrastructure requirements. Beautiful! Unfortunately this did not get us to a Virtual Server machine. But, wait! There’s hope! A simple, self-contained utility called VMDK2VHD was released by vmToolkit. This beauty of a tool allows you to convert your VMWare VMDK-format virtual hard drives into MS Virtual Server/PC VHD files. I was set!

The overall process was even pretty painless. Of course it can take a few hours for the whole process if you’re converting machines with a whole bunch of data, but trust me, it’s a breeze compared to some of the other options out there.

So, here’s what you need:

  • Source physical machine
  • I recommend having a conversion tools machine to install all the required software onto and to do all the grunt work of the actual conversions.
  • VMWare Converter installed (probably on your conversion tools machine)
  • Access to enough disk to store both the VMWare VMDK hard disk files and the Virtual Server/PC VHD hard disk files
  • VMWare Server installed (probably on your conversion tools machine).
  • PrepVM.vbs script (more on that later)
  • Generic hal.dll or ntoskrnl.exe, either from your Windows setup CD or from %windir%\system32\servicepackfiles if you have applied a service pack at any time.
  • VMDK2VHD extracted somewhere (probably on your conversion tools machine). Note that this utility is self-contained and does not need to be installed, just run.
  • Virtual Server or Virtual PC installed somewhere to test the final product.

If you have all that, you are ready to go:

  1. Ensure that the source physical machine is running, and that you have network connectivity to it from your conversion tools machine.
  2. Launch the VMWare Converter application on your conversion tools machine.
  3. Click Import Machine and follow the wizard to set the options for your conversion. A few notes: (1) VMWare Converter will install an agent on the source physical machine, and will ask you for administrative credentials to connect to the machine. (2) When selecting the partitions to convert, be sure to un-check utility partitions as are found on many servers. VMWare Converter will not understand these partitions, and the conversion will fail. (3) It is best to output your data to a single VMDK file and not to use the VMWare option of splitting the hard disk into multiple 2 GB files. Virtual Server does not use a similar technique, and the VMDK2VHD tool will not understand it as far as I recall. (4) Be sure to select the correct output format for your file. If you are running a different version of VMWare from the version that VMWare Converter is creating, you will not be able to start your VMWare virtual machine and complete the conversion process.
  4. Start the conversion, and then go for lunch…this process can take a while, as it is reading all of your source data, converting it into a VMDK format, and writing it to the destination VMDK file.
  5. When the conversion completes, I recommend making a backup copy of the VMDK files and working with those from now on. If things blow up, you can roll back to the VMDK files rather than having to re-do the whole capture process.
  6. Configure a new virtual machine in VMWare Server to use the VMDK file created and start it up. I recommend leaving the network cards disconnected and logging on locally, as this will avoid problems such as IP address and naming conflicts that come with having both the physical machine and its virtual counterpart on the same LAN.
  7. Log on to the VMWare virtual machine. NOTE: Cancel all of the “New Hardware Found” wizards that pop up. These are all for VMWare virtual devices, and we will be getting rid of these anyway. Installing them is just a waste of time and might mess with the whole process.
  8. CAUTION BEFORE PROCEEDING: You will be replacing the hal.dll and ntoskrnl.exe files in %windir%\system32. I recommend making backup copies of the hal.dll and ntoskrnl.exe files at %windir%\system32. You don’t have to do this, but I prefer to err on the side of caution. ALSO: The replacement files MUST be of the same service pack level as your current machine. If the SP levels don’t match, your machine is very likely to give you hassles and might not even start. That being said…
  9. Make the VM generic by copying the generic hal.dll and ntoskrnl.exe files from either your Windows setup disk or from the %windir%\system32\servicepackfiles directory. If you are using the service pack files, you can simply copy the files into the VM’s %windir%\system32 folder. If you are using the Windows setup disk, you will need to run the following commands on the server (assuming that your CD drive on the machine is D:\): expand d:\i386\hal.dl_ %windir%\system32\\hal.dll and expand d:\i386\\ntoskrnl.ex_ %windir%\system32\ntoskrnl.exe.
  10. Uninstall VMWare Tools if it has been installed.
  11. Run the Prepvm.vbs script included at the end of this page. The script disables the VMWare devices in the machine so that they are not present when the machine starts up in Virtual Server/PC. It will also shut down the VM for the final conversion process when it’s done running.
  12. At this point, you could make more backup copies of the VMDK files, but, to be honest, the “make the machine generic” steps are fairly quick, and will take much less time to re-do than to copy gigs and gigs of VMDK files as backups.
  13. Launch the VMDK2VHD utility on your conversion tools machine. The interface is very simple, and basically just asks you for the source VMDK file and the destination VHD file that you want to output it to. It also does ask you if you want a fixed or dynamically-expanding VHD file. This is totally up to you. Basically, think of it this way: If your VHD represents an 80 GB hard disk, but you only have 10 GB of data on it, a fixed-size disk will be 80 GB in size, whereas a dynamically-expanding VHD will be 10 GB in size and will grow as the size of the data on your VHD grows.
  14. Let the utility run, and go and grab a coffee/dinner/breakfast/whatever, because this will again take a fair bit of time, depending on the amount of data you’re working with.
  15. When the conversion is done, configure a new VM in Virtual Server/PC that uses the VHD file produced by VMDK2VHD as your virtual hard disk.
  16. Start up the Virtual Server/PC VM, again probably with NIC’s disconnected to avoid IP/Naming conflicts.
  17. Logon to the machine and install all of the hardware that Windows finds.
  18. If everything seems in order, celebrate! Shut down your source physical machine, connect the VM to the network, and away you go!

    Again, this post would not be possible without other smarter people having gone before me. Some resources:

    How to convert VMware virtual disk images to Virtual Server

    Prepvm.vbs script

    1. Dan
      2008-02-12 at 10:09

      I tried the steps above to convert the vmware image to VPC, when l run the converted image under VPC its completely blank (black screen). please advise

    2. justanothersysadmin
      2008-02-14 at 23:21

      Hi Dan,

      I’m not sure exactly what the problem might be without checking over all of the steps, but I would check a few things:

      * Ensure that the hal.dll and ntoskrnl.exe have been replaced with their generic counterparts of a matching service pack.
      * Ensure that the prepvm.vbs script was run on your VMWare machine prior to the conversion.
      * Ensure that your VMWare machine was using IDE disks, not SCSI disks. I apologize if this was not included in the post, but I believe there may be problems with the conversion process if you are using SCSI virtual hard disks.

      Please let me know how you make out.

      Just Another Sysadmin

    3. Steve
      2008-03-23 at 07:38

      After a couple of false starts (trying to install VMWare onto a VERY old box, giving up, and trying to install it onto a Vista x64 machine, giving up), I have to say that this process worked a treat for me.

      One thing to be aware of is that the newly virtualised machine will most likely need re-activating due to the change in hardware, but that shouldn’t be a problem to legitimately licensed users.

      Thanks!

      Steve.

    4. justanothersysadmin
      2008-03-23 at 09:10

      Hi Steve,

      I’m glad I could help! I have not personally run in to a reactivation requirement myself, but I guess that’s not out of the question. Good luck with the new VM!

    5. Patrick
      2008-03-30 at 08:04

      Hi,

      I’m trying your guidelines to convert my old W2K3 server in a virtual machine.
      The problem right now is that I can’t unselect the ‘Split in 2Gb’ option and the VMDK becomes a bunch of 2 Gig files. Do you have any suggestion in how to solve this issue?
      Thanks in advance,

      Patrick
      (the Netherlands)

    6. justanothersysadmin
      2008-03-30 at 10:28

      Hi Patrick,

      I can’t recall a case off the top of my head where you were not allowed to get rid of the “Split in 2GB” option in the VMWare conversion process. I will see what I can find out and let you know if anything pops up.

      Just Another Sysadmin

    7. Patrick
      2008-03-30 at 10:34

      Hi again,

      Thanks for your reaction. In the meanwhile I installed VMWare Converter on my Win2008 server and started the process without the grayed-out checkbox. So I left the checkbox Unselected and started the conversion. And now, during the wait, I’ll watch a rerun of StarGate The Movie.

      Thanks again for your mail and your conversion guideline.

      Patrick

    8. justanothersysadmin
      2008-03-30 at 13:23

      You’re very welcome, Patrick.

      Let me know how the conversion works out for you.

      Just Another Sysadmin

    9. Tom
      2008-05-29 at 02:07

      This works like a charm, however none of the newly created machines will shutdown ! (I get the old ‘it’s now save to turn off your computer’ on Windows 2000 Pro, 2000 Server, XP Pro and 2003 Server). Any insights ?

    10. justanothersysadmin
      2008-05-31 at 16:19

      Hi Tom,

      Glad to hear things are working out for you. There are a few things you can try (ideas from http://www.theeldergeek.com/shutdown_issues_in_xp.htm).

      The one that was relevant for one of my systems that had gone through this P2V process was to check the REG_SZ value
      PowerDownAfterShutdown at HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon. On my system, for some reason, this had switched to ‘0’. Flip it to ‘1’ and your problem should hopefully go away.

      Please let me know if you have success with that.

      Just Another Sysadmin

    11. Tom
      2008-06-09 at 00:37

      Thanks justanothersysadmin !

      That certainly did the trick for me 🙂

      Grtz. Tom

    12. justanothersysadmin
      2008-06-12 at 12:40

      Hey Tom,

      Glad to hear it!

      JaS

    13. Jeremy
      2008-06-30 at 01:49

      Hi,

      I tried this method to convert virtual disk, but when I start the new virtual machine, there ‘s a problem with the network card. I can’t install it, driver installation said “data invalid”.

      Are you an idea to resolve my problem ?

      thanks to your help :).

    14. justanothersysadmin
      2008-06-30 at 20:11

      Hi Jeremy,

      I have not yet come across that personally, but hopefully I can be of some assistance. I just want to be sure of a few things:

      What OS is your guest VM? (Server 2000/2003, XP, NT, etc.)
      For the network card you are referring to, are talking about the virtual network adapter or the ghost device for the adapter that was installed in the physical machine you have converted (I would assume the former, but I figured I would check just in case).
      Have VM Additions been installed in the new guest VM? If so, which version?

      JaS

    15. Jeremy
      2008-07-01 at 23:50

      thanks to your answer,

      It was the virtual network adpater with windows XP Professional SP2. I replace the driver.cab file in “%windir%\driver cache” by the original in windows xp SP2 CD-ROM and now that’s work 🙂 .

    16. justanothersysadmin
      2008-07-03 at 13:40

      Nice work,

      Thanks for the update, and good job on the solution there!

      JaS

    17. olof
      2008-07-30 at 23:30

      works like a charm, thanks allot!

    18. test1
      2008-08-12 at 07:44

      This worked great. But I only tested a single drive letter server. How would the instructions change if the server had a c:\ and a e:\ for example? Would it create 2 vhd ?

    19. justanothersysadmin
      2008-08-12 at 20:04

      When you run through this process with a source machine that has multiple partitions or drives, VMWare Converter recognizes that and presents you with an option to create a separate disk for each volume. You might have to upgrade your current version of VMWare Converter in order to ensure that little checkbox is available to you. There’s a nice post about that here: http://virtualfuture.info/2008/07/convert-disks-vmware-converter/.

      I can’t recall off the bat, but I believe VMWare converter will respect the difference between physical disks and logical partitions. In other words, if you have a single physical disk on the source machine, but that disk contains multiple partitions (C, D, etc.), VMWare Converter will by default give you a single VMDK file that contains multiple partitions. If you had, for instance, a server that contains multiple physical disks, then VMWare Converter would by default produce a matching number of VMDK files.

      Does that answer your question? Let me know if you have any other follow-up questions there.

      JaS

    20. Mes
      2008-08-13 at 01:18

      I have once seen a simple utility that allowed you to load the specs from your existing small servers that you are trying to consolidate into fewer larger servers with virtualization. This tool allowed you to size your new servers and gave you a way to account for all of the Physical server requirements in the virtualized environment, and even gave out a report. This was such a great sizing tool. Unfortunately I have lost it and now I do not seem to be able to find it again.

      Please help,
      Mes

    21. justanothersysadmin
      2008-08-13 at 22:01

      Hi Mes,

      I’m sorry, but I’m not familiar with something along those lines that fit with the classification of “simple utility”. I’m guessing it’s a pretty safe bet that the big consolidation/P2V boys like Platespin probably have something like this, but I can’t recall personally running across a tool like that.

      If I do track it down, I will be sure to let you know. Other than that, can anyone point Mes in the right direction?

      Cheers,

      JaS

    22. dlove
      2008-09-04 at 09:49

      Hi JaS-
      Do you know of a solution if your VMWare VMDK is SCSI? I of course, am using a SCSI virtual drive per VMWare’s recommendations, and now I get a BSOD on the converted VHD. I did prep the VMDK appropriately. Obviously I’m not doing the whole p2v thing, just tryng to get a VMWare virtual machine I created, converted to Virtual Server. The server is a w2k3 r2 os with sharepoint installed and a hugely painful specialization perfomed on it to actually make it work as a collaboraion solution with outside (non-domain users) and I don’t think I can go through it again.
      TIA,
      dlove

    23. 2008-09-04 at 18:23

      Hi dlove,

      I can’t think of anything off the top of my head. I believe a previous comment had similar issues with SCSI VMDKs, but I don’t recall a solution. Now, I’ve had to convert before between VS IDE and SCSI disks, and the process was actually fairly painless. I’m wondering if a similar option exists in VMWare.

      In Virtual Server, the process consisted basically of:

      1. In the Virtual Machine Configuration windows, click on SCSI adapters
      2. Click on Add SCSI Adapter (ID 7, or whatever you prefer your controller to be) and then OK
      3. Leave the boot disk as IDE disk
      4. Start the Virtual Machine
      5. You should see the following when the adapter is identified

      • Found new hardware: Adaptec AIC-7870 PCI SCSI Adapter
      • You will need a CD or ISO to load the aic78xx.sys driver
      • The driver will install and the Virtual Machine will now be able to boot using SCSI, but this is a slow SCSI driver.

      6. In the Virtual Machine, open Device Manager
      7. Expand the SCSI and RAID controllers section
      8. Right-click on the Adaptec driver and choose Update Driver
      9. Choose the Install from a list or specific location and Have Disk options
      10. Browse to “C:\Program Files\Virtual Machine Additions” and click OK
      11. The Microsoft Virtual Machine PCI SCSI Controller driver will now install

      • Now the fast SCSI driver is loaded

      12. Shutdown the Virtual Machine
      13. Back in the Virtual Server Virtual Machine configuration, click on Hard disks in the Configuration section
      14. Change the boot Virtual Hard Disk attachment to a SCSI ID
      15. Click OK
      16. Start the Virtual machine

      Check out this blog for more info on that route.

      I haven’t played extensively with VMWare’s server products, but as far as I’m aware they have some pretty decent virtual disk-management tools. Is it maybe an option to convert the machine’s VMDKs into IDE drives before the conversion to Virtual Server?

      JaS

    24. Shane
      2008-11-18 at 19:59
    25. Jason
      2009-06-05 at 13:13

      I ran into this while looking for a way to P2V my Vista laptop onto my Hyper V Server 2008 (more for ****s and giggles than anything). I tried to skip the VMWare Server step of restoring a vanilla version of HAL.dll and NTOSKRNL.exe since VMWare server won’t run on a computer running Hyper V. That failed though, I was able to boot into the image on Hyper V, and install new drivers, and even the Integration Services, but subsequent boots failed.

      So I tried the next best thing, install VMWare Workstation on the Laptop and boot the image I had just taken of it…. as you can imagine that was an exercise in futility on 4 year old hardware… it barely runs the physical version, no way it will run that PLUS the virtual version of itself. So I checked around Google to see if there was a way to mount a VMDK file. Sure enough, inside the latest VMWare Workstation, you can map and then mount a VMDK file. So I did that and just replaced both files.

      After that I converted to VHD and set up in Hyper V, and now am happily running my virtual Laptop on my server in my basement. Thanks for the great info you have shared here!

    26. justanothersysadmin
      2009-06-06 at 20:35

      Hi Jason,

      Thanks for the info on your P2V experience; it’s good to see the process, while tried out originally in Virtual Server, still works for Hyper-V. I believe that in Virtual Server there was a command-line utility for mounting VHD files; I’m wondering if a similar utility exists in Hyper-V. At any rate, I was thinking that another way around the issue might have been to mount the VHD and replace the files with copies from an already-running VM of similar build (same OS and service pack level, same CPU’s and such) into the mounted VHD file.

      I’m not sure if that would work, but I’m thinking that if a generic HAL and kernel would work, then copies from a similar machine (same OS and virtual hardware) should do the trick as well and might even be better.

      Anyhow, thanks again for the info; I’m sure some poor, frustrated soul will benefit from you posting your experience!

    27. Jason
      2009-06-07 at 14:28

      Very interesting, and indeed it appears that Windows 7 era has the ability to mount VHD’s within disk management. This link has some details… https://thelazyadmin.com/blogs/thelazyadmin/archive/2009/01/15/mount-a-vhd-within-windows-7-server-2008-r2.aspx

      Win 7 and Server 2008 R2 (which is Server 7) can do it natively. Nice, I just wish that MS had a clean tool for the actual P2V conversion. SCVMM 08 requires that both the host of the virtual machine as well as the physical host be on trusted domains. If they’re not, then you’re out of luck… you can use SCVMM to manage a perimeter Hyper-V host, but you can’t do a P2V conversion unless everything is on trusted domains… UGH.

    28. justanothersysadmin
      2009-06-07 at 21:51

      Yea, I get the whole thing about leveraging AD where you can, but there’s a point at which you’re just intentionally forcing your own product to be tied into other components.

      The AD requirements you described remind me again of the VSMT outlined above in the original post, where you actually are required to have a box running Server Enterprise in order to use ADS and do a P2V…are you kidding me?! Compare this to VMWare Converter, which can be installed on a simple workstation with no real requirements over-and-above sufficient disk space and network connectivity. I’m sure VMWare could have forced you to use ESX server in some capacity in order to do a P2V into VMWare, but isn’t just a little silly to throw up barriers to entry when people actually WANT to convert physical boxes onto YOUR virtualization platform?!

      Anyway, $rant.end(). Thanks for the VHD mounting tips.

    29. Lee Mitchell
      2009-09-04 at 06:27

      Hi,

      Been digging around the net for a while on how to convert an xp station p2v vhd but still having no joy implementing. Problem I always get is after I’ve converted the vmdk to vhd and create a vm, when I start it I always get a black screen with ‘A disk read error occurred. Press ctrl+alt+del to restart’. I haven’t been able to find anyone else with this problem. Followed your steps to a t but get the same thing. If it’s of any relevance, after running the prepvm.vbs it says machine prep’d and will shut down, but it doesn’t shut down, I have to do it manually. Can anyone help please?!

    30. James Feldman
      2009-09-06 at 22:08

      Lee, it sounds like you haven’t converted your VMware SCSI disks to IDE before doing the conversion.

    31. Lee Mitchell
      2009-09-07 at 00:49

      Just incase anyone else has been having this problem, found the solution at http://www.xtralogic.com/testdisk_rebuild_bootsector.shtml

    32. justanothersysadmin
      2009-09-13 at 07:34

      @Lee:

      Thanks for the info.

      JaS

    33. Willie
      2010-12-17 at 17:38

      Thanks! This 2008 post is still relevant today!
      It was considerably easier though — I could just create the .vmdk and then convert it to the .vhd and load it up in Hyper-V… no extra steps needed.
      Of course, I told it not to install the VMware tools upon creating the .vmdk since I was not going to use VMware in this case.

    1. 2013-07-15 at 14:29

    Leave a reply to Shane Cancel reply