VMware
 

Knowledge Base

Search the Knowledge Base:

Products:
Search In:
 

Recreating a missing virtual disk (VMDK) header/descriptor file

Details

This article guides you through recreating a lost header/descriptor file.
 
You may need to recreate a missing header/descriptor file if:
  • The virtual machine disk is missing when viewing the VM folder from a Datastore browser
  • You can see the –flat.vmdk file does exist when connected to the host via command line
  • The .vmdk descriptor file for the virtual machines disk does not exist or is corrupted
  • When powering on a virtual machine you see a File not found error
The disk drives of a virtual machine are represented by a pair of .vmdk files. One is a small text file, containing descriptive data about the virtual hard disk. The second is the actual contents of that disk, and is usually the same size as the drive. 
 
For example, a 10GB disk has a 10GB .vmdk file. These content files have -flat appended to the name of the virtual machine, like virtualDisk-flat.vmdk. The descriptive file of this set is virtualDisk.vmdk.

Solution

the camtasia studio video content presented here requires a more recent version of the adobe flash player. if you are you using a browser with javascript disabled please enable it now. otherwise, please update your version of the free flash player by downloadinghere.

*If you find the video does not play, try updating your flash player.
**To watch the video in full-screen, choose the full-screen option at the bottom right of the player.
 
Overview Steps
 
To create a virtual disk header file:
  1. Identify the size of the -flat file.
  2. Create a new blank virtual disk that is the same size as the original.

    Note: This step is critical to assure proper disk geometry.

  3. Rename the descriptor of the new disk to match the name of the original virtual disk.
  4. Edit the descriptor to change the reference to the -flat file.
  5. Remove the leftover temporary -flat file as it is not needed.
Detailed Steps
 
To create a virtual disk header file:
  1. Log in to the console of the ESX host.
  2. Run this command to go to the directory that contains the virtual disk with the missing header/descriptor file:

    cd /vmfs/volumes/myvmfsvolume/mydir

  3. Identify the kind of SCSI controller the virtual disk is using. You can do this by examining the virtual machine configuration file (.vmx). The controller is identified by the line scsi#.virtualDev, where # is the controller number. There can be more than one controller attached to the virtual machine so make sure to identify which controller the disk you are working on is attached to.

    This example uses lsilogic:

    scsi0.present = "true"
    scsi0.sharedBus = "none"
    scsi1.present = "true"
    scsi1.sharedBus = "virtual"
    scsi1.virtualDev = "lsilogic"

  4. Run this command to identify and record the exact size of the flat file:

    # ls -l vmdisk0-flat.vmdk

    -rw------- 1 root root 4294967296 Oct 11 12:30 vmdisk0-flat.vmdk

  5. Run the vmkfstools command to create a new virtual disk.

    # vmkfstools -c 4294967296 -a lsilogic temp.vmdk

    This command uses the following flags:

    -c <size> (This is the size of the virtual disk.)
    -a <virtual controller> (Whether the virtual disk was configured to work with BusLogic or LSILogic.)

    If you are short on disk space, you can create the temporary disk as type thin. The associated -flat file consumes almost no space (1Mb) instead of the amount specified with -c (as we are not keeping the new -flat file, this is not a problem). The consequence is that the header file will contain an extra line that must be removed manually. The command looks like this:

    # vmkfstools -c 4294967296 -d thin -a lsilogic temp.vmdk


    The files temp.vmdk and temp-flat.vmdk are created as a result.

  6. Delete temp-flat.vmdk as it is not needed. Run the command:

    # rm temp-flat.vmdk

  7. Rename temp.vmdk to the name that is required to match the orphaned -flat file (vmdisk0.vmdk in this example):

    # mv temp.vmdk vmdisk0.vmdk

  8. Edit the descriptor file with a text editor:
    1. Find the line with RW ####### VMFS and change the name of the -flat to match the orphaned -flat file you have.
    2. Find the line with ddb.thinProvisioned (if -d thin was used and the original was not a thin disk) and remove it:
      -------------------------------------
      # Disk DescriptorFile
      version=1
      CID=fb183c20
      parentCID=ffffffff
      createType="vmfs"

      # Extent description
      RW 8388608 VMFS "vmdisk0-flat.vmdk"

      # The Disk Data Base
      #DDB

      ddb.virtualHWVersion = "4"
      ddb.geometry.cylinders = "522"
      ddb.geometry.heads = "255"
      ddb.geometry.sectors = "63"
      ddb.adapterType = "lsilogic"
      ddb.thinProvisioned = "1"
      -------------------------------------

      The virtual machine is now ready for power on.
Note: Although these steps are specific to the ESX service console, they may also be applied to platforms using VMware desktop products such as VMware Server or VMware Workstation. When performing these operations on a different platform, you must use the equivilent commands for your platform (move, copy, and del insteal of mv, cp, and rm for Microsoft Windows platforms).  Instead of using the vmkfstools command, you must use the vmware-vdiskmanager utility. For more information on the Virtual Disk Manager, see the Virtual Disk Manager User's Guide. For more information about platform specific commands, see the DOS verses Linux Commands from the Linux Documentation Project.

Feedback

Rating: 1 - Lowest 2 3 4 5 - Highest (20 Ratings)   

Did this article help you?
This article resolved my issue.
This article did not resolve my issue.
This article helped but additional information was required to resolve my issue.
What can we do to improve this information? (2000 or fewer characters)
Submit
Rating: 1 - Lowest 2 3 4 5 - Highest (20 Ratings)   
Actions