Removing a persistent iSCSI connection: Difference between revisions

From WilliamsNet Wiki
Jump to navigation Jump to search
(initial commit)
(No difference)

Revision as of 18:49, 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, you can also delete the targets from the ISCSI discovery database entirely.

sudo 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:

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