Virtual disk options allow you to set up, migrate, and manage virtual disks stored on your datastores. You can also perform most of these tasks through the vSphere Client.

Supported Disk Formats

When you create or clone a virtual disk, you can use the -d|--diskformat suboption to specify the format for the disk.

Choose from the following formats:

  • zeroedthick (default) – Space required for the virtual disk is allocated during creation. Any data remaining on the physical device is not erased during creation, but is zeroed out on demand on first write from the virtual machine. The virtual machine does not read stale data from disk.
  • eagerzeroedthick – Space required for the virtual disk is allocated at creation time. In contrast to zeroedthick format, the data remaining on the physical device is zeroed out during creation. It might take much longer to create disks in this format than to create other types of disks.
  • thin – Thin-provisioned virtual disk. Unlike with the thick format, space required for the virtual disk is not allocated during creation, but is supplied, zeroed out, on demand.
  • rdm:device – Virtual compatibility mode raw disk mapping.
  • rdmp:device – Physical compatibility mode (pass-through) raw disk mapping.
  • 2gbsparse – A sparse disk with the maximum extent size of 2 GB. You can use disks in this format with hosted VMware products, such as VMware Fusion. However, you cannot power on the sparse disk on an ESXi host unless you first re-import the disk with vmkfstools in a compatible format, such as thick or thin.

Disk Formats on NFS Datastores

The only disk formats you can use for NFS are thin, thick, zeroedthick, and 2gbsparse.

Thick, zeroedthick, and thin formats usually behave the same because the NFS server and not the ESXi host determines the allocation policy. The default allocation policy on most NFS servers is thin. However, on NFS servers that support Storage APIs - Array Integration, you can create virtual disks in zeroedthick format. The reserve space operation enables NFS servers to allocate and guarantee space.

For more information on array integration APIs, see Storage Hardware Acceleration in vSphere.

Creating a Virtual Disk

Use the vmkfstools command to create a virtual disk.

-c|--createvirtualdisk size[bB|sS|kK|mM|gG]
      -d|--diskformat [thin|zeroedthick|eagerzeroedthick]
      -W|--objecttype [file|vsan|vvol]
      --policyFile fileName

This option creates a virtual disk at the specified path on a datastore. Specify the size of the virtual disk. When you enter the value for size, you can indicate the unit type by adding a suffix of k (kilobytes), m (megabytes), or g (gigabytes). The unit type is not case-sensitive. vmkfstools interprets either k or K to mean kilobytes. If you do not specify a unit type, vmkfstools defaults to bytes.

You can specify the following suboptions with the -c option.

  • -d|--diskformat specifies disk formats.
  • -W|--objecttype specifies whether the virtual disk is a file on a VMFS or NFS datastore, or an object on a vSAN or Virtual Volumes datastore.
  • --policyFile fileName specifies VM storage policy for the disk.

Example for Creating a Virtual Disk

This example shows how to create a two-gigabyte virtual disk file named disk.vmdk. You create the disk on the VMFS datastore named myVMFS. The disk file represents an empty virtual disk that virtual machines can access.

vmkfstools -c 2048m /vmfs/volumes/myVMFS/disk.vmdk

Initializing a Virtual Disk

Use the vmkfstools command to initialize a virtual disk.

-w|--writezeros
This option cleans the virtual disk by writing zeros over all its data. Depending on the size of your virtual disk and the I/O bandwidth to the device hosting the virtual disk, completing this command might take a long time.
Note: This command is not supported on NFS datastores.
Caution: When you use this command, you lose any existing data on the virtual disk.

Inflating a Thin Virtual Disk

Use the vmkfstools command to inflate a thin virtual disk.

-j|--inflatedisk

This option converts a thin virtual disk to eagerzeroedthick, preserving all existing data. The option allocates and zeroes out any blocks that are not already allocated.

Converting a Zeroedthick Virtual Disk to an Eagerzeroedthick Disk

