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

5

4

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.

Radek

Posted 2013-09-27T00:18:35.363

Reputation: 2 914

OK. Let's try ... ;-) – Radek – 2013-09-29T01:54:49.373

@Radek what have you tried opening the vhd with? – Cole Busby – 2013-09-29T04:15:22.477

@ColeBusby: I didn't try to open it. I used it as hdd for Virtual Box virtual machine. – Radek – 2013-09-29T04:18:35.753

@Radek Did you get an error at all? – Cole Busby – 2013-09-29T04:20:05.877

No error. Only black screen. – Radek – 2013-09-29T04:20:32.353

@Radek did you try mounting the physical drive to a virtual machine? It's not efficient but if the physical drive can boot into a vm I can help you with a solution. – Cole Busby – 2013-09-29T04:22:02.277

let us continue this discussion in chat

– Radek – 2013-09-29T04:23:02.600

1

I can't verify if this will work, but look into http://www.vmware.com/products/converter/. If its possible to P2V and capture the image w/o a vmware cluster, you will be able to use it with http://www.vmware.com/products/player/. Free solution if you can get the converter to work.

Link for free VMware Player-https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/6_0

– Spencer5051 – 2013-09-29T05:09:58.180

@Spencer5051: Doesn't the VMWare convertor require the machine to be running? Is the converter for free? – Radek – 2013-09-29T05:26:21.367

@Radek The converter is free. But the enhanced version "vSphere" costs. – Christian – 2013-09-29T09:38:28.813

@Chris: good to know. So can I use converter only if the system is up and running? – Radek – 2013-09-29T09:42:40.073

@Radek I don't know that. That's why I haven't recommended it. But give it a try. If you can clon it from a harddrive than you should be able to boot it up. – Christian – 2013-09-29T09:53:30.677

With Converter Standalone 5.1, you can only perform hot cloning. Hot cloning, also called live cloning or online cloning, requires converting the source machine while it is running its operating system. https://www.vmware.com/pdf/convsa_51_guide.pdf

– Radek – 2013-09-29T10:02:33.657

1Did you try disk2vhd while ticking everything, to try and create an exact copy of the disk? – harrymc – 2013-09-29T11:25:03.400

@harrymc: the hdd in question got two partitions H and I and is connected to Windows7 comp via usb. I tried to use Disk2vhd while ticking both only boot partition H and then both H and I. Does it answer your question? – Radek – 2013-09-29T11:50:07.967

No, because to make the disk image bootable you must exactly duplicate partition numbers and also include in the image the boot sector and the MBR/GPT, which is the basis for my answer below. – harrymc – 2013-09-29T12:50:14.523

But the H & I partitions create one physical disk that was bootable before so why it didn't work? Why cannot I boot from it like from usb hdd? I'll try your solution tomorrow... – Radek – 2013-09-29T13:03:25.217

There is more on the hard disk than just these two partitions. Without these other partitions and data, the disk is not bootable. – harrymc – 2013-09-29T13:29:00.910

@harrymc: so do I do dd on the partition or whole hdd? – Radek – 2013-09-29T13:50:59.133

DD the whole disk. – harrymc – 2013-09-29T14:25:06.653

Answers

6

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.

Michał Sacharewicz

Posted 2013-09-27T00:18:35.363

Reputation: 1 944

1

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

harrymc

Posted 2013-09-27T00:18:35.363

Reputation: 306 093

You can also create a .vdi directly by using dd if=\\?\Device\Harddisk6\DR12 bs=1M --progress | VBoxManage.exe convertfromraw stdin output.vdi 120034123776 --format VDI – Gianluca P. – 2015-07-26T08:45:56.593

Even if the recovered image works, there is no guarantee that Windows in the VM will stay activated. You should (if possible) try to find out the MAC address of the old computer to set in the VM. – harrymc – 2013-09-29T12:55:07.277

1How is MAC address related to the fact that it won't boot? I can boot the old computer from usb. Ubuntu from usb flash works ok but this hdd won't boot from usb. I am not able to use this hdd internally anymore. – Radek – 2013-09-29T13:05:08.337

Can your old notebook boot from this HDD? – MariusMatutiae – 2013-09-29T13:14:28.877

@Radek: What I'm saying is that if you do manage to construct and boot the VM successfully, XP might still decide that reactivation is required because the emulated hardware is too different from the original. The biggest factors in activation are the network card (MAC) and the motherboard, so you should try to keep them both (or at least one of them, and the easiest is the MAC). The above procedure will at least keep the same disk serial number. – harrymc – 2013-09-29T13:31:49.770

@harrymc: what kind of activation? I can get the mac when I boot up ubuntu. – Radek – 2013-09-29T13:46:09.093

@MariusMatutiae: No I am not able to boot from this hdd when connected via usb. I tried two computers ( desktop and the original notebook ) – Radek – 2013-09-29T13:47:24.787

@Radek: Windows activation - without it Windows comes up as a trial version and will expire after 30 days. One should be aware of it while constructing the VM. – harrymc – 2013-09-29T14:26:54.617

Also: Is it possible to return the old disk to the notebook and will it boot into Windows? – harrymc – 2013-09-29T16:38:12.183

@Radek Windows activation requires a phone call, you can't get around re-activating windows, microsoft still supports activating it though and provides you with step by step robots to help. You will definitely need to activate because it will notice a radical change in hardware and there is no stopping this that I know of. – Cole Busby – 2013-09-29T18:04:41.713

@ColeBusby: Microsoft activation will forgive some hardware changes, as long as essential hardware is the same, which is why I counseled keeping the MAC address. And which is also why I asked about reboot in the old configuration, because then VMware vCenter Converter can capture the motherboard and MAC address. – harrymc – 2013-09-29T18:39:06.200

@harrymc: I can connect the hdd to old notebook only via usb. – Radek – 2013-09-29T22:49:10.607

@harrymc I'm speaking from experience when I say that just because it might capture the Motherboard you shouldn't count on it. I was stuck searching for a valid XP key for a few hours as it had detected that I jumped to a VM and it wasn't sitting in it's same box. – Cole Busby – 2013-10-01T17:40:59.783

@ColeBusby: I'm also speaking from experience as regarding VMware vCenter Converter. – harrymc – 2013-10-01T17:53:23.943

@harrymc Just re-read your comment and the first time I thought you meant running the system in a VM with "Last Known Good Configuration" not inside it's old hardware. – Cole Busby – 2013-10-01T18:03:35.180

1

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.

MariusMatutiae

Posted 2013-09-27T00:18:35.363

Reputation: 41 321

I got the message about going slowly. Merci beaucoup. Just to note that all and any manipulation on the physical disk can equally be done on the virtual one from the VM (and much more safely if the physical disk is old). – harrymc – 2013-09-29T14:30:58.933