iscsiadm
Learn essential iscsiadm commands for iSCSI initiator administration. Discover targets, log in/out of iSCSI nodes, and manage sessions with this powerful utility.
iSCSI Initiator Administration Utility
The iscsiadm
utility is a powerful command-line tool used for administering the iSCSI initiator on Linux systems. It allows users to manage iSCSI discovery, node configuration, and session management, which are crucial for connecting to and utilizing iSCSI storage arrays.
Discover iSCSI Targets
Before logging into an iSCSI target, you need to discover available targets on a specific iSCSI portal. This command scans the specified IP address and port for discoverable iSCSI targets.
# Discover targets at iscsi portal ADDR:PORT
# Prints a list of available iscsi targets, example:
#
# <target-ip>:<port> <IQN>
# 10.10.10.42:3260,1 iqn.2007-10:iscsi.target0
iscsiadm -m discovery -t sendtargets -p ADDR:PORT
Log In to an iSCSI Target
Once targets are discovered, you can log in to a specific iSCSI target using its Qualified Name (IQN) and portal address. This establishes a connection to the storage resource.
# login to target IQN at portal ADDR:PORT:
iscsiadm -m node -T IQN -p ADDR:PORT --login
Log Out from an iSCSI Target
To disconnect from an iSCSI target, you can use the logout command. This releases the connection to the specified target.
# logout from specified target IQN:
iscsiadm -m node -T IQN --logout
List Active iSCSI Sessions
This command displays all currently active iSCSI sessions, showing which targets are connected and their status.
# list active sessions:
iscsiadm -m session
Log Out from All Active Sessions
For a comprehensive disconnection, you can log out from all active iSCSI sessions simultaneously.
# logout from all active sessions:
iscsiadm -m node --logout