Sometimes, webmasters experiences errors such as "unable to unmount/delete vmfs datastore: the resource is in use" in the process of deleting an empty VMFS Datastore in VMWare vSphere.
Here at Ibmi Media, as part of our Server Support Services, we regularly help our Customers to solve VMware related errors.
Now let us look into the causes of this error and how to tackle it.
As earlier referenced, sometimes while trying to migrate a virtual machine from an old storage to a new system, users experiences errors such as this;
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 occurs in the process of trying to unmount the VMFS Datastore from ESXi hosts.
From the error message, you can see that VMFS datastore cannot be removed since ESXi hosts or vSphere are still using storage to write some data.
As per the official VMWare documentation, the following points should be noted when trying to remove LUN from vSphere;
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.
Sometimes, even after migrating a virtual machine to a new datastore, some files and folders might still remain in the VMFS data storage.
This may include a directory with logs (logdir), a directory with the description of SCSI devices (sdd.sf), VMFS metadata and so on.
Look out for the ESXi host logs in the VMFS datastore location. It is important to check that the datastore is specified as a location of logs in the ESXi host settings.
To do this, navigate through "Manage -> Settings -> Advanced System Settings" to find "ScratchConfig.CurrentScratchLocation" and "Syslog.global.logDir". If specified, then modify the path to the logs directory.
After this, perform a restart of the ESXi host or restart the Syslog Server service on the host.
Now, we will try to unmount the unmount the datastore from the ESXi host again. To do this navigate through "Manage -> Storage -> Storage Device" to find the corresponding LUN in the list shown. Then select it and click "Detaches the selected device from the host".
In other cases, the unmount operation tends to fail even after changing the paths to the log directory.
To fix this, you need to delete the partition table of the VMFS datastore. To do this, follow the steps below;
1. Make a connection via SSH to the ESXi host that has VMFS store mounted.
2. Then, copy the ID of your datastore in the vSphere interface and check the ESXi host which device and path to the VMFS store matches as shown below;
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 570e5298-08f4c74e-ca3a-b4b52f5e2b38 0 MSA2000_LUN1
3. Now, check how much space is busy on the VMFS datastore with the command below;
df -h | grep MSA2000_LUN1
This will display the output;
VMFS-5 499.8G 1.4G 498.3G 0% /vmfs/volumes/MSA2000_LUN1
4. Now that the datastore name and the store ID matches the LUN we are trying to remove, then check the information relating to the partition table on the datastore with the commands below;
partedUtil getptbl /vmfs/devices/disks/naa.6001438005df0dee0000700004be0000
65270 255 63 1048576000
1 2048 1048575966 AA31E02A400F11DB9590000C2911D1B8 vmfs 0
5. You will notice that the LUN has a single partition with the VMFS file system.
6. Now you can delete the VMFS partition with ID 1 from the disk (LUN) as shown below;
partedUtil delete /vmfs/devices/disks/naa.6001438005df0dee0000700004be0000 1
After deleting the partition, you can now proceed with unmounting the LUN in vSphere.
You will notice that the error "datastore is in use" does not apply anymore.
This guide will help to fix VMWare error "unable to unmount/delete vmfs datastore: the resource is in use" which occurs when trying to remove an empty VMFS Datastore in VMWare vSphere.