1

I have been trying to convert a Windows 7 partition to a VDI so I could boot it in Virtualbox and remove the partition.

I'd previously been able to boot the raw partition within the host (Mac OS X).

I used dd to create an image of the partition, not the entire disk. Stupid

I then deleted the partition. Stupider.

Now, when I create a Virtualbox machine I can attach the drive but it will not boot.

I've tried the standard Windows boot recovery options but they have not been successful. In diskpart I can't even select the partition, and it won't mount in a Linux live OS.

I think (know) it is because I only pulled an image of the partition and not the drive, so there is no partition table or boot record. I no longer have access to the raw partition or drive.

So my question is - given a raw image of a partition, what do I need to do to create a bootable drive in Virtualbox?

2 Answers 2

2

I managed to fix this by creating a new drive image with one partition, then restoring my partition backup into that, then using the new drive image in my virtual machine. It wasn't easy though, so here are the specific steps - though I am not sure all steps were necessary -

  1. Created a new, empty 130GB image using dd if=/dev/zero of=disk1.img bs=1 count=1 seek=130g (It had to be slightly bigger than the original image of 126GB.)
  2. Used sudo fdisk -e disk1.img to create a partition table and MBR on that image, with one partition.
  3. Mounted the new image directly in Mac OS X Finder, then used Mac OS X Disk Utility to restore the backed up partition image onto the new partition within the drive image.
  4. Converted the image to a VDI using VBoxManage convertfromraw disk1.img Windows.vdi
  5. At this point, I thought it would work so attached it to a Virtual machine as a boot drive, but unfortunately this created 'A disk read error occurred' messages.
  6. Booted that virtual machine to Windows 7 recovery, then ran bootsect.exe /FixBoot and bootsect.exe /FixMbr
  7. Still has 'A disk read error occurred' messages, so ...
  8. Attached the drive image within an existing Virtual machine, but as a secondary drive.
  9. Ran testdisk on the drive within the guest (so it treated it as a normal drive, not an image).
  10. Checked and updated the partition structure, and boot sectors until testdisk stopped complaining.
  11. Rebooted the virtual machine with the new image as the primary drive and ... BINGO!

Credit goes to these pages:

0

Try and boot the VM off a linux live cd image. From there you can use gparted or testdisk to repair the disk structure.

Thought, often in these situations it is better to simply install windows as a vm and move the files from the image across to the newly installed partitions/disk image.

1
  • Thanks - testdisk was the final piece of the puzzle actually, but it was quite complicated so will reply with full instructions!
    – hepto
    Commented Mar 21, 2014 at 13:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .