Fixing disk geometry for "error loading operating system" (Windows XP from VMWare)

Discussions about using Windows guests in VirtualBox.
Post Reply
GernotH
Posts: 2
Joined: 31. Mar 2020, 02:49

Fixing disk geometry for "error loading operating system" (Windows XP from VMWare)

Post by GernotH »

I hope this post can help others importing working VMs (not only Windows XP) from VMWare Workstation/Player to VirtualBox (converted with ovftool), suffering from "error loading operating system", where the original VMWare VMs work fine in VMWare Workstation/Player.

Symptom:
VMWare Workstation/Player Windows XP virtual machine converted to OVF and imported into VirtualBox does not boot, displaying "error loading operating system" on black screen.

Summary:
VirtualBox does not correctly set the disk geometry in certain imported VDI files.

A simple fix to the VirtualBox VDI disk geometry solves the problem, using CHS data from original VMDK file:

Code: Select all

vbox-img geometry --filename <diskimage>.vdi --format VDI --cylinders <C> --heads <H> --sectors <S>
Checks:
  • No obvious issues with disk controller setting or MBR.
  • Several threads (listed at end) referenced.
    Many dealt with issues related to P2V process.
    Common issues were Windows XP drivers and MBR.
    These are not applicable in this case.
  • Several unsolved threads seem to be like this case.
Solution:
  • One or two of the referenced threads mentioned disk geometry issues in converted VirtualBox virtual machines.
    VirtualBox conversion of VDMK disk during OVF import does not correctly set the CHS (cylinder/head/sector) values in the VDI file for the imported VMDK disk under certain conditions. I think from reading the various threads that the developers have stated that only standard geometry of 255 heads and 63 sectors is expected, and that the VMDK CHS information is ignored. When this expectation is not met, the VDI file will have the wrong information.
  • Check the original VMDK and converted VDI disk geometry in VBox.log.
  • Manually set correct geometry using vbox-img command.
Details:
Two original VMWare VMs, both clones of the same Windows XP Home VM, using VMWare, probably VMWare Workstation 9.x on Debian GNU/linux 32-bit or 64-bit, sometime around 2010-2014.

Current hardware (Intel Core2Duo motherboard) too old for latest VMWare Workstation, while Debian GNU/linux kernel too new for old VMWare workstation 9 or 10 to build necessary modules.

So, I converted the VMWare virtual machines (both with VMWare workstation 9 hardware compatibility) to OVF and attempted to import into VirtualBox 6.1.4, during which the VMDK disk is imported as a VDI file (this is where the problem arises).

One of them worked fine, the other did not, with the error mentioned.

The results was the same whether performing conversion and import on my 64-bit Debian GNU/linux machine or on 64-bit Windows 10.

Despite reading of numerous threads about this error, and trying to fix from the OS level, it turned out that the problem was incompatible disk geometry in the VMDK file, and VirtualBox import does not correctly use the data in the VDI disk file.

So, the solution I found was to change the geometry of the VDI disk file.

After importing and attempting to boot the imported VMs in VirtualBox, I could see In the VBox.log file the original VMWare VMDK file CHS information and the converted result.

First (working) Windows XP Home:
Checking VMDK:
SCSI capacity: 83886080
logical sector size 512
geometry (CHS): 5221/255/63
VBox.log file after importing OVF (which converts VMDK to VDI file):
CHS = 1024/255/63
VMWare was 5221/255/63
vbox-img shows 1024/255/63 in VDI disk

Code: Select all

vbox-img info --filename <diskimage>.vdmk
Header: Geometry PCHS=16383/16/63 LCHS=1024/255/63 cbSector=83886080
VBox.log:
00:00:01.326888 PcBios: SCSI LUN#0 LCHS=1024/255/63
00:00:01.378575 VMMDev: Guest Log: BIOS: SCSI 0-ID#0: LCHS=1024/255/63 0x0000000005000000 sectors
Second (problematic) Windows XP Home:
Checking VMDK:
SCSI capacity: 83886080
logical sector size 512
geometry (CHS): 5874/255/56
VBox.log file after importing OVF (which converts VMDK to VDI file):
CHS = 5220/255/63
VMWare was 5874/255/56
vbox-img shows 0/0/0 in VDI disk

Code: Select all

