×


Failure to unmount or delete VMFS Datastore the resource is in use

Sometimes, in the process of deleting an empty VMFS Datastore in VMWare vSphere, an error such as "unable to unmount/delete vmfs datastore: the resource is in use" occurs.


Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to solve VMware related errors.


In this context, we shall look more into causes of this error and how to get rid of it.


What triggers the error unable to unmount/delete VMFS Datastore: the resource is in use?

As earlier stated, in the process of migrating virtual machines files from old storage to a new storage system users experiences the error message as  displayed below;


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”.


Basically, this occurs in the process of unmounting the VMFS Datastore from ESXi hosts.


From this error message, you will notice that the VMFS datastore cannot be removed since ESXi hosts or vSphere are still using storage to write some data.


If you go through the official VMWare documentation, it is stated there that in the process of removing LUN from vSphere, it is important to consider the following points;


i. There are no virtual machine, template, snapshot, or ISO image files on VMFS datastore (we must migrate the VMs to another VMFS Datastore, power off and remove them, or unregister VMs in vSphere).


ii. Storage I/O Control is disabled for datastore.


iii. The datastore is not a part of the Datastore Cluster.


iv. The LUN is not used as an RDM device.


v. VMFS datastore is not used to store vSphere HA data, Storage DRS, logs, dumps (/vmkdump/), vSAN data (/vsantraced/), technical support data (scratch partition), or virtual machine swap files.


Steps to fix the error unable to unmount/delete VMFS Datastore: the resource is in use?

Sometimes, even after moving the virtual machines to a new datastore, the VMFS data storage might still contain some other files and folders such as a directory with logs(logdir), a directory with the description of SCSI devices (sdd.sf), VMFS metadata, and so on.


In a situation where the ESXi host logs are still located in the VMFS datastore (Scratch Location), we may need to check out if the datastore is specified as a location of logs in the ESXi host settings.


To do this, navigate through, "Manage -> Settings -> Advanced System" system. Look for ScratchConfig.CurrentScratchLocation and Syslog.global.logDir. You must then change the path to the logs if VMFS datastore is specified in it.


After this, perform a restart of the ESXi host or you can simply restart the Syslog Server service on the host.


To unmount the datastore from the ESXi host, simply navigate through "Manage -> Storage -> Storage Device". Here, look for the corresponding LUN from the list, then select it, and click Detaches the selected device from the host.


How to delete a partition table of VMFS datastore?

Sometimes, the unmount operation still fails even after changing the paths to the log directory.


In this case, you can try to delete the partition table of the VMFS datastore. To do this, follow the steps given below;


i. Establish a connection to the ESXi host which has VMFS store mounted via an ssh tool such as putty.


ii. Then, copy the ID of your datastore in the vSphere interface, and check on the ESXi host, which device and path to the VMFS store it matches as shown below;


esxcfg-scsidevs -c | grep naa.8001438005df0dee0000700004be0000


naa.8001438005df0dee0000700004be0000 Direct-Access /vmfs/devices/disks/naa. 8001438005df0dee0000700004be0000 512000MB NMP HP Fibre Channel Disk (naa.8001438005df0dee0000700004be0000)


esxcfg-scsidevs -m | grep naa.8001438005df0dee0000700004be0000


naa.8001438005df0dee0000700004be0000:1 /vmfs/devices/disks/naa.8001438005df0dee0000700004be0000:1 570e5298-08f4c74e-ca3a-b4b52f5e2b38 0 MSA2000_LUN1


iii. Now, check the available space which is in a busy state on the VMFS datastore by running the command below;


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


iv. Now that we are certain about the datastore name and the store ID match the LUN we want to remove, then we can proceed to the next step.


v. In this step, we can check the Partition table information of the datastore by running the command below;


partedUtil getptbl 
/vmfs/devices/disks/naa.8001438005df0dee0000700004be0000


Also run the following command and you will get a corresponding output like this;


gpt
65270 255 63 1048576000
1 2048 1048575966 AA31E02A400F11DB9590000C2911D1B8 vmfs 0


vi. Now, the LUN has a single partition with the VMFS file system.


vii. You can delete the VMFS partition with ID 1 from this disk (LUN) by running the following command as shown below;


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

As soon as the partition is deleted, then you can unmount the LUN in vSphere. This will resolve the issue finally.


Need support in fixing  unable to unmount/delete VMFS Datastore: the resource is in use? We are available to help you today.


Conclusion

This article will guide you on how to solve the error “unable to unmount/delete vmfs datastore: the resource is in use” triggers while removing an empty VMFS Datastore in VMWare vSphere.