Dec 04 2012

Hyper-v “error loading operating system” after running disk2vhd

Published by at 11:39 am under Virtualization,Windows

Converting a Windows 2003 Server to a Hyper-v virtual machine with disk2vhd tool may throw a generic error on a black screen on boot:

Error loading operating system

Needless to say Windows is not even starting.
I tried to repair Windows with a 2003 server image, fixmbr, fixboot, nothing works.
The MBR needs to get fixed. The only tool around that does seem to work is TestDisk.
Now, download TestDisk on above link and unzip on your Hyper-v host.
Attach the virtual disk under Disk Management in Computer Manager.
Run testdisk_win.exe
Select if you’d like to get logs enable

 [ Create ]
 [ Append ]
>[ No Log ]

Select the disk matching your virtual disk – Description should be Msft Virtual Disk

Select a media (use Arrow keys, then press Enter):
 Disk /dev/sda - 320GB / 298 GiB - ST320LT007-9ZV142
>Disk /dev/sdb - 73GB / 68 GiB - Msft Virtual Disk
 Drive E: - 623 MB / 594 MiB

>[PROCEED ]  [  QUIT  ]

Select Intel/PC partition type

Disk /dev/sdb - 73GB / 68 GiB - Msft Virtual Disk

Please select the partition table type, press Enter when done.
>[Intel  ] Intel/PC partition
 [EFI GPT] EFI GPT partition map (Mac i386, some x86_64...)
 [Humax  ] Humax partition table
 [ Mac   ] Apple partition map
 [None   ] Non partitionned media
 [Sun    ] Sun Solaris partition
 [XBox   ] XBox partition
 [Return ] Return the disk selection

Hint: Intel partition table type has been detected.
Note: Do NOT select 'None' for media with only a single partition. It's very
rare for a drive to be 'Non-partitionned'.

Select MBR Code

Disk /dev/sdb - 73GB / 68 GiB - Msft Virtual Disk
     CHS 8920 255 62 - sector size=512

 [ Analyse  ] Analyse current partition structure and search for the lost partitions
 [ Advanced ] Filesystem Utils
 [ Geometry ] Change disk geometry
 [ Options  ] Modify options
>[MBR Code  ] Write TestDisk MBR code to first sector
 [ Delete   ] Delete all data in the partition table
 [ Quit     ] Return to disk selection

Proceed with y

Disk /dev/sdb - 73 GB / 68 GiB - CHS 8920 255 63

Write a new copy of MBR code to first sector? (Y/N)

And confirm

Write a new copy of MBR code, confirm ? (Y/N)

Then quit.

A new copy of MBR code has been written.
You have to reboot for the change to take effect.


You may also need to rebuild the NTFS boot sector in the same way as described above. Instructions can be found at xtralogic.
Since the link is broken, here are quick instructions:

>[ No Log   ]
>Disk /dev/sdb - 73GB / 68 GiB - Msft Virtual Disk
>[Intel     ] Intel/PC partition
>[ Advanced ] Filesystem Utils
>1 * HPFS - NTFS [...]
>[Rebuild BS]
>[ Write    ]
>[ Confirm  ]
>[ Quit     ]

The virtual machine should boot ok from now on. Don’t forget to detach the Vdisk in the first place.

7 responses so far

7 Responses to “Hyper-v “error loading operating system” after running disk2vhd”

  1. […] Hyper-v “error loading operating system” after running disk2vhd […]

  2. Davidon 02 Dec 2014 at 2:49 am

    Saved my bacon… many thanks!

  3. Martinon 04 Mar 2015 at 1:18 pm

    Thanks for this!

    Although this is an old post, it really helped me out! 🙂

    Had an old Windows server 2003, that just wouldn’t boot up. This did the trick!

  4. Daveon 05 Apr 2015 at 3:40 am

    I found these instructions, which seem to be helpful–after fixing the MBR, I no longer get the “error loading operating system”, I just get a flashing cursor. Presumably I still need to fix the NTFS boot sector, but unfortunately, the link to Xtralogic is broken. Does anyone have the steps required to fix the NTFS boot sector using Testdisk?

  5. Daveon 05 Apr 2015 at 3:52 am

    Wayback machine to the rescue!

  6. Akberon 22 Sep 2015 at 3:02 pm

    I Have HP Server and use the UrBackup, I not use the compress vhd, instead I used uncompress, now I copied the files to windows 2012 where I installed the hyper-V. Though i follow the guideline but not work with me. Any idea how to do this.

    I also try restoring the HP Backup (urBackup) from one hardware to another, though both hardware are same, except the RAID CARD is different in one hardware than the other.

    Anybody done this also please update me. I wanted to restore and wanted to fully test if this work.

  7. Jiyadon 09 Oct 2019 at 1:46 pm

    Thank you soooooooooo much for this. This helped me when i had the error first followed the procedure and then the comment from dave

Trackback URI | Comments RSS

Leave a Reply