Ask the Community
Groups
Remove ISCSI sessions using the Linux command line - Connect IT Community | Kaseya
<main> <article class="userContent"> <h2 data-id="summary"><strong>SUMMARY</strong></h2> <p>Necessary commands to remove an ISCSI session</p> <h2 data-id="issue"><strong>ISSUE</strong></h2> <p>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. <br><br>When trying to remove the session, you may receive an error message like:<br><br>Failed to destroy the image: tgtadm: this access control rule does not exist<br>tgtadm: can't find the logical unit<br>tgtadm: can't find the logical unit<br>tgtadm: this target is still active<br>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<br><br>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. </p> <h2 data-id="resolution"><strong>RESOLUTION</strong></h2> <p>Use an SSH client such as <a href="/home/leaving?allowTrusted=1&target=https%3A%2F%2Fwww.chiark.greenend.org.uk%2F%7Esgtatham%2Fputty%2Flatest.html" rel="noopener nofollow">PuTTY</a> to access the Unitrends system at the command line level. <em>Note: Ensure you have the OS password to access the Unitrends system’s command line. The OS </em><a href="https://kaseya.vanillacommunities.com/kb/articles/aliases/unitrends/hc/en-us/articles/360013244978" rel="noopener nofollow">password</a> <em>may differ from the password used to access the User Interface.</em><br><br>Kill an ISCSI session:</p> <pre class="code codeBlock" spellcheck="false" tabindex="0">iscsiadm -m node -T <iqn> -p <ip address>:<port number> -u</pre> <p><br>When run, the command should look something like this:</p> <pre class="code codeBlock" spellcheck="false" tabindex="0">iscsiadm -m node -T iqn.52425-1.com.unitrends:UNI.target-25a74d1 -p 10.10.10.10:3260 -u</pre> <p><br>To prevent the session from re-establishing, you may wish to remove the node:</p> <pre class="code codeBlock" spellcheck="false" tabindex="0">iscsiadm -m node -o delete -T <iqn></pre> <p><br>Once this is complete, make sure the session is no longer listed:</p> <pre class="code codeBlock" spellcheck="false" tabindex="0">iscsiadm -m session</pre> <p>If required, you can also delete the targets from the ISCSI discovery database entirely.</p> <pre class="code codeBlock" spellcheck="false" tabindex="0">iscsiadm -m discoverydb -t sendtargets -p <IP>:<port> -o delete</pre> <p>Finally, it is necessary to check the file system to ensure Linux does not try to re-establish the connection on future boot operations.<br> </p> <pre class="code codeBlock" spellcheck="false" tabindex="0">ls /var/lib/iscsi/nodes/<iqn></pre> <p>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. </p> <p><br><br><strong>Another way can do this is as follows: </strong> </p> <ol><li>Identify the sessions that are still open: <ol><li>iscsiadm -m session</li> </ol></li> <li> Find the one with <strong>unitrends.dpu</strong> in it. </li> <li>Then run <strong>iscsiadm -m node -T <iqn> -p <ip address>:<port number> -u</strong> </li> </ol> </article> </main>