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.
Tags: disk2vhd, Hyper-v, virtualization, Windows