To create a virtual machine disk:
- Log in to the terminal of the ESXi/ESX host
- Navigate to the directory that contains the virtual machine disk with the missing descriptor file using the command:
# cd /vmfs/volumes/myvmfsvolume/mydir
- Identify the type of SCSI controller the virtual disk is using 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.
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 "vi" text editor ( vi vmdisk0.vmdk, in this example)
- Under the Extent Description section,
- Use command "Shift + r" to enter replace mode.
- Locate and change the name of the .flat file to match the orphaned .flat, Press "Esc" to exit replace mode.
- Find and remove the line ddb.thinProvisioned = "1" if the original .vmdk was not a thin disk. If it was, retain this line. Use command "Shift + zz" to save and exit "vi" editor.
# 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 and ensure Disk chain is consistent before starting the virtual machine.
- 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)
Each disk drive for a virtual machine consists of a pair of .vmdk files. One is a text file containing descriptive data about the virtual hard disk, and the second is the actual content of that disk. For example, a virtual machine named examplevm has one disk attached to it. This disk is comprised of a examplevm.vmdk descriptor file of under 1 KB, and a 10 GB examplevm-flat.vmdk flat file which contains virtual machine content.