Dec 04 2012

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

Published by at 11:39 am under Virtualization,Windows

Converting a physical Windows 2003 Server to a Hyper-v virtual machine with disk2vhd tool may throw the following 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, and they all failed.
The Master Boot Record needs to be 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.
Then run testdisk_win.exe from the command line.
Choose if you’d like to get logs enable

 [ Create ]
 [ Append ]
>[ No Log ]

 
Select the disk matching the virtual disk, the 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 default 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'.

 
And MBR Code in the list of actions

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 to override the first sector

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

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

 
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.

>[OK]

 
You may also need to rebuild the NTFS boot sector in the same way as described above. Instructions can be found at xtralogic.
Unfortunately the link is broken, so here is a quick set of 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 before booting the virtual machine.


8 responses so far

8 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!

    http://web.archive.org/web/20140831151616/http://www.xtralogic.com/testdisk_rebuild_bootsector.shtml

  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

  8. Alexon 16 Jun 2021 at 11:36 am

    Thanks a lot for your help. I tried many things to start virtual machine but nothing worked.

Trackback URI | Comments RSS

Leave a Reply