Use the vmkfstools command to convert any zeroedthick virtual disk to an eagerzeroedthick disk.

-k|--eagerzero

While performing the conversion, this option preserves any data on the virtual disk.

Follow this example:

vmkfstools --eagerzero /vmfs/volumes/myVMFS/VMName/disk.vmdk

Removing Zeroed Blocks

Use the vmkfstools command to remove zeroed blocks.

-K|--punchzero

This option deallocates all zeroed out blocks and leaves only those blocks that were allocated previously and contain valid data. The resulting virtual disk is in thin format.

Deleting a Virtual Disk

Use the vmkfstools command to delete a virtual disk file at the specified path on the VMFS volume.

Use the following option:

-U|--deletevirtualdisk

Renaming a Virtual Disk

Use the vmkfstools command to rename a virtual disk file at the specified path on the VMFS volume.

You must specify the original filename or file path oldName and the new filename or file path newName.

-E|--renamevirtualdisk oldName newName

Cloning or Converting a Virtual Disk or RDM

Use the vmkfstools command to create a copy of a virtual disk or raw disk you specify.

A non-root user cannot clone a virtual disk or an RDM. You must specify the original filename or file path oldName and the new filename or file path newName.

 -i|--clonevirtualdisk oldName newName
      -d|--diskformat [thin|zeroedthick|eagerzeroedthick|rdm:device|rdmp:device|2gbsparse]
      -W|--objecttype [file|vsan|vvol]
      --policyFile fileName
      -N|--avoidnativeclone

Use the following suboptions to change corresponding parameters for the copy you create.

  • -d|--diskformat specifies disk formats.
  • -W|--objecttype specifies whether the virtual disk is a file on a VMFS or NFS datastore, or an object on a vSAN or Virtual Volumes datastore.
  • --policyFile fileName specifies VM storage policy for the disk.

By default, ESXi uses its native methods to perform the cloning operations. If your array supports the cloning technologies, you can off-load the operations to the array. To avoid the ESXi native cloning, specify the -N|--avoidnativeclone option.

Example for Cloning or Converting a Virtual Disk

This example illustrates cloning the contents of a master virtual disk from the templates repository to a virtual disk file named myOS.vmdk on the myVMFS file system.

vmkfstools -i /vmfs/volumes/myVMFS/templates/gold-master.vmdk /vmfs/volumes/myVMFS/myOS.vmdk

You can configure a virtual machine to use this virtual disk by adding lines to the virtual machine configuration file, as in the following example:

scsi0:0.present = TRUE 
scsi0:0.fileName = /vmfs/volumes/myVMFS/myOS.vmdk

If you want to convert the format of the disk, use the -d|--diskformat suboption.

This suboption is useful when you import virtual disks in a format not compatible with ESXi, for example 2gbsparse format. After you convert the disk, you can attach this disk to a new virtual machine you create in ESXi.

For example:
vmkfstools -i /vmfs/volumes/myVMFS/templates/gold-master.vmdk /vmfs/volumes/myVMFS/myOS.vmdk  -d thin

Extending a Virtual Disk

After you create a virtual machine, you can use the vmkfstools command to extend the size of a disk allocated to the virtual machine.

-X|--extendvirtualdisk newSize[bBsSkKmMgGtT]

Specify the newSize parameter adding an appropriate unit suffix. The unit type is not case-sensitive. vmkfstools interprets either k or K to mean kilobytes. If you do not specify the unit type, vmkfstools defaults to kilobytes.

The newSize parameter defines the entire new size, not just the increment you add to the disk.

For example, to extend a 4-g virtual disk by 1 g, enter: vmkfstools -X 5g disk name.

You can extend the virtual disk to the eagerzeroedthick format by using the -d eagerzeroedthick option.

