Detaching Devices and Removing a LUN
Before you can remove a LUN, you must detach the corresponding device by using the vSphere Client or the esxcli storage core device set command. Detaching a device brings a device offline. Detaching a device does not impact path states. If the LUN is still visible, the path state is not set to dead.
To detach a device and remove a LUN
1
For information on migrating virtual machines, see the vCenter Server and Host Management documentation.
2
If the unmount fails, ESXCLI returns an error. If you ignore that error, you will get an error in step 4 when you attempt to detach a device with a VMFS partition still in use.
3
esxcli storage core device world list -d <device>
If a VMFS volume is using the device indirectly, the world name includes the string idle0. If a virtual machine uses the device as an RDM, the virtual machine process name is displayed. If any other process is using the raw device, the information is displayed.
4
esxcli storage core device set -d naa.xxx... --state=off
Detach is persistent across reboots and device unregistration. Any device that is detached remains detached until a manual attach operation. Rescan does not bring persistently detached devices back online. A persistently detached device comes back in the off state.
ESXi maintains the persistent information about the device’s offline state even if the device is unregistered. You can remove the device information by running esxcli storage core device detached remove -d naa.12.
5
esxcli storage core device detached list
6
esxcli <conn_options> storage core adapter rescan
When you have completed storage reconfiguration, you can reattach the storage device, mount the datastore, and restart the virtual machines.
To reattach the device
1
esxcli storage core device detached list
2
esxcli storage core device set -d naa.XXX --state=on
3