Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Virtualization / VMWare / Unable to Unmount/Delete VMFS Datastore: The Resource Is in Use

September 15, 2022 VMWare

Unable to Unmount/Delete VMFS Datastore: The Resource Is in Use

During the migration of virtual machines files from an old HP MSA 2000 storage to a new storage system Dell EMC Unity (both connected to ESXi hosts over SAN) I have come across a problem when trying to remove an empty VMFS Datastore in VMWare vSphere. When trying to unmount the VMFS Datastore from ESXi hosts, an error message appears saying that the datastore is still in use / busy:

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

Cannot unmount VMFS Datastore The resource s in use

Based on the error, it is clear that the VMFS datastore cannot be removed since ESXi hosts or vSphere are still using storage to write some data. According to the VMWare documentation, when removing LUN from vSphere you should check the following points:

  • There are no virtual machine, template, snapshot or ISO image files on VMFS datastore (you must migrate your VMs to another VMFS Datastore, power off and remove them, or unregister VMs in vSphere);
  • Storage I/O Control is disabled for datastore;
  • The datastore is not a part of the Datastore Cluster;
  • The LUN is not used as an RDM device;
  • 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.

The virtual machines have already been moved to a new datastore using Storage vMotion. Let’s see what other files and folders remain on the VMFS datastorage:

system files on vmfs: logdir, sdd.sf? dbsData and naa…

As you can see, there are logdir (a directory with logs), sdd.sf (a directory with the description of SCSI devices), dbsData (a directory with the data of the distributed virtual switch) and naa… (VMFS metadata) folders remained.

In my case, ESXi host logs  are still located in the VMFS datastore (Scratch Location). Check out if the datastore is specified as a location of logs in the ESXi host settings. Go to Manage -> Settings -> Advanced System Settings. Find ScratchConfig.CurrentScratchLocation and Syslog.global.logDir and if your VMFS datastore is specified in it, change the path to the logs directory.

ScratchConfig.CurrentScratchLocation and Syslog.global.logDir

Restart the ESXi host or restart the Syslog Server service on the host.

restart syslog on esxi

Let’s try to unmount the datastore from the ESXi host again. Go to Manage -> Storage -> Storage Device. Find your LUN in the list, select it and click Detaches the selected device from the host.

Detaches the selected LUN device from the vmware esxi host

In my case the error occurred again:
Detach SCSI LUN The resource is in use.

Quite for a long time I was trying to find out who uses this datastore and decided that the easiest way in my case was to delete the partition table of VMFS datastore (of course, you should do it very carefully and make sure that you are removing the right datastore).

  1. Connect over SSH to any ESXi host that has VMFS store mounted;
  2. 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: 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. Let’s see how much space is busy on the VMFS datastore (it’s almost empty): df -h | grep MSA2000_LUN1
    VMFS-5 499.8G 1.4G 498.3G 0% /vmfs/volumes/MSA2000_LUN1
     esxcfg-scsidevs 
  4. So we have made sure that the datastore name and the store ID match the LUN that we want to remove;
  5. Now let’s get check information about partition table on your datastore: 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 single partition with the VMFS file system;
  7. Delete the VMFS partition with the ID 1 from this disk (LUN). Please, be very attentive!!!partedUtil delete /vmfs/devices/disks/naa.6001438005df0dee0000700004be0000 1 partedUtil delete vmfs partition

After deleting the partition, you can unmount the LUN in vSphere – Unmount Datastore. The ‘datastore is in use’ error won’t not appear again.

unmount datastore on vmware esxi

Select the ESXi hosts to unmount the datastore from.

select esxi host to unmount datastore

Or you can make Detach from the list of connected storage devices on the ESXi host. The connection state will then change to Detached.

detach lun on esxi host

After that you can remove the VMFS store (Delete Datastore) and it will disappear from vSphere.

Delete Datastore on vmware esxi host

1 comment
1
Facebook Twitter Google + Pinterest
previous post
RDP Authentication Error: CredSSP Encryption Oracle Remediation
next post
How to View and Parse WindowsUpdate.log on Windows 10 / Windows Server 2016?

Related Reading

Reset Root Password in VMware ESXi

October 12, 2023

How to Fix ‘An Operating System Wasn’t Found’...

July 14, 2023

Unmounting an NFS Datastore from VMware ESXi

April 21, 2023

How to Increase Virtual Machine Disk Size in...

April 6, 2023

How to Install Free VMware Hypervisor (ESXi)

January 24, 2023

1 comment

joishw April 11, 2022 - 5:18 pm

Worked a treat for me, thank you very much!

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • ESXi: Slow Disk Performance on HPE Gen8
  • Windows Server Licensing for Virtual Environments
  • Invalid State of a Virtual Machine on VMWare ESXi
  • Match Windows Disks to VMWare VMDK Files
  • System Logs on ESXi Host are Stored On Non-Persistent Storage
  • Configuring USB Devices Passthrough from VMWare ESXi to a Virtual Machine
  • Selecting the Number of vCPUs and Cores for a Virtual Machine
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top