esxcli storage vmfs extent list
We will remove the LUN (Datastore) called Storage-001 and clean all iSCSI connections etc.
~ # esxcli storage vmfs extent list
Volume Name VMFS UUID Extent Number Device Name Partition
----------- ----------------------------------- ------------- ------------------------------------ ---------
Storage-001 54b7c326-6204faef-6719-e839351060ad 0 naa.6090a06860d40e5a524b15ae2bc3c366 1
In this case our Volume is Storage-001 and the naa id is naa.6090a06860d40e5a524b15# esxcli storage filesystem unmount -l Storage-001
After this you can connect to your Storage Administration and put the Volume offline. If you put your Volume offline, you can bypass the step 2 and move to step 3.
# esxcli storage core device set --state=off -d naa.6090a06860d40e5a524b15ae2bc3c366
Next we need to know which iSCSI adapter we are using and also which iSCSI server (sendtarget) is in the Static Discover so that we can remove it also.
~ # esxcli iscsi adapter discovery sendtarget list
Adapter Sendtarget
------- ---------------
vmhba37 10.10.10.33:3260
Note step 3: Do this step only if you want to delete completely this Storage from your VMware environment. If you have more than one Volumes from this Storage, skip this step and move to step 5.
# esxcli iscsi adapter discovery sendtarget remove --adapter=vmhba37 --address='10.10.10.33:3260'
Next we need to check which iSCSI sessions there are in the target list for the volumes that we want to detach.
~ # esxcli iscsi adapter target portal list
Adapter Target IP Port Tpgt
------- -------------------------------------------------------------------------- ---------- ---- ----
vmhba37 iqn.2001-05.com.equallogic:0-8a0906-5a0ed4606-66c3c32bae154b52-storage-001 10.10.10.33 3260 1
This is the target adapter. List the sessions (since the Best Practice for iSCSI connections is to have two portgroups. For High Availability and multipath purposes we will see two sessions for each Volume). We just need to remove the target. In our case is:
iqn.2001-05.com.equallogic:0-8a0906-5a0ed4606-66c3c32bae154b52-storage-001
Note: The next print screen will have more details, but we will only list the first few lines (the more detailed information is not needed for our tasks):
~ # esxcli iscsi session list
vmhba37,iqn.2001-05.com.equallogic:0-8a0906-5a0ed4606-66c3c32bae154b52-storage-001,00023d000001
Adapter: vmhba37
Target: iqn.2001-05.com.equallogic:0-8a0906-5a0ed4606-66c3c32bae154b52-storage-001
ISID: 00023d000001
vmhba37,iqn.2001-05.com.equallogic:0-8a0906-5a0ed4606-66c3c32bae154b52-storage-001,00023d000002
Adapter: vmhba37
Target: iqn.2001-05.com.equallogic:0-8a0906-5a0ed4606-66c3c32bae154b52-storage-001
ISID: 00023d000002
4. Remove iSCSI target session:
# esxcli iscsi session remove -A vmhba37 -n iqn.2001-05.com.equallogic:0-8a0906-5a0ed4606-66c3c32bae154b52-storage-001
5. Next check if the target was removed and rescan the adapter:
# esxcli storage core adapter rescan --adapter=vmhba37
# esxcli iscsi adapter target portal list and # esxcli iscsi session list
You should see no output after the command.
~ # esxcli storage core device detached list
Device UID State
------------------------------------ -----
naa.6090a06860d40e5a524b15ae2bc3c366 off
# esxcli storage core device detached remove -d naa.6090a06860d40e5a524b15ae2bc3c366
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (1)
Author
Commented:Because writing articles in my blog sometimes the time is not too much, and then need to write again articles here but cannot be the same, is not suitable.
At least for those who are always fighting with time for work, personal projects, family etc
This way is more easy and will not take much time just to copy and do some minor changes.
Thanks again
Luciano