Loading

×Sorry to interrupt
CSS Error

Refresh

Cookie Preference Center

General Information on cookies

When you visit our website, we use cookies to ensure that we give you the best experience. This information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies by clicking on the different category headings to find out more and change your settings. However, blocking some types of cookies may impact your experience on the site and the services we are able to offer. Further information can be found in our

Cookie Policy.

Strictly Necessary

Strictly Necessary

Always Active

Strictly Necessary

Strictly necessary cookies are always enabled since they are essential for our website to function. They enable core functionality such as security, network management, and website accessibility. You can set your browser to block or alert you about these cookies, but this may affect how the website functions. For more information please visit www.aboutcookies.org or www.allaboutcookies.org.

Cookie Details‎

Performance

Performance

Performance

Performance cookies are used to analyze the user experience to improve our website by collecting and reporting information on how you use it. They allow us to know which pages are the most and least popular, see how visitors move around the site, optimize our website and make it easier to navigate.

Cookie Details‎

Please confirm your settings by refreshing the page.

Functional

Functional

Functional

Functional cookies help us keep track of your past browsing choices so we can improve usability and customize your experience. These cookies enable the website to remember your preferred settings, language preferences, location and other customizable elements such as font or text size. If you do not allow these cookies, then some or all of these services may not function properly.

Cookie Details‎

Advertising

Advertising

Advertising

Advertising cookies are used to send you relevant advertising and promotional information. They may be set through our site by third parties to build a profile of your interests and show you relevant advertisements on other sites. These cookies do not directly store personal information, but their function is based on uniquely identifying your browser and internet device.

Cookie Details‎

Advertising Cookies

Consent Leg.Interest

Select All Vendors

Select All Vendors

Select All Hosts

Select All

Clear Filters

Information storage and access

Apply

Confirm My Choices Reject All Allow All

My Subscriptions

Loading

Knowledge Base

How to detach a LUN device from ESXi hosts (2004605)

Last Updated: 4/20/2023Categories: Best PracticesTotal Views: 119180Language:
Chinese (Simplified)Portuguese (European)JapaneseSpanishEnglishGerman

59 like this article

Subscribe to get an email
newsletter with new updates

59 people found this helpful Please provide article feedback:

Learn how VMware Skyline Advisor and Skyline Health Diagnostics work together to provide proactive intelligence and self-service log analysis.

Use Skyline Advisor to avoid issues before they occur across VCF, vSphere, vSAN, NSX, vROps & Horizon. Skyline Findings are based on top KBs, VMSAs/CVEs and design best practices.

Use Skyline Health Diagnostics to root cause vSphere & vSAN logs when an issue occurs. Skyline Health Diagnostic Findings are based on top KBs and VMSA/CVEs. You can use the Skyline Health Diagnostics tool in online or offline mode.

If you require additional help from technical support, please use Skyline Advisor to initiate a Log Assist to reduce time to upload logs. TSEs can also initiate logs to reduce effort.

Symptoms

You cannot unmount a datastore using the vSphere Client.

You see the error:

Cannot unmount volume Datastore_details because Reason. Correct the problem and retry the operation.

Where reason can be any of these:

One or more virtual machines are still registered on it

Swap to host cache is enabled on it

Storage I/O Control is either enabled or running in statistics collection mode on it

File system is busy

Purpose

This article provides steps to unmount a LUN from an ESXi 6.x/7.x host, which includes unmounting the file system and detaching the datastore/storage device. These steps must be performed for each ESXi host.

Note: The documented method using the vSphere Client is limited to detaching the device on a per-host basis. To detach a storage device from multiple hosts at the same time, see Automating detaching datastores using PowerCLI and the vSphere SDK for Perl in the Resolution section in this article.

Resolution

Pre-unmount checklist

If the LUN is being used as a VMFS datastore, all objects (for example, virtual machines, templates, and Snapshots) stored on the VMFS datastore must be unregistered or moved to another datastore.

vCLS VMs will need to be migrated to another datastore or Retreat Mode enabled to safely remove the vCLS VM. See Unmounting or detaching a VMFS, NFS and vVols datastore fails (80874)

Note that vCLS VMs are not visible under the Hosts and Clusters view in vCenter

All CD/DVD images located on the VMFS datastore must also be unmounted/unregistered from the virtual machines.

The datastore is not used for vSphere HA heartbeat.

The datastore is not part of a datastore cluster.

The datastore is not managed by Storage DRS.

The datastore is not configured as a diagnostic coredump Partition/File and Scratch Partition. For more information, see the following:

Configuring a diagnostic coredump partition on an ESXi 5.x host (2004299)

Configuring ESXi coredump to file instead of partition (2077516)