vbox-img info --filename <diskimage>.vdmk results:
Header: Geometry PCHS=0/16/63 LCHS=0/0/0 cbSector=83886080
VBox.log:
00:00:01.191130 PcBios: SCSI LUN#0 LCHS not provided
00:00:01.230446 VMMDev: Guest Log: BIOS: SCSI 0-ID#0: LCHS=5220/255/63 0x0000000005000000 sectors
Correction
Solution was to use vbox-img, included with VirtualBox, to change the geometry of the VDI disk:

Code: Select all

vbox-img geometry --filename <diskimage>.vdi --format VDI --cylinders 5874 --heads 255 --sectors 56
Now that this matched the geometry of the original VMDK file, Windows booted up perfectly.
VBox.log entries:
00:00:01.140001 PcBios: SCSI LUN#0 LCHS=5874/255/56
00:00:01.187537 VMMDev: Guest Log: BIOS: SCSI 0-ID#0: LCHS=1024/255/56 0x0000000005000000 sectors
I have no explanation why one clone had a geometry which was compatible with Virtualbox expectations, and the other one had a different geometry.

Referenced threads:
  1. Oct 2019: current discussion (latest discussion)
    Error loading operating System error when loading a XP Guest on a W10 Host.
    viewtopic.php?f=6&t=95312&p=461562
  2. July 2018: no solution
    error loading operating system
    viewtopic.php?f=1&t=88923&p=426436
  3. July 2015: no solution
    Yosemite using a bootcamp as a VM
    viewtopic.php?f=8&t=68756&p=327375
  4. Sep 2014: same issue - led me to solution
    Geometry of imported disk images
    viewtopic.php?f=1&t=63454&p=297969
  5. Sep 2014: possibly same issue
    Vmware vmdk to virtualbox
    viewtopic.php?f=7&t=63861&p=300061
  6. Feb 2014: possibly similar issue
    error loading operating system XP
    viewtopic.php?f=8&t=60208&p=280213
  7. Jan 2014: different issue
    Mac OS as host, Ubuntu 12.04 (64b) guest as dual-boot on VB
    viewtopic.php?f=8&t=59529&p=276902
  8. July 2013: possibly different issue
    Discussion: MacOS Bootcamp Partition as a VBox Guest
    viewtopic.php?f=8&t=48704&p=318314
  9. July 2013: different issue
    [Solved] vboxmanage - resized to 50TB instead of 50GB
    viewtopic.php?f=1&t=56261&p=260448
  10. June 2013: same issue no doubt, discussion but no solution
    Windows XP vmdk "ERROR LOADING OPERATING SYSTEM"
    viewtopic.php?f=2&t=56195&p=260535
  11. Jan 2013: likely same issue
    VMWare VM
    viewtopic.php?f=6&t=53533&p=245620
  12. Dec 2012: likely same issue
    vmdk file fails to load in Vbox
    viewtopic.php?f=6&t=52924&p=242640
  13. Aug 2012: different issue
    [FIXED] Existing Windows 7x64 machine do not run
    viewtopic.php?f=36&t=51049&p=233826
  14. April 2011: different issue
    Raw Disk Access for existing Windows XP with host opensuse
    viewtopic.php?f=7&t=41018&p=184445
  15. Feb 2011: could be same issue
    Using VMWare SCSI Image in VB 4.0.2
    viewtopic.php?f=2&t=38776&p=242645
  16. Oct 2010: different issue
    "Error loading operating system" after host reinstall
    viewtopic.php?f=2&t=35416&p=158679
  17. Mar 2010: could be same issue
    Problem using VMWare vmdk images with Virtualbox
    viewtopic.php?f=1&t=28611&p=127642
  18. Feb 2010: possibly related
    Importing Xen virtual appliance?
    viewtopic.php?f=1&t=28354&p=126281
  19. Aug 2009: related issues discussed here
    Howto: Windows XP in both VM and native - DISCUSSION
    viewtopic.php?f=2&t=9700&p=95231
  20. Dec 2008: different issue
    Cant install windows xp on VM
    viewtopic.php?f=7&t=12101&p=49311
  21. Sep 2008: different issue
    how to use vmdk files with XP host
    viewtopic.php?f=6&t=9360&p=36143
  22. Dec 2007: migrating windows XP (different issue)
    How to disable LBA on Raw disk non-LBA partition
    viewtopic.php?f=7&t=3408&p=11947
  23. Nov 2007: different issue
    Error loading operating system (Win XP raw guest on Gutsy)
    viewtopic.php?f=2&t=2776&p=9734
Post Reply