VMware Cloud Community
kendzi87
Enthusiast
Enthusiast

Is there a way to check if datastore is use by the ESXi system?

I am looking for somehow counter, reference or variable for example if let's say isBusy=1 datastore is in use and cannot be deleted if isBusy=0 then it can be safely deleted (this is for automation purpose).

I am looking for these because off  error : "Error: The reason is Call "HostDatastoreSystem.RemoveDatastore" for object "ha-datastoresystem" on ESXi "10.10.1.186" failed.
Cannot remove datastore 'Datastore Name: datastore1 VMFS uuid: 5616aa3a-5fa106ea-b830-6805ca3819fe' because file system is busy."

Reply
0 Kudos
7 Replies
mordi
Enthusiast
Enthusiast

you can check in your script if the filesystem is mounted by using the command : esxcli storage filesystem list

example: check for the "mounted" value

[root@F22-Raptor:~] esxcli storage filesystem list

Mount Point                                        Volume Name            UUID                                 Mounted  Type            Size          Free

-------------------------------------------------  ---------------------  -----------------------------------  -------  ------  ------------  ------------

/vmfs/volumes/57c6de04-4fac85fa-4b81-00505694b691  Replication-Datastore  57c6de04-4fac85fa-4b81-00505694b691     true  VMFS-5  214479929344  168025915392

/vmfs/volumes/57c543a1-b90bd01b-753d-109836a1a1b9  lun0-syslog            57c543a1-b90bd01b-753d-109836a1a1b9     true  VMFS-5   53418655744   52288290816

/vmfs/volumes/57b41aea-fcf34ac6-7f9b-109836a1a1b9  f22_local_dsk2         57b41aea-fcf34ac6-7f9b-109836a1a1b9     true  VMFS-5  499826819072  195510140928

/vmfs/volumes/57ac82fb-8425ab1e-07f6-109836a1a1b9  f22_local_dsk1         57ac82fb-8425ab1e-07f6-109836a1a1b9     true  VMFS-5  492042190848  335503425536

/vmfs/volumes/eff6207d-e323ddd6-e5de-3b0929a28df3                         eff6207d-e323ddd6-e5de-3b0929a28df3     true  vfat       261853184      85811200

/vmfs/volumes/57ac8309-5bf59f04-5325-109836a1a1b9                         57ac8309-5bf59f04-5325-109836a1a1b9     true  vfat      4293591040    4264951808

/vmfs/volumes/cc8c8577-2e33c358-b051-4dbff4e1c3ba                         cc8c8577-2e33c358-b051-4dbff4e1c3ba     true  vfat       261853184     261844992

/vmfs/volumes/57ac82e8-6c08804b-fcb0-109836a1a1b9                         57ac82e8-6c08804b-fcb0-109836a1a1b9     true  vfat       299712512      87310336

[root@F22-Raptor:~]

If you found this or any other answer useful please consider the use of the Helpful or Correct buttons to award points. Mordi Shushan http://vpentathlon.com @mordi_s
Reply
0 Kudos
francsza
Contributor
Contributor

Try the lsof command to check of any files are open on that datastore, e.g.

lsof | grep UUID


This will list any ESX host processes writing to that datastore.

Reply
0 Kudos
kendzi87
Enthusiast
Enthusiast

Sorry for long response. Unfortunately both answers not helped

Reply
0 Kudos
battybishop
Hot Shot
Hot Shot

Try this

Display hosts which are actively using a volume

~ # vmkfstools –activehosts /vmfs/volumes/VNX-20
Found 1 actively heartbeating hosts on volume '/vmfs/volumes/VNX-20'
(1): MAC address 98:4b:e1:0a:24:d8

This option will show the management interface MAC address of any hosts which is actively using a datastore. This is exactly what vSphere HA uses to see if a host is still active. It walks through the heartbeat records on the VMFS and checks which are active. This might take a few moments to run as it has to wait for the heartbeat record to age and refresh. It then it displays the MAC address of the owner.

kendzi87
Enthusiast
Enthusiast

I tried your command:

vmkfstools –activehosts /vmfs/volumes/VNX-20


I assume after VNX-20 is your datastore. I used mine but I am getting:


"Extra arguments at the end of the command line."

Reply
0 Kudos
battybishop
Hot Shot
Hot Shot

Sorry missed a - command should be vmkfstools --activehosts vmfspath

Reply
0 Kudos
kendzi87
Enthusiast
Enthusiast

thanks I am going to check it

Reply
0 Kudos