Creating a persistent scratch location for ESXi 7.x/6.x/5.x/4.x (1033696)

Storage I/O Control is disabled for the datastore.

No third-party scripts or utilities running on the ESXi host can access the LUN that has issue. If the LUN is being used as a datastore, unregister all objects (such as virtual machines and templates) stored on the datastore.

If the LUN is being used as an RDM, remove the RDM from the virtual machine. Click Edit Settings, highlight the RDM hard disk, and click Remove. Select Delete from disk if it is not selected and click OK.

Note: This destroys the mapping file but not the LUN content.

Check that there are no processes locking the VMFS with this command: esxcli storage core device world list -d

For example:

[root@esxi:~] esxcli storage core device world list -d naa.6589cfc000000080160d5180d713aae5

Device                                World ID  Open Count  World Name

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

naa.6589cfc000000080160d5180d713aae5     65575           1  idle0

naa.6589cfc000000080160d5180d713aae5     67003           1  sdrsInjector

naa.6589cfc000000080160d5180d713aae5     67080           1  storageRM

Check if the LUN/datastore is used as the persistent scratch location for the host. For more information on persistent scratch, see Creating a persistent scratch location for ESXi 7.x/6.x (1033696).

Note: When using the vSphere Client with vSphere 6.x and later, only these checks are performed during the datastore unmount operation:

Host should not have any virtual machines residing on this datastore

Host should not use the datastore for HA heartbeats

Obtaining the NAA ID of the LUN to be removed

From the vSphere Client

This information is visible in the Properties window of the datastore.

From the ESXi host

Run this command:
esxcli storage vmfs extent list

For example:

esxcli storage vmfs extent list
Volume Name VMFS UUID Extent Number Device Name Partition
----------- ----------------------------------- ------------- ------------------------------------ ---------
datastore1 4de4cb24-4cff750f-85f5-0019b9f1ecf6 0 naa.6001c230d8abfe000ff76c198ddbc13e 3
Storage2 4c5fbff6-f4069088-af4f-0019b9f1ecf4 0 naa.6001c230d8abfe000ff76c2e7384fc9a 1
Storage4 4c5fc023-ea0d4203-8517-0019b9f1ecf4 0 naa.6001c230d8abfe000ff76c51486715db 1
LUN01 4e414917-a8d75514-6bae-0019b9f1ecf4 0 naa.60a98000572d54724a34655733506751 1

Make a note of the NAA ID of the datastore to use this information later in this procedure.

Note: Alternatively, you can run the esxcli storage filesystem list command, which lists all file systems recognized by the ESXi host.

Unmount and Detach a LUN using the vSphere Client

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:

If the LUN is an RDM, continue on step 2. Otherwise, in the Configuration tab of the ESXi host, click Storage. Right-click the datastore being removed and click Unmount.

A Confirm Datastore Unmount window appears. When the prerequisite criteria have been passed, click OK.

Select a ESXi host and click the Storage view under Configure > Storage Devices:

Note: Screenshot below is from a HTML5 vSphere Client environment.

Right-click the NAA ID of the LUN (as noted above) and click Detach. A Confirm Device Unmount window is displayed. When the prerequisite criteria are passed, click OK. Under the Operational State of the Device, the LUN is listed as Unmounted.

Note: The Detach function must be performed on a per-host basis and does not propagate to other hosts in vCenter Server. If a LUN is presented to an initiator group or storage group on the SAN, the Detach function must be performed on every host in that initiator group before unmapping the LUN from the group on the SAN. Failing to follow this step results in an all-paths-down (APD) state for those hosts in the storage group on which Detach was not performed for the LUN being unmapped.

Confirm if the LUN is successfully detached. The LUN can then be safely removed from the SAN. For more information, contact your storage array vendor.

Perform a rescan on all ESXi hosts which had visibility to the LUN. The device is automatically removed from the Storage Adapters.

Note: If you are trying to unmount a LUN from a software iscsi based storage array see the the vSphere Documentation page before rescanning.

When the device is detached, it stays in an unmounted state even if the device is re-presented (that is, the detached state is persistent). To bring the device back online, the device must be attached.

If you want the device to permanently decommission from an ESXi host, manually remove the NAA entries from the host configuration:

To list the permanently detached devices, run this command:

esxcli storage core device detached list

You see output similar to:

Device UID State
------------------------------------ -----
naa.50060160c46036df50060160c46036df off
naa.6006016094602800c8e3e1c5d3c8e011 off

To permanently remove the device configuration information from the system, run this command:

esxcli storage core device detached remove -d NAA_ID

For example:

esxcli storage core device detached remove -d naa.50060160c46036df50060160c46036df

Unmount and Detach a LUN using the command line

