Recreating a virtual disk (VMDK) header file

ที่มา : VMware

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

  1. 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”
  2. 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
  3. Run the vmkfstools command to create a new virtual disk.# vmkfstools -c 4294967296 -a lsilogic temp.vmdkThis 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.

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

# rm temp-flat.vmdk

  1. 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

  1. 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.Find the line with ddb.thinProvisioned (if -d thin was used and the original was not a thin disk) and remove it:
  2. ————————————-

# 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.

Leave a Reply