This article provides a procedure to rename a virtual machine (VM) and its associated files (.vmdk, .vmx, and folder) when the VM resides on a vSAN datastore and no secondary datastore is available to perform a standard Storage vMotion.
VMware vSAN 8.x
vSAN Cluster where hosts only have a single datastore (vSAN)
Pre-requisites:
Before implementing this fix, ensure a valid file-level backup of the vCenter Server is available.
Procedure to rename VM and files:
Select a host in the vSAN cluster where the VM resides.
Place the host into Maintenance Mode using the Ensure Accessibility option. Run pre-check to validate that the host can be placed into maintenance mode.
Navigate to vSAN Cluster > Configure > vSAN > Disk Management.
Select the host and click View Disks.
Harvest a capacity device to create a temporary VMFS datastore:
If Deduplication is DISABLED: Select a capacity device and click Remove Disk.
If Deduplication is ENABLED: The entire disk group must be deleted and recreated while omitting one capacity device.
Create a temporary VMFS datastore:
Right-click the host and select Storage > New Datastore.
Select VMFS 6 and use the harvested device as the backing storage.
Exit the host from Maintenance Mode.
Trigger a vSAN resync to ensure data availability: vSAN Cluster > Monitor > vSAN > Resyncing Objects > Sync Now.
Rename the VM in the vCenter inventory.
Perform a Storage vMotion of the VM from the vSAN datastore to the temporary VMFS datastore.
This process renames the underlying files.
Perform a Storage vMotion of the VM back to the vSAN datastore.
Delete the temporary VMFS datastore.
Add the capacity device back to the vSAN disk group via vSAN Disk Management.
Notes:
Before migrating the virtual machine back, clear out any existing folders with the same name from the vSAN datastore. If a duplicate directory is detected, the system will automatically append _1 to the new VM's folder name.