To unmount a LUN from an ESXi 6.x/7.x host using the command line:

If the LUN is an RDM, skip to step 4. Otherwise, to obtain a list of all datastores mounted to an ESXi host, run this command:

esxcli storage filesystem list

You see output, which lists all VMFS datastores, similar to:

Mount Point Volume Name UUID Mounted Type Size Free
------------------------------------------------- ----------- ----------------------------------- ------- ------ ----------- -----------
/vmfs/volumes/4de4cb24-4cff750f-85f5-0019b9f1ecf6 datastore1 4de4cb24-4cff750f-85f5-0019b9f1ecf6 true VMFS-5 140660178944 94577360896
/vmfs/volumes/4c5fbff6-f4069088-af4f-0019b9f1ecf4 Storage2 4c5fbff6-f4069088-af4f-0019b9f1ecf4 true VMFS-3 146028888064 7968129024
/vmfs/volumes/4c5fc023-ea0d4203-8517-0019b9f1ecf4 Storage4 4c5fc023-ea0d4203-8517-0019b9f1ecf4 true VMFS-3 146028888064 121057050624
/vmfs/volumes/4e414917-a8d75514-6bae-0019b9f1ecf4 LUN01 4e414917-a8d75514-6bae-0019b9f1ecf4 true VMFS-5 146028888064 4266131456

To find the unique identifier of the LUN housing the datastore to be removed, run this command:

esxcfg-scsidevs -m

This command generates a list of VMFS datastore volumes and their related unique identifiers. Make a note of the unique identifier (NAA_ID) for the datastore you want to unmount as this will be used later on.

For more information on the esxcfg-scsidevs command, see Identifying disks when working with VMware ESXi (1014953) .

Unmount the datastore by running this command:

esxcli storage filesystem unmount [-u UUID | -l label | -p path ]

For example, use one of these commands to unmount the LUN01 datastore:

esxcli storage filesystem unmount -l LUN01
esxcli storage filesystem unmount -u 4e414917-a8d75514-6bae-0019b9f1ecf4
esxcli storage filesystem unmount -p /vmfs/volumes/4e414917-a8d75514-6bae-0019b9f1ecf4

Note: If the VMFS filesystem you are attempting to unmount has active I/O or has not fulfilled the prerequisites to unmount the VMFS datastore, you see an error in the VMkernel logs similar to:

WARNING: VC: 637: unmounting opened volume ('4e414917-a8d75514-6bae-0019b9f1ecf4' 'LUN01') is not allowed.
VC: 802: Unmount VMFS volume f530 28 2 4e414917a8d7551419006bae f4ecf19b 4 1 0 0 0 0 0 : Busy

To verify that the datastore is unmounted, run this command:

esxcli storage filesystem list

You see output similar to:

Mount Point Volume Name UUID Mounted Type Size Free
------------------------------------------------- ----------- ----------------------------------- ------- ------ ----------- -----------
/vmfs/volumes/4de4cb24-4cff750f-85f5-0019b9f1ecf6 datastore1 4de4cb24-4cff750f-85f5-0019b9f1ecf6 true VMFS-5 140660178944 94577360896
/vmfs/volumes/4c5fbff6-f4069088-af4f-0019b9f1ecf4 Storage2 4c5fbff6-f4069088-af4f-0019b9f1ecf4 true VMFS-3 146028888064 7968129024
/vmfs/volumes/4c5fc023-ea0d4203-8517-0019b9f1ecf4 Storage4 4c5fc023-ea0d4203-8517-0019b9f1ecf4 true VMFS-3 146028888064 121057050624
LUN01 4e414917-a8d75514-6bae-0019b9f1ecf4 false VMFS-unknown version 0 0

The Mounted field is set to false, the Type field is set to VMFS-unknown version, and that no Mount Point exists.

Note: The unmounted state of the VMFS datastore persists across reboots. This is the default behavior. If you need to unmount a datastore temporarily, you can do so by appending the --no-persist flag to the unmount command.

To detach the device/LUN, run this command:

esxcli storage core device set --state=off -d NAA_ID

To verify that the device is offline, run this command:

esxcli storage core device list -d NAA_ID

You see output, which shows that the Status of the disk is off, similar to:

naa.60a98000572d54724a34655733506751
Display Name: NETAPP Fibre Channel Disk (naa.60a98000572d54724a34655733506751)
Has Settable Display Name: true
Size: 1048593
Device Type: Direct-Access
Multipath Plugin: NMP
Devfs Path: /vmfs/devices/disks/naa.60a98000572d54724a34655733506751
Vendor: NETAPP
Model: LUN
Revision: 7330
SCSI Level: 4
Is Pseudo: false
Status: off
Is RDM Capable: true
Is Local: false
Is Removable: false
Is SSD: false
Is Offline: false
Is Perennially Reserved: false
Thin Provisioning Status: yes
Attached Filters:
VAAI Status: unknown
Other UIDs: vml.020000000060a98000572d54724a346557335067514c554e202020

Running the partedUtil getptbl command on the device shows that the device is not found.

For example:

partedUtil getptbl /vmfs/devices/disks/naa.60a98000572d54724a34655733506751

Error: Could not stat device /vmfs/devices/disks/naa.60a98000572d54724a34655733506751 - No such file or directory.
Unable to get device /vmfs/devices/disks/naa.60a98000572d54724a34655733506751

If the device is to be permanently decommissioned, it is now possible to unpresent the LUN from the SAN. For more information, contact your storage team, storage administrator, or storage array vendor.

To rescan all devices on the ESXi host, run this command:

esxcli storage core adapter rescan [ -A vmhba# | --all ]

The devices are automatically removed from the Storage Adapters.

Notes:

A rescan must be run on all hosts that had visibility to the removed LUN.

When the device is detached, it stays in an unmounted state even if the device is re-presented (that is, the detached state is persistent). To bring the device back online, the device must be attached. To do this via the command line, run this command:

esxcli storage core device set --state=on -d NAA_ID

If the device is to be permanently decommissioned from an ESXi host, (that is, the LUN has been or will be destroyed), remove the NAA entries from the host configuration by running these commands:

To list the permanently detached devices:

esxcli storage core device detached list

You see output similar to:

Device UID State
---------------------------- -----
naa.50060160c46036df50060160c46036df off
naa.6006016094602800c8e3e1c5d3c8e011 off

To permanently remove the device configuration information from the system:

esxcli storage core device detached remove -d NAA_ID

For example:

esxcli storage core device detached remove -d naa.50060160c46036df50060160c46036df

The reference to the device configuration is permanently removed from the ESXi host's configuration.

Note: If the device is detached but still presented (step 7 was skipped), the preceding command fails to permanently remove the device from the system, and the device is automatically re-attached. You must complete step 7 for the device to be permanently removed.

Notes:

After detaching the LUN, it can be as not presented from the storage. However, if you run the esxcli storage core device detached remove -d NAA_ID command 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 this you will still experience vCenter storage connectivity alarms. It would be advantageous to disable the alarm when carrying out these tasks.

Related Information

VMware Skyline Health Diagnostics for vSphere - FAQ

For more information, see Best Practice: How to correctly remove a LUN from an ESX host.

If the LUN you are attempting to remove is flagged as perennially reserved, to prevent it causing host boot delays. The perennially reserved flag can prevent a successful unmount of the LUN.

To remove the perennially reserved flag, run this command to remove the flag:

esxcli storage core device setconfig -d $device --perennially-reserved=false

Then run this command to retry removal of the device:

esxcli storage core device detached remove -d $device

Note: There is no negative impact in setting the flag to false, even when it is not needed.

For more information about the perennially reserved flag, see ESXi/ESX hosts with visibility to RDM LUNs being used by MSCS nodes with RDMs may take a long time to start or during LUN rescan (1016106).

简体中文：如何从ESXi 主机卸载 LUN 或分离数据存储设备

Identifying disks when working with VMware ESXi/ESX
ESXi/ESX hosts with visibility to RDM LUNs being used by MSCS nodes with RDMs may take a long time to start or during LUN rescan
Unable to remove an inaccessible NFS datastore with Storage I/O control enabled
ESXi ホストから LUN をアンマウントまたはデータストア デバイスを接続解除する方法
使用中の Micron PCIe SSD のホットリムーブに失敗する
Como desmontar um LUN ou desanexar um dispositivo repositório de dados de hosts ESXi
Cómo desmontar un LUN o desasociar un dispositivo de almacén de datos de los hosts ESXi
Unmounten einer LUN oder Trennen eines Datenspeichers/Speichergeräts von mehreren VMware ESXi 5.x/6.0-Hosts

Detectable by VMware SkylineTM

Actions

Copy

link to clipboard
copied!

Print

Language:
Chinese (Simplified)Portuguese (European)JapaneseSpanishEnglishGerman

Attachments

Additional Resources

KB
•
Unmounting or detaching a VMFS, NFS and vVols datastore fails (80874)

Result 1 of 1

Ask The Community

Get answers quickly from VMware experts in the community

Post Subject

CONTINUE IN COMMUNITIES

Related Products:

VMware vSphere ESXi

Related Versions:

VMware vSphere ESXi 7.0.0

VMware vSphere ESXi 6.7

VMware vSphere ESXi 6.5

VMware vSphere ESXi 6.0

Take Our Survey

Support Assistant