How to create vdi from existing (off line) partition?
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:
- Create your VM, connect the virtual drive.
- 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.
- Launch Recovery Console
- Use the fixmbr tool to recover MBR
- 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
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.
Solution 3
Here is a procedure based on the article Linux P2V With DD and VHDTool :
Download and install the Windows version of DD and VHD tool.
Use DD with the
--list
parameter to find the name of the disk in questionCreate a raw image of the disk via a command such as:
dd if=\\?\Device\Harddisk1\DR2 of=C:\Hanna.img bs=1M --progress
Use VHD tool to converts the raw disk image file to a fixed-format VHD:
VHDTool /convert c:\Hanna.img
Rename the converted image file from .img to .vhd
Define the VM using the .vhd file
Related videos on Youtube
Radek
Updated on September 18, 2022Comments
-
Radek over 1 year
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.
Update1
I tried to use Disk2vhd and selected both partitions (H & I) and again played with the settings like
Enable IO APIC
andEnable PAE/NX
but the virtual machine didn't boot up.-
Radek over 10 yearsOK. Let's try ... ;-)
-
Cole Busby over 10 years@Radek what have you tried opening the vhd with?
-
Radek over 10 years@ColeBusby: I didn't try to open it. I used it as hdd for Virtual Box virtual machine.
-
Cole Busby over 10 years@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.
-
Radek over 10 years
-
Spencer5051 over 10 yearsI can't verify if this will work, but look into 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 vmware.com/products/player. Free solution if you can get the converter to work. Link for free VMware Player-my.vmware.com/web/vmware/free#desktop_end_user_computing/…
-
Radek over 10 years@Spencer5051: Doesn't the VMWare convertor require the machine to be running? Is the converter for free?
-
Christian over 10 years@Radek The converter is free. But the enhanced version "vSphere" costs.
-
Radek over 10 years@Chris: good to know. So can I use converter only if the system is up and running?
-
Christian over 10 years@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.
-
Radek over 10 yearsWith 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. vmware.com/pdf/convsa_51_guide.pdf
-
harrymc over 10 yearsDid you try disk2vhd while ticking everything, to try and create an exact copy of the disk?
-
Radek over 10 years@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?
-
harrymc over 10 yearsNo, 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.
-
Radek over 10 yearsBut 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...
-
harrymc over 10 yearsThere is more on the hard disk than just these two partitions. Without these other partitions and data, the disk is not bootable.
-
Radek over 10 years@harrymc: so do I do dd on the partition or whole hdd?
-
harrymc over 10 yearsDD the whole disk.
-
harrymc over 10 yearsEven 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.
-
Radek over 10 yearsHow 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.
-
MariusMatutiae over 10 yearsCan your old notebook boot from this HDD?
-
harrymc over 10 years@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.
-
Radek over 10 years@harrymc: what kind of activation? I can get the mac when I boot up ubuntu.
-
Radek over 10 years@MariusMatutiae: No I am not able to boot from this hdd when connected via usb. I tried two computers ( desktop and the original notebook )
-
harrymc over 10 yearsI 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 over 10 yearsAlso: Is it possible to return the old disk to the notebook and will it boot into Windows?
-
Cole Busby over 10 years@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.
-
harrymc over 10 years@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.
-
Radek over 10 years@harrymc: I can connect the hdd to old notebook only via usb.
-
Cole Busby over 10 years@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.
-
harrymc over 10 years@ColeBusby: I'm also speaking from experience as regarding VMware vCenter Converter.
-
Cole Busby over 10 years@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.
-
Gianluca P. almost 9 yearsYou 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