When you use the -X option, the following considerations apply:

  • Do not extend the base disk of a virtual machine that has snapshots associated with it. If you do, you can no longer commit the snapshot or revert the base disk to its original size.
  • After you extend the disk, you might need to update the file system on the disk. As a result, the guest operating system recognizes the new size of the disk and can use it.

Upgrading Virtual Disks

This option converts the specified virtual disk file from ESX Server 2 formats to the ESXi format.

Use this option to convert virtual disks of type LEGACYSPARSE, LEGACYPLAIN, LEGACYVMFS, LEGACYVMFS_SPARSE, and LEGACYVMFS_RDM.

-M|--migratevirtualdisk

Creating a Virtual Compatibility Mode Raw Device Mapping

Use the vmkfstools command to create a Raw Device Mapping (RDM) file on a VMFS volume and map a raw LUN to this file. After this mapping is established, you can access the LUN as you would a normal VMFS virtual disk. The file length of the mapping is the same as the size of the raw LUN it points to.

-r|--createrdm device

When specifying the device parameter, use the following format:

/vmfs/devices/disks/disk_ID:P

Example for Creating a Virtual Compatibility Mode RDM

In this example, you create an RDM file named my_rdm.vmdk and map the disk_ID raw disk to that file.

vmkfstools -r /vmfs/devices/disks/disk_ID my_rdm.vmdk

You can configure a virtual machine to use the my_rdm.vmdk mapping file by adding the following lines to the virtual machine configuration file:

scsi0:0.present = TRUE 
scsi0:0.fileName = /vmfs/volumes/myVMFS/my_rdm.vmdk

Creating a Physical Compatibility Mode Raw Device Mapping

Use the vmkfstools command to map a pass-through raw device to a file on a VMFS volume. With the mapping, a virtual machine can bypass ESXi SCSI command filtering when accessing its virtual disk. This type of mapping is useful when the virtual machine must send proprietary SCSI commands, for example, when SAN-aware software runs on the virtual machine.

-z|--createrdmpassthru device example.vmdk

After you establish this type of mapping, you can use it to access the raw disk as you access any other VMFS virtual disk.

When specifying the device path, use the following format:

/vmfs/devices/disks/device_ID 

For the .vmdk name, use this format. Make sure to create the datastore before using the command.

/vmfs/volumes/datastore_name/example.vmdk 
For example,
vmkfstools -z /vmfs/devices/disks/naa.600a0000000000000... /vmfs/volumes/datastore1/mydisk.vmdk

Listing Attributes of an RDM

Use the vmkfstools command to list the attributes of a raw disk mapping. The attributes help you identify the storage device to which your RDM files maps.

-q|--queryrdm my_rdm.vmdk

This option prints the name of the raw disk RDM. The option also prints other identification information, like the disk ID, for the raw disk.

Example of Listing RDM Attributes

# vmkfstools -q /vmfs/volumes/VMFS/my_vm/my_rdm.vmdk 

Disk /vmfs/volumes/VMFS/my_vm/my_rdm.vmdk is a Passthrough Raw Device Mapping 

Maps to: vml.020000000060050768019002077000000000000005323134352020 

Displaying Virtual Disk Geometry

Use the vmkfstools command to get information about the geometry of a virtual disk.

-g|--geometry

The output is in the form: Geometry information C/H/S, where C represents the number of cylinders, H represents the number of heads, and S represents the number of sectors.

Note: When you import virtual disks from hosted VMware products to the ESXi host, you might see a disk geometry mismatch error message. A disk geometry mismatch might also trigger problems when you load a guest operating system or run a newly created virtual machine.

Checking and Repairing Virtual Disks

Use the vmkfstools command to check or repair a virtual disk if it gets corrupted.

-x|--fix [check|repair]

For example,

vmkfstools -x check /vmfs/volumes/my_datastore/my_disk.vmdk

Checking Disk Chain for Consistency

Use the vmkfstools command to check the entire snapshot chain. You can determine if any of the links in the chain are corrupted or any invalid parent-child relationships exist.

-e|--chainConsistent