This article provides steps to unmount a LUN from an ESXi host, which includes unmounting the file system and detaching the datastore/storage device. These steps must be performed for each ESXi host.
Cannot unmount volume Datastore_details because Reason. Correct the problem and retry the operation.
Where reason can be any of these:
Detach SCSI Lun failed! Cannot change the host configuration.VMware vSphere ESXi (All Versions)
[root@esxi:~] esxcli storage core device world list -d naa.6589cfc00000008016##############This information is visible in the Properties window of the datastore.
Run this command:
esxcli storage vmfs extent list
For example:esxcli storage vmfs extent listVolume Name VMFS UUID Extent Number Device Name Partition----------- ----------------------------------- ------------- ------------------------------------ ---------datastore1 4de4cb24-########-####-##########f6 0 naa.6001c230d8abfe000f############## 3Storage2 4c5fbff6-########-####-##########f4 0 naa.6001c230d8abfe000ff############# 1Storage4 4c5fc023-########-####-##########f4 0 naa.6001c230d8abfe000ff7############ 1LUN01 4e414917-########-####-##########f4 0 naa.60a98000572d54724a34############ 1
Make a note of the NAA ID of the datastore to use this information later in this procedure.
Note: Alternatively, run the esxcli storage filesystem list command, which lists all file systems recognized by the ESXi host.
Note: These steps to not apply to the vSphere Web Client or HTML5 client.
To unmount a LUN from an ESXi host using the vSphere Client:
esxcli storage core device detached listDevice UID State------------------------------------ -----naa.50060########################## offnaa.60060########################## offesxcli storage core device detached remove -d naa.50060#########################To unmount a LUN from an ESXi 6.x/7.x/8.x host using the command line:
esxcli storage filesystem listMount Point Volume Name UUID Mounted Type Size Free------------------------------------------------- ----------- ----------------------------------- ------- ------ ------------ -----------/vmfs/volumes/4de4cb24-########-####-########f6 datastore1 4de4cb24-########-####-########f6## true VMFS-5 140660178944 94577360896/vmfs/volumes/4c5fbff6-########-####-##########f4 Storage2 4c5fbff6-########-####-##########f4 true VMFS-3 146028888064 7968129024/vmfs/volumes/4c5fc023-########-####-#########f4 Storage4 4c5fc023-########-####-##########f4 true VMFS-3 146028888064 121057050624/vmfs/volumes/4e414917-########-####-########f4 LUN01 4e414917-########-####-##########f4 true VMFS-5 146028888064 4266131456esxcfg-scsidevs -mesxcli storage filesystem unmount [-u UUID | -l label | -p path ]esxcli storage filesystem unmount -l LUN01esxcli storage filesystem unmount -u 4e414917-########-####-##########f4esxcli storage filesystem unmount -p /vmfs/volumes/4e414917-########-####-########f4esxcli storage filesystem listMount Point Volume Name UUID Mounted Type Size Free------------------------------------------------- ----------- ----------------------------------- ------- ------ ------------ -----------/vmfs/volumes/4de4cb24-########-####-########f6 datastore1 4de4cb24-########-####-########f6## true VMFS-5 140660178944 94577360896/vmfs/volumes/4c5fbff6-########-####-##########f4 Storage2 4c5fbff6-########-####-##########f4 true VMFS-3 146028888064 7968129024/vmfs/volumes/4c5fc023-########-####-#########f4 Storage4 4c5fc023-########-####-##########f4 true VMFS-3 146028888064 121057050624/vmfs/volumes/4e414917-########-####-########f4 LUN01 4e414917-########-####-##########f4 true VMFS-unknown version 0 0 esxcli storage core device set --state=off -d NAA_IDesxcli storage core device list -d NAA_IDnaa.60#########################Display Name: NETAPP Fibre Channel Disk (naa.60#########################)Has Settable Display Name: trueSize: 1048593Device Type: Direct-AccessMultipath Plugin: NMPDevfs Path: /vmfs/devices/disks/naa.60#########################Vendor: NETAPPModel: LUNRevision: 7330SCSI Level: 4Is Pseudo: falseStatus: offIs RDM Capable: trueIs Local: falseIs Removable: falseIs SSD: falseIs Offline: falseIs Perennially Reserved: falseThin Provisioning Status: yesAttached Filters:VAAI Status: unknownOther UIDs: vml.020000000060a#####################################################partedUtil getptbl /vmfs/devices/disks/naa.60a##########################esxcli storage core adapter rescan [ -A vmhba# | --all ]esxcli storage core device detached listDevice UID State---------------------------- -----naa.50060########################## offnaa.60060########################## offesxcli storage core device detached remove -d NAA_IDesxcli storage core device detached remove -d naa.50060##########################Notes:
After detaching the LUN, it can be as not presented from the storage. However, if the esxcli storage core device detached remove -d NAA_ID command is run to permanently decommission the LUN from the ESXI host before removing the LUN from the storage, the LUN gets reattached to the host and must be detached again.
While following these steps, vCenter storage connectivity alarms will still be seen. It would be advantageous to disable the alarm when carrying out these tasks.
If LUN detach is executed from vSphere Client and if the LUN was presented to multiple hosts, it may take a long time to detach the LUN. In these cases, manual LUN detach can be executed parallelly across multiple hosts where the LUN is presented, either via CLI or the host web client. This would significantly improve the time taken to detach the LUN from all hosts.
esxcli storage core device setconfig -d $device --perennially-reserved=false
esxcli storage core device detached remove -d $device