Removing a persistent iSCSI connection: Difference between revisions

From WilliamsNet Wiki
Jump to navigation Jump to search
(initial commit)
 
mNo edit summary
Line 21: Line 21:
  sudo iscsiadm -m session
  sudo iscsiadm -m session


If required, you can also delete the targets from the ISCSI discovery database entirely.
If required (it is extreme, but may be necessary), you can also delete the targets from the ISCSI discovery database entirely.


  sudo iscsiadm -m discoverydb -t sendtargets -p <IP>:<port> -o delete
  sudo iscsiadm -m discoverydb -t sendtargets -p 10.2.0.201 -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.
Finally, clean out the state information to ensure Linux does not try to re-establish the connection on future boot operations.


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


If the iqn exists, it should be deleted:
If the <iqn> exists, delete it:


  sudo rm -rf /var/lib/iscsi/nodes/<iqn>
  sudo rm -rf /var/lib/iscsi/nodes/<iqn>


---
Excerpted and adapted from https://support.unitrends.com/hc/en-us/articles/360013269518-Remove-ISCSI-sessions-using-the-Linux-command-line
Excerpted and adapted from https://support.unitrends.com/hc/en-us/articles/360013269518-Remove-ISCSI-sessions-using-the-Linux-command-line

Revision as of 18:53, 26 November 2020

Kill the iSCSI session

First, find the session you're trying to delete:

sudo iscsiadm -m session

The key information is also available from the iSCSI server itself (using the equallogic cluster as an example):

sudo iscsiadm -m discovery -t st -p 10.2.0.201

The iqn number is the key from the command output. To disconnect the session:

sudo iscsiadm -m node -T <iqn> -p 10.2.0.201 -u

This is only the first skirmish of the battle, however, as the iscsi subsystem is rather persistent about keeping its connections alive and restoring them after a reboot. To prevent the session from re-establishing, you may wish to remove the node:

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

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

sudo iscsiadm -m session

If required (it is extreme, but may be necessary), you can also delete the targets from the ISCSI discovery database entirely.

sudo iscsiadm -m discoverydb -t sendtargets -p 10.2.0.201 -o delete

Finally, clean out the state information 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, delete it:

sudo rm -rf /var/lib/iscsi/nodes/<iqn>

--- Excerpted and adapted from https://support.unitrends.com/hc/en-us/articles/360013269518-Remove-ISCSI-sessions-using-the-Linux-command-line