How to create vdi from existing (off line) partition?

I have an old hdd from my notebook that carries WindowsXP. I would like to run this WindowsXP installation under Virtual box under Windows7. I am able to connect the disk to my Windows7 via usb.

So far I didn't find any free working solution to that. Would you have an idea?

Regarding

  • disk manager from Windows7 the system partition ( drive H from below picture) is Healty - active and primary)
  • gparted from ubuntu the partition got boot flag but I wasn't able to boot from this usb hdd

What I found/tried so far that didn't work for me

  • VirtualBox from an existing partition (VMWare convertor requires the machine must be running at the time of conversion - https://www.vmware.com/pdf/convsa_51_guide.pdf)
  • Create Virtualbox image of a physical partition (linux solution I got only Windows7 available and the official Virtual Box page have step one: "Run the MergeIDE utility as mentioned above on existing windows machine. " I cannot run the XP any more or can I?)
  • I tried to use Disk2vhd and the vhd file was created but when used as virtual hdd in Virtual box it won't boot. I tried to play with different settings of this virtual machine but it didn't help. I tried two versions of Disk2vhd and Virtual Box. Once yesterday and once 3 years ago :-)

The physical drive got two partitions that are mapped as drives H and I. The H drive is the system bootable partition. And that is what I ticked.

How I used Dist2vhd

Update1

I tried to use Disk2vhd and selected both partitions (H & I) and again played with the settings like Enable IO APIC and Enable PAE/NX but the virtual machine didn't boot up.


Solution 1:

Your problem is that you are converting partition(s), not the whole hard drive.

You cannot boot your OS because in the newly created virtual disk you have no MBR record - to simplify, original MBR is part of the disk, not part of the partition (it is outside of the scope of the partitions).

To make your OS boot properly, create a virtual HDD image of your partition using any working method from the list you've tried, and then restore the MBR:

  1. Create your VM, connect the virtual drive.
  2. Boot the VM from Windows XP CD. Note, that you need to boot the VM, not the physical computer as @MariusMatutiae suggested in his post.
  3. Launch Recovery Console
  4. Use the fixmbr tool to recover MBR
  5. You may also use fixboot tool to recover partition boot sector, though it shouldn't need fixing.

Once done, your virtualised system should be bootable again.

Note though, that Windows XP might not launch due to change of hardware.

Solution 2:

Here is a procedure based on the article Linux P2V With DD and VHDTool :

  1. Download and install the Windows version of DD and VHD tool.

  2. Use DD with the --list parameter to find the name of the disk in question

  3. Create a raw image of the disk via a command such as:
    dd if=\\?\Device\Harddisk1\DR2 of=C:\Hanna.img bs=1M --progress

  4. Use VHD tool to converts the raw disk image file to a fixed-format VHD:
    VHDTool /convert c:\Hanna.img

  5. Rename the converted image file from .img to .vhd

  6. Define the VM using the .vhd file

Solution 3:

I think your first problem, even before the one solved by harrymc, is a corrupted boot sector in your disk. Easiest solution is: get yourself a live Ubuntu USB stick, and use boot-repair to restore your Master Boot Record (MBR). Though using a Ubuntu live stick is a bit of a nuisance at first, it helps you solve serious issues in the future. So go to www.ubuntu.com, download a copy of the OS, and install it on USB stick.

Boot your pc from the stick, and now install boot-repair. This very clear Web page has all the info on how to install it on the stick, and how to run it. It is trivial.

EDIT: just be careful to repair the MBR of the HDD, not of the pc disk, that's all.

This will fix your MBR. At this point the HDD will become once more correctly bootable, and harrymc's instructions will apply.

However, since you do have Ubuntu, you may as well give it try and follow harry's solution with proper Linux utilities. There are guides everywhere, but should you wish any guidance just ask (I bet there are thousands of people in this forum who know hot to do that, LOL).

@harry: about the registration, as the French say, glissez, glissez, n'appuyez pas.