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

来源:互联网 发布:网络司法拍卖调研报告 编辑:程序博客网 时间:2024/06/08 00:43

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 virtual machine 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 

 
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

    Note: If you are using ESXi, you can move, copy, change and delete directories and files using the vSphere client datastore browser, or the vifs utility which comes with the vSphere CLI. For more information, see the Performing File System Operations with vifs section of the vSphere CLI 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.

  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"

    Note: If you are using ESXi, you can download, view, edit and upload files using the vSphere Client datastore browser or the vifs utility which comes with the vSphere API. The file can be viewed or edited using your preferred text editor. For more information, see the Performing File System Operations with vifs section of the vSphere CLI documentation.

  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.

    Note: If you are using ESXi, you can run the vmkfstools utility remotely using the vSphere CLI. For more information, see the vmkfstools Command Syntax section of the vSphere CLI documentation.

  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: If you are using ESXi, you can download, view, edit and upload files using the vSphere Client datastore browser or the vifs utility which comes with the vSphere API. The file can be edited using your preferred text editor. For more information about the usage of the vifs utility, see the vSphere CLI documentation.

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 equivalent commands for your platform ( move, copy, and del instead 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.
0 0
原创粉丝点击