Clear stale ESX iSCSI targets

During our beta testing of our new VMWare environment, we created various volumes and then deleted them. After removing them from the Equallogic SAN, we found ESX server was still trying to login to those targets. After some research, I stumbled across the following files containing the stale entries:

[root@vmware root]# cd /var/lib/iscsi
[root@vmware iscsi]# ls -la
total 16
drwx——    2 root     root         4096 Dec 17 12:11 .
drwxr-xr-x   11 root     root         4096 Oct 23 09:17 ..
-rw——-    1 root     root          830 Dec 17 11:22 vmkbindings
-rw——-    1 root     root          474 Dec 17 12:16 vmkdiscovery
[root@vmware iscsi]#

Put the host into maintenance mode, then edit both the /var/lib/iscsi/vmkbindings and /var/lib/iscsi/vmkdiscovery files to remove the stale entries. Reboot the host and exit maintenance mode. Lastly, rescan the HBA:

esxcfg-swiscsi -s

Repeat for all hosts that are attempting to use the stale entries.