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 primary 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-primary.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-primary.vmdk /vmfs/volumes/myVMFS/myOS.vmdk  -d thin