Duplicate directories exist for the same VM on one or more datastores.
search cancel

Duplicate directories exist for the same VM on one or more datastores.

book

Article ID: 416878

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

Symptoms:

  • When browsing one of your datastores, you see 2 similar folders, with the same name, but one of them has an _1 (and possibly  _2, _3, ...) appended to it.  For example, you have 2 folders on a datastore, where one is named myVMFolder and another is named myVMFolder_1

Environment

  • VMware ESXi  (all versions)

Cause

  • In general, this occurs automatically when a VM is created on or migrated to a datastore that has an existing folder with the same name. ESXi automatically appends the _1 (or _2, _3, ..., if necessary) to ensure the directory name is unique to one particular VM.

  • Some example situations where this can occur:

    • A single VM may have several virtual disks stored on separate datastores.  Each disk on a different data datastore will be stored in a folder with the same name, if possible. If a folder with the same name already exists on the datastore(s) , the host will create a new folder by appending _1, _2, etc. to the VM name (e.g. MyVM_1, MyVM_2, ...).  

    • A folder will be left on the datastore if a VM was unregistered, but not deleted. Creating a new VM with the exact same name on the same datastore will result in the creation of such a folder.

    • Manual creation/copying of VM directories without registering the VM in the new folder, then subsequently creating a new VM with the same name, will result in the creation of such a folder.

    • Restoration of a VM by 3rd party backup. Similar to the above, the VM is restored from a backup to the same datastore as the existing VM folder (where the original VM was not deleted), so such a folder may be created, if the backup software does not create a folder with a new unique name.

    • Certain 3rd party VM replication/disaster recovery workflows. 

 

Resolution

To determine which folders/files are in use by registered VMs, you can do the following: 

  • Verify the working directory in which the VM files of a register virtual machine are located:

    • In the VM inventory, select the VM -> Edit Settings -> click the VM Options tab -> Select General. The path to the virtual machine working location appears in the "VM Working Location" text box.

  • Verify to location of each VMDK file in the VM configuration:

    • In the VM inventory, select the VM -> Edit Settings
    • Expand each virtual disk and check the "Disk File" path.

 

  • Verify if any of the folders/files within in the folder are in use:

    • Open an ssh session to the ESXi host
    • Obtain the UUID of the datastore where the folder is located: 

esxcli storage vmfs extent list | grep <datastore_name> | awk '{print $2}'

 

    • Run the following command:

lsof | egrep -i "Cartel|/vmfs/volumes/<datastore_uuid_from_above>/folder_name"

 

If any of the files in the path specified above are in use, they will be displayed in the output:

 

Example

Cartel | World name | Type | fd | Description
#####    vmx          FILE   80   /vmfs/volumes/<datastore_uuid_from_above>/folder_name/VM_name.vmdk

 

NOTE:

      • This only shows output if the VM the file or folder belongs to is currently running.
      • You may see any number of files that are locked.
      • Files other than *.vmdk files may be locked (e.g. *.vmx, *.vmsn, *.vswp).
      • Do not assume if a file is not listed that it is not used. For example: virtual disks have both a descriptor file (vm_name.vmdk) and a data file (*-flat.vmdk), in addition to possible related snapshot files (*-delta.vmdk, *-sesparse.vmdk) or other metadata (*.vmsd, *.vmxf, etc), which are read at boot time, but are not be locked on an ongoing basis). 
      • If you find any files in the folder that are locked, you can assume the folder is in use. The files should be left alone in this case unless advised otherwise by Broadcom Technical Support for troubleshooting purposes. 

 

  • Check the date and time stamps in the datastore browser:

    • From vSphere Client:

      • Right-click Datastore in inventory -> Browse Files)

    • You can also check from an ssh session to the host:

ls -l /vmfs/volumes/<datastore_name>  (to see the date/time of the folder itself)
ls -l /vmfs/volumes/<datastore_name>/folder
   (to see the date/time of the files within the folder)

    • Check both the dates/times of the folders and the files within the folders to see which ones have been used recently to help narrow down which folders/files are still used, even if not currently in use as per the lsof command above. 

 

 

  • If you are still unsure which files are in use--especially if you are considering deleting the folder--please open a case with Broadcom Technical Support for further assistance. 

 

Additional Information