vCenter Troubleshooting TIPS : HOW TO Delete and detach properly iSCSI volumes manually in a ESXi Shell

Luciano PatrãoICT Senior Infraestructure  Engineer  
CERTIFIED EXPERT
vExpert vSAN, NSX, Cloud Provider, Veeam Vanguard, Virtual Backups, and Storage design, and an active blogger.
Published:
In this article we will look HOW TO detach and delete properly iSCSI volumes manually from ESXi. This article will focus in how to on ESXi Shell only.

Note: Before we start, some VMware official information and technical details you can get in the VMware KB 1014953

Migrate or backup any data you should have inside of the Volumes you want to delete/detach. For this task and to be on the safe side, we recommend do this in maintenance mode, but it is not mandatory.

Connect the host (where we want to delete/detach the volumes) and use ESXi Shell. For deleting or detaching Volumes (disk and Logical Unit Numbers) we need to collect disk and LUN information from within ESX i(naa, iqn and Datastore names and numbers, etc.)

First we will collect .naa id using the command:
esxcli storage vmfs extent list

Open in new window

We will remove the LUN (Datastore) called Storage-001 and clean all iSCSI connections etc.

This is the information I get and that we will use for this article:
~ # esxcli storage vmfs extent list
                      Volume Name  VMFS UUID                            Extent Number  Device Name                           Partition
                      -----------  -----------------------------------  -------------  ------------------------------------  ---------
                      Storage-001  54b7c326-6204faef-6719-e839351060ad              0  naa.6090a06860d40e5a524b15ae2bc3c366          1

Open in new window

In this case our Volume is Storage-001 and the naa id is naa.6090a06860d40e5a524b15ae2bc3c366

1. Unmount the Volume(file system) from the host:

# esxcli storage filesystem unmount -l Storage-001

Open in new window

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.

2. Disable the iSCSI Device(using naa id):

# esxcli storage core device set --state=off -d naa.6090a06860d40e5a524b15ae2bc3c366

Open in new window

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

Open in new window

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.

3. Remove the discovery address from the Static Discovery in the iSCSI Initiator:

# esxcli iscsi adapter discovery sendtarget remove --adapter=vmhba37 --address='10.10.10.33:3260'

Open in new window

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

Open in new window

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

Open in new window

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

Open in new window

4. Remove iSCSI target session:

# esxcli iscsi session remove -A vmhba37 -n iqn.2001-05.com.equallogic:0-8a0906-5a0ed4606-66c3c32bae154b52-storage-001

Open in new window

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

Open in new window

You should see no output after the command.

Now for the final cleanup, we need to check the detached device list and remove any entries for the volume that we removed/detached using:
~ # esxcli storage core device detached list
                      
                      Device UID                            State
                      
                      ------------------------------------  -----
                      
                      naa.6090a06860d40e5a524b15ae2bc3c366  off

Open in new window


If it is empty, you can bypass this step and finish.

6. Check and clean the device detached list:
 
# esxcli storage core device detached remove -d naa.6090a06860d40e5a524b15ae2bc3c366

Open in new window


Check the device detached list again and see if is empty. Note: You can use some of this commands that we present in this article to to clean some old detached Volumes that are still around in your VMware environment from a non good cleaning. 
After this you can now delete the Volume in your Storage.

This is the Third of "TIP Articles" that I plan to write when I have some time. So, please vote "Helpful" on this Article. And I encourage your comments and feedback.
0
1,825 Views
Luciano PatrãoICT Senior Infraestructure  Engineer  
CERTIFIED EXPERT
vExpert vSAN, NSX, Cloud Provider, Veeam Vanguard, Virtual Backups, and Storage design, and an active blogger.

Comments (1)

Luciano PatrãoICT Senior Infraestructure  Engineer  
CERTIFIED EXPERT

Author

Commented:
Yes that was one of the reasons that I give up writing articles in EE.

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

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.