VirtualBox: grain table inconsistency

The setup in question is as follows: Windows 7 64bit host running VirtualBox. The guest machine is running Windows XP 32bit.

After a power failure on the host box, the guest machine cannot boot and complains that

inconsistency between grain table and backup grain table

Any help to boot the guest machine without reinstalling it appreciated.

PS: What is a grain table anyway?


Can't really help, but I found what the grain tables are here: http://www.vmware.com/support/developer/vddk/VirtualDiskAPIprogramming.pdf (page 16)

Like the user mailq says, looks like your virtual drive is broken. Maybe check the vmdkck tool (on this page http://datto.org/projects/vmdk-tools ) to double check it's broken?


VMware has a tool called vmware-vdiskmanager located in "/Applications/VMware Fusion.app/Contents/Library/" and symlinked to /usr/local/bin when installed. You can use this tool to repair VirtualBox VMDK disks as well. It saved me a couple of times already.

Installation

a. You can install vmware-fusion (requires macOS Catalina; use vmware-fusion10 for older macOS versions)

brew install vmware-fusion

b. Or you can download the vmware-vdiskmanager utility directly from Attachments section at the bottom of this page:
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1023856

Usage

vmware-vdiskmanager -R <your_disk>.vmdk

Invoking without parameters gives help usage:

Usage: vmware-vdiskmanager OPTIONS <disk-name> | <mount-point>
Offline disk manipulation utility
...
     -R                   : check a sparse virtual disk for consistency and attempt
                            to repair any errors.
...

Your virtual hard drive is broken. Grain tables are some internal stuff of virtualization environments.

Googling for the exact term reveals that there are not many possibilities to recover: https://forums.virtualbox.org/viewtopic.php?f=6&t=40049


I used CloneVDI to solve this problem. I made a clone and the new file works very well.


I had this error after moving my ~/VirtualBox\ VMs from Linux to MacOS. I tried @mens solution using vmware-vdiskmanager, but it failed for me.

During my migration from linux to MacOS, I added all of the *.vbox files back into Virtualbox and they all failed to boot with the same error (using vagrant):

There was an error while executing `VBoxManage`, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "<UUID 1>", "--type", "headless"]

Stderr: VBoxManage: error: Could not open the medium '/path/to/box-disk1.vmdk'.
VBoxManage: error: VMDK: inconsistency between grain table and backup grain table in '/path/to/box-disk1.vmdk' (VERR_VD_VMDK_INVALID_HEADER).
VBoxManage: error: VD: error VERR_VD_VMDK_INVALID_HEADER opening image file '/path/to/box-disk1.vmdk' (VERR_VD_VMDK_INVALID_HEADER)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MediumWrap, interface IMedium

I verified that the data transfered correctly, md5 box-disk1.vmdk returned the same thing for both files.

I managed to get a vm to boot again by converting the vmdk files to vdi doing the following. (Requires qemu, brew install qemu)

# Convert from `.vmdk` to `.bin`
qemu-img convert box-disk1.vmdk box-disk1.bin

# Convert from `.bin` to `.vdi`
VBoxManage convertdd box-disk1.bin box-disk1.vdi

Updated path to volume for .vdi and machine booted.

In my case, vdi file is slightly larger, don't forget to delete .bin as it's huge. Oh and it fails to authenticate on first run. Anyway, if possible, maybe you should spin up a new vm from scratch instead.