Sunday, January 19, 2025

Steps to Fix VMFS Datastore unmount/Delete Error: Resource in Use

 Often while deleting an empty VMFS Datastore in VMWare vSphere you may encounter the error "Unable to unmount/delete VMFS datastore: the source is in use". What Causes VMFS Datastore Unmount/Delete Error Not Existing: Resource in Use? Often when moving VM files from old storage to a new storage system, users encounter an error message like the following:

Unmount VMFS volume vmesxi2.woshub.com. The resource 'Datastore Name: MSA2000_LUN1 VMFS uuid: xxxxx--xxxxx-x-xxxxx-xxxx' is in use. Cannot unmount volume Datastore Name VMFS “file system is busy”.

This error usually occurs when trying to disconnect VMFS Datastore from ESXi hosts. Based on the error, it is clear that VMFS data storage cannot be removed because ESXi or vSphere hosts still use storage to write some data.

According to VMWare documentation, we need to check the following points when removing LUN from vSphere:

  • There are no virtual machines, templates, snapshots, or ISO image files in the VMFS Data Store (we need to move VMs to another VMFS Datastore, turn them off and delete, or unregister VMs in vSphere).
  • Storage I/O Control is disabled for storing data
  • Datastore is not part of the Datastore Cluster
  • LUN is not used as an RDM device
  • VMFS datastore is not used to store vSphere HA data, Storage DRS, logs, dump data (/vmkdump/), vSAN data (/vsantraced/), technical support data (scratch partition), or virtual machine swap files.

How to Fix VMFS Datastore Unmount/Delete Error: Resource in Use?

Sometimes, even after moving virtual machines to a new data store, VMFS storage may still contain other files and folders. This may include a directory with log (logdir), a directory with a description of SCSI devices (sdd.sf), VMFS metadata. If ESXi host logs are still in the VMFS data store (logdir), we may need to check if the data store is specified as the location of the logs in the ESXi host settings. To do this, go to Manage -> Settings -> Advanced System Settings. Find ScratchConfig.CurrentScratchLocation and Syslog.global.logDir. If there is a VMFS data store in that path, change the path of the logs directory.

Now restart ESXi Hosting or restart the Syslog Server service on the host. Let's try to disconnect the data store from the ESXi host again. Go to Manage -> Storage -> Storage Device. Find the corresponding LUN in the list, select it, and click Detaches the Selected device from host.

Delete VMFS datastore partition table

Sometimes, even after redirecting to the report directory, the unmount operation still fails. This can be done by the following steps:

1. Connect via SSH to an ESXi host that has VMFS storage installed.
2. Copy your data store ID into the vSphere interface and check the ESXi host which device and VMFS storage path it corresponds to:

esxcfg-scsidevs -c | grep naa.6001438005df0dee0000700004be0000
naa.6001438005df0dee0000700004be0000 Direct-Access /vmfs/devices/disks/naa. 6001438005df0dee0000700004be0000 512000MB NMP HP Fibre Channel Disk (naa.6001438005df0dee0000700004be0000)
esxcfg-scsidevs -m | grep naa.6001438005df0dee0000700004be0000
naa.6001438005df0dee0000700004be0000:1 /vmfs/devices/disks/naa.6001438005df0dee0000700004be0000:1

3. Let's see how much space is occupied in the VMFS data repository:

df -h | grep MSA2000_LUN1
VMFS-5 499.8G 1.4G 498.3G 0% /vmfs/volumes/MSA2000_LUN1

4. So we have made sure that the datastore name and store ID match the LUN we want to remove.
5. Now let's check the information about the partition table in the data store:

partedUtil getptbl /vmfs/devices/disks/naa.6001438005df0dee0000700004be0000
gpt
65270 255 63 1048576000
1 2048 1048575966 AA31E02A400F11DB9590000C2911D1B8 vmfs 0

6. In this case, the LUN has a partition with the VMFS filesystem.
7. Remove VMFS partition with ID 1 from this disk (LUN).

partedUtil delete /vmfs/devices/disks/naa.6001438005df0dee0000700004be0000 1

After removing the partition, we can unmount LUN in vSphere. The "Datastore is in use" error does not appear again. In summary, the "unable to unmount/delete vmfs datastore: the resource is in use" error is generated when deleting an empty VMFS Datastore in VMWare vSphere

No comments: