-
Check List: Ensure the following
-
If the LUN is being used as a VMFS datastore, all objects (such as virtual machines and templates) stored on the VMFS Datastore are unregistered or moved to another datastore.
- Note: All CD/DVD images located on the VMFS datastore must also be unregistered from the virtual machines.
- The datastore is not part of a datastore cluster.
- The datastore is not managed by Storage DRS
- Storage I/O Control is disabled for the datastore.
- The datastore is not used for vSphere HA heartbeat.
-
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 select Remove. Ensure that Delete from disk is selected and click OK.
- Note: This destroys the mapping file, but not the LUN content.
- No third party scripts or utilities running on the ESXi host can access the LUN in question.
-
vSphere Client Method
-
Get the NAA ID of the LUN to be removed
- From the vSphere Client, this information is visible from the Properties window of the datastore.
-
Unpresent the LUN from an ESXi 5.0 host
-
In the Configuration tab of the ESXi host, click Storage. Right-click on the datastore being removed, and click Unmount.
- A "Confirm Datastore Unmount" window appears. When the prerequisite criteria have been passed, click OK.
- Note: To umount a datastore from multiple hosts, from the vSphere Client select Hosts and Clusters, Datastores and Datastore Clusters view (Ctrl+Shift+D). Perform the umount task and select the appropriate hosts that should no longer access the datastore to be unmounted.
- Choose the Devices View (Under Configuration > Storage)
-
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 have been passed, click OK.
- Under the Operational Status of the Device, the LUN will be listed as Unmounted.
- The LUN can now be unpresented from the SAN. For more information, contact your storage array vendor.
- Perform a rescan on all of the ESXi hosts that had visibility to the LUN. The device is automatically removed from the Storage Adapters.
- When the device is detached, it stays in an unmounted state even if the device is represented (that is, the detached state is persistent). To bring the device back online, the device needs to be attached.
-
If the device is to be permanently decommissioned from an ESXi servers(s) , you may have to manually remove the naa entries from the host configuration by issuing these commands:
- To list the permanently detached devices: # esxcli storage core device detached list
- To permanently remove the device configuration information from the system: # esxcli storage core device detached remove -d <NAA ID>
-
esxcli Method
- To get a list of all datastores mounted to an ESXi host, run the command: # esxcli storage filesystem list
-
Unmount the datastore by running the command: # esxcli storage filesystem unmount [-u <UUID> | -l <label> | -p <path> ]
- Note: If the VMFS fileystem that you are attempting to unmount has active I/O or has not fulfilled the prerequisites to unmount the VMFS datastore, the vmkernel logs show an error.
-
To verify that the datastore has been unmounted, run the command: # esxcli storage filesystem list
- Note that 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 behaviour. However, it can be changed by appending the --no-persist flag.
- 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>
- The LUN can now be unpresented from the SAN. For more information, contact your storage array vendor.
-
To rescan all devices on the ESXi host, run the command: # esxcli storage core adapter rescan [ -A vmhba# | --all ]
- The device are automatically removed from the Storage Adapters.
- Note: A rescan needs to be run on all hosts that had visibility of the removed LUN.
- Note: When the device is detached, it stays in an unmounted state even if the device is represented (that is, the detached state is persistent). To bring the device back online, the device needs to be attached. To do this via the command-line, run the command: # esxcli storage core device set --state=on -d <NAA ID>
-
If the device is to be permanently decommissioned from an ESXi servers(s), (that is, the LUN has been destroyed), remove the naa entries from the host configuration by issuing the following set of commands:
- To list the permanently detached devices: # esxcli storage core device detached list
- To permanently remove the device configuration information from the system: # esxcli storage core device detached remove -d <NAA ID>
- The reference to the device configuration is permanently removed from the ESXi host's configuration.
-
PowerCLI Method
- Alan Renouf has created a set of functions to allow you to unmount/mount and detach/attach datastores from multiple hosts.
- List all datastores and their mount/detach status by passing your datastore object(s) into the Get-DatastoreMountInfo advanced function.
- To unmount a datastore pass your datastore object(s) to the Unmount-Datastore advanced function as seen below, this will unmount the datastore from all attached hosts.
- Once unmounted you will then be able to detach the datastore from the hosts using the Detach-Datastore cmdlet.