This Blog is to share our knowledge and expertise on Linux System Administration and VMware Administration

Wednesday, October 14, 2015

How ro Recreate a missing Virtual machine disk descriptor file

Overview steps

Note: It would be advisable to attempt to restore the missing descriptor file from backups if possible. If this is not possible, proceed with recreating the virtual machine disk descriptor file.

To create a virtual machine disk descriptor file:

    Identify the size of the flat file in bytes.
    Create a new blank virtual disk that is the same size as the original. This serves as a baseline example that is modified in later steps.

    Note: This step is critical to assure proper disk geometry.
    Rename the descriptor file (also referred to as a header file) of the newly-created disk to match the name of the original virtual disk.
    Modify the contents of the renamed descriptor file to reference the flat file.
    Remove the leftover temporary flat file of the newly-created disk, as it is not required.

Note: This procedure will not work on virtual disks configured with a Para-virtualized SCSI controller in the virtual machine as the virtual machine may not boot. However, there are reports that if the Para-virtualized SCSI controller is used, the new descriptor file can also be updated with ddb.adapterType = pvscsi replacing ddb.adapterType = lsilogic in the descriptor file.

Detailed steps

To create a virtual machine disk:

    Log into the terminal of the ESXi/ESX host:
        For ESX 4.1 and earlier, see Connecting to an ESX host using a SSH client . Alternatively, access the system directly and press Alt+F1 to begin the login process. Log in as root .
        For ESXi 4.1 and 5.x, see Using Tech Support Mode in ESXi 4.1, ESXi 5.x, and ESXi 6.0 .
        For ESXi 4.0 and 3.5  Navigate to the directory that contains the virtual machine disk with the missing descriptor file using the command:

    # cd /vmfs/volumes/myvmfsvolume/mydir

        If you are using a version of ESXi, you can access and modify files and directories using the vSphere Client Datastore Browser or the vifs utility included with the vSphere CLI. For more information, see the section Performing File System Operations in the vSphere Command-Line Interface Documentation.
        If you are using VMware Fusion, the default location for the virtual machine files is the home/Documents/Virtual Machines.localized/virtual_machine/ folder, where home is your home folder, and virtual_machine is the name of the virtual machine.

    Identify the type 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 may be more than one controller and controller type attached to the virtual machine, such as lsisas1068 (which is the LSILogic SAS controller), lsilogic , or buslogic . This example uses lsilogic :

    scsi0.present = "true"
    scsi0.sharedBus = "none"
    scsi1.present = "true"
    scsi1.sharedBus = "virtual"
    scsi1.virtualDev = "lsilogic"
    Identify and record the exact size of the -flat file using a command similar to:

    # ls -l vmdisk0-flat.vmdk

    -rw------- 1 root root 4294967296 Oct 11 12:30 vmdisk0-flat.vmdk
    Use the vmkfstools command to create a new virtual disk:

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

    The command uses these flags:
        -c size

        This is the size of the virtual disk.
        -a virtual_controller

        Whether the virtual disk was configured to work with BusLogic, LSILogic (for both lsilogic and lsilogic SAS), Paravirtual, or IDE:
        Use lsilogic for virtual disk type "lsilogic" and "lsisas1068"
        -d thin

        This creates the disk in thin-provisioned format.

    Note: To save disk space, we create the disk in thin-provisioned format using the type thin . The resulting flat file then consumes minimal amounts of space (1 MB) instead of immediately assuming the capacity specified with the -c switch. The only consequence, however, is the descriptor file contains an extra line that must be manually removed in a later step.

    The temp.vmdk and temp-flat.vmdk files are created as a result.
    Delete temp-flat.vmdk , as it is not needed. Run the command:

    # rm -i temp-flat.vmdk
    Rename temp.vmdk to the name that is required to match the orphaned .flat file (or vmdisk0.vmdk , in this example):

    # mv -i temp.vmdk vmdisk0.vmdk
    Edit the descriptor file using a text editor:
        Under the Extent Description section, change the name of the .flat file to match the orphaned .flat file you have.
        Find and remove the line ddb.thinProvisioned = "1" if the original .vmdk was not a thin disk. If it was, retain this line.

        # Disk DescriptorFile

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

        # The Disk Data Base

        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 to power on. Verify your changes before starting the virtual machine.

        If powering on the virtual machine is not successful
    To check the disk chain for consistency, run this command against the disk descriptor file:

    For ESXi 6.0 and 5.x:
    # vmkfstools -e filename.vmdk

    For a complete chain, you see output similar to:
    Disk chain is consistent

    For a broken chain, you see a summary of the snapshot chain and then an output similar to:
    Disk chain is not consistent : The parent virtual disk has been modified since the child was created. The content ID of the parent virtual disk does not match the corresponding parent content ID in the child (18)

    For ESXi 3.5/4.x:
    # vmkfstools -q filename.vmdk

    For a complete chain, you see output similar to:
    filename.vmdk is not an rdm

    For a broken chain, you see output similar to:
    Failed to open 'test-000001.vmdk' : The parent virtual disk has been modified since the child was created (18)
    Note: The primary purpose of the vmkfstools -q command is(from the vmkfstools help page: vmkfstools -h ): -q --queryrdm .
    This command identify any issues with the snapshot chain, not its intended purpose, which is to identify if the vmdk disk is a raw device mapping.

    For more information on the vmkfstools command, see: vmkfstools - vSphere CLI for managing VMFS volumes

No comments:

Post a Comment