In an earlier article I discussed the procedure to remove a LUN from an ESXi host. The exact steps are available in this VMware KB article which will be summarized below:
- Confirm the LUN is not used by any virtual machine;
- Unmount the LUN in the vSphere client;
- Detach the LUN from the ESXi host;
- Unmask the LUN on your SAN.
To definite remove the LUN from your ESXi server you should remove the LUN from the detached LUN list as well, this requires three additional step:
- Connect to ESXi shell (through the DCUI or SSH) and enter the following command:
# esxcli storage core device detached list
- Remove the detached volumes from this list:
# esxcli storage core device detached remove -d NAA_ID
- Run a rescan on your HBA
After following this procedure something strange happened: although the LUN was umasked on the SAN, the removed LUN re-appeared.
What was the case? In this case the iSCSI solution (in this case Dell Equallogic) creates a seperate iSCSI target for each iSCSI volume. Despite of unmasking the LUN from the ESXi host, the iSCSI target for this volume was still accessible, which is something I wouldn’t expect. Because the ESXi host still has access to the target, the volume is also still usuable.
After removing the relevant iSCSI target from the static discovery tab in the software iSCSI properties tab, things were solved and worked as expected. Another solution is to reboot the host, this will also remove the not accessible iSCSI targets.
Important note: You can compare the detach option in ESXi 5 with a “server side masking” option. Removing a LUN from ESXi 4 involves some server side LUN masking, because there’s no detach option available. Removing LUNs from the detached device list on ESXi 5, is actually removing the “server side mask”. If you want to reconnect an earlier removed LUN to an ESXi server, the LUN shouldn’t be in the detached device list because the ESXi server will never see your represented LUN!