Remove ISCSI sessions using the Linux command line

SUMMARY

Necessary commands to remove an ISCSI session

ISSUE

Under certain circumstances, an ISCSI session may persist even after it has been removed from the storage menu of the Unitrends appliance. In order to prevent the Unitrends appliance from reconnecting to these sessions, these commands may be necessary. 

When trying to remove the session, you may receive an error message like:

Failed to destroy the image: tgtadm: this access control rule does not exist
tgtadm: can't find the logical unit
tgtadm: can't find the logical unit
tgtadm: this target is still active
Could not delete iSCSI target 7. Ensure that no iSCSI initiator is connected to the target. Session connected from iqn.9999-11.com.unitrends:aa1ab4ad66df 127.0.0.1

A customer may also see iscsid errors on the console screen at boot time indicating connection attempts to a particular iscsi target are failing, which may lead to delayed boot time.  

RESOLUTION

Use an SSH client such as  PuTTY to access the Unitrends system at the command line level.  Note:  Ensure you have the OS password to access the Unitrends system’s command line.  The OS  password may differ from the password used to access the User Interface.

Kill an ISCSI session:

iscsiadm -m node -T <iqn> -p <ip address>:<port number> -u


When run, the command should look something like this:

iscsiadm -m node -T iqn.52425-1.com.unitrends:UNI.target-25a74d1 -p 10.10.10.10:3260 -u


To prevent the session from re-establishing, you may wish to remove the node:

iscsiadm -m node -o delete -T <iqn>


Once this is complete, make sure the session is no longer listed:

iscsiadm -m session

If required, you can also delete the targets from the ISCSI discovery database entirely.

iscsiadm -m discoverydb -t sendtargets -p <IP>:<port> -o delete

Finally, it is necessary to check the file system to ensure Linux does not try to re-establish the connection on future boot operations.
 

ls /var/lib/iscsi/nodes/<iqn>

If the iqn exists, it should be deleted.  It may be necessary to edit this node object to remove specific IPs from its listings without modifying the node itself if a customer has changed the IP of their ISCSI targets but the IQN remains valid.  This can be done by navigating the node folder and reviewing and selectively deleting objects related to the invalid IP addresses.  



Another way can do this is as follows:  

  1. Identify the sessions that are still open: 
    1. iscsiadm -m session
  2.  Find the one with unitrends.dpu in it. 
  3. Then run iscsiadm -m node -T <iqn> -p <ip address>:<port number> -u
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Contact us