iscsi tools: fix iscsiadm return value on failed login
[open-iscsi.git] / doc / iscsiadm.8
bloba03614217142017eb6baefae35f29e34945b7e4a
1 .TH ISCSIADM 8 "Sep 2006" "" "Linux Administrator's Manual"
2 .SH NAME
3 iscsiadm \- open-iscsi administration utility
4 .SH SYNOPSIS
5 \fBiscsiadm\fR \-m discoverydb [ \-hV ] [ \-d debug_level ] [ \-P printlevel ] [ \-I iface \-t type \-p ip:port [ \-lD ] ] | [ [ -p ip:port -t type ] \
6 [ \-o operation ] [ \-n name ] [ \-v value ] [ \-lD ] ]
8 \fBiscsiadm\fR \-m discovery [ \-hV ] [ \-d debug_level ] [ \-P printlevel ] [ \-I iface \-t type \-p ip:port [ \-l ] ] | [ [ -p ip:port ] [ \-l | \-D ] ]
10 \fBiscsiadm\fR \-m node [ \-hV ] [ \-d debug_level ] [ \-P printlevel ] [ \-L all,manual,automatic ] [ \-U all,manual,automatic ] [ \-S ] [ [ \-T targetname \-p ip:port \-I iface ] [ \-l | \-u | \-R | \-s] ]
11 [ [ \-o operation ]  [ \-n name ] [ \-v value ] [ \-p ip:port ] ]
13 \fBiscsiadm\fR \-m session [ \-hV ] [ \-d debug_level ] [ \-P printlevel ] [ \-r sessionid | sysfsdir [ \-R ] [ \-u | \-s | \-o new ] ]
15 \fBiscsiadm\fR \-m iface [ \-hV ] [ \-d debug_level ] [ \-P printlevel ] [ \-I ifacename | \-H hostno|MAC ]   [ [ \-o  operation  ] [ \-n name ] [ \-v value ] ]
17 \fBiscsiadm\fR \-m fw [\-l]
19 \fBiscsiadm\fR \-m host [ \-P printlevel ] [ \-H hostno|MAC ]
21 \fBiscsiadm\fR \-k priority
23 .SH "DESCRIPTION"
24 The iscsiadm utility is a command-line tool allowing discovery and login
25 to iSCSI targets, as well as access and management of the open-iscsi
26 database.
28 Open-iscsi does not use the term node as defined by the iSCSI RFC,
29 where a node is a single iSCSI initiator or target. Open-iscsi uses the
30 term node to refer to a portal on a target.
32 For session mode, a session id (sid) is used. The sid of a session can be
33 found by running iscsiadm \-m session \-P 1. The session id and sysfs
34 path are not currently persistent and is partially determined by when the
35 session is setup.
37 .PP
38 Note that many of the node and discovery operations require that the iSCSI
39 daemon (iscsid) be running.
41 .SH OPTIONS
43 .TP
44 \fB\-d\fR, \fB\-\-debug=\fIdebug_level\fP
45 print debugging information. Valid values for debug_level are 0 to 8.
47 .TP
48 \fB\-h\fR, \fB\-\-help\fR
49 display help text and exit
51 .TP
52 \fB\-H\fR, \fB\-\-host=\fI[hostno|MAC]\fR
53 The host agrument specifies the SCSI host to use for the operation. It can be
54 the scsi host number assigned to the host by the kernel's scsi layer, or the
55 MAC address of a scsi host.
57 .TP
58 \fB\-I\fR, \fB\-\-interface=\fI[iface]\fR
59 The interface argument specifies the iSCSI interface to use for the operation.
60 iSCSI interfaces (iface) are defined in /etc/iscsi/ifaces. For hardware
61 iSCSI (qla4xxx) the iface config must have the hardware address
62 (iface.hwaddress = port's MAC address)
63 and the driver/transport_name (iface.transport_name). The iface's name is
64 then the filename of the iface config. For software iSCSI, the iface config
65 must have either the hardware address (iface.hwaddress), or the network
66 layer's interface name (iface.net_ifacename), and it must have the
67 driver/transport_name
69 The available drivers/iscsi_transports are tcp (software iSCSI over TCP/IP),
70 iser (software iSCSI over infinniband), or qla4xxx (Qlogic 4XXXX HBAs). The
71 hwaddress is the MAC address or for software iSCSI it may be the special
72 value "default" which directs the initiator to not bind the session to a
73 specific hardware resource and instead allow the network or infinniband layer
74 to decide what to do. There is no need to create a iface config with the default
75 behavior. If you do not specify a iface, then the default behavior is used.
77 As mentioned above there is a special iface name default. There are three
78 others -- cxgb3i, bnx2i and iser, which does not bind the session to a specific card, but will bind the session to the cxgb3i, bnx2i or iser transport. These
79 are experimental and the use is not supported as a stable interface yet.
81 In discovery mode multiple interfaces can be specified by passing in multiple
82 \-I/\-\-interface instances. For example,
84 "iscsiadm \-m discoverydb \-t st \-p ip:port \-I iface0 \-I iface2 --discover"
86 Will direct iscsiadm to setup the node db to create records which will create
87 sessions though the two intefaces passed in.
89 In node mode, only a single interface is supported in each call to iscsiadm.
90 .IP
91 This option is valid for discovery, node and iface mode.
93 .TP
94 \fB\-k\fR, \fB\-\-killiscsid=\fI[priority]\fR
95 Currently priority must be zero. This will immediately stop all iscsid
96 operations and shutdown iscsid. It does not logout any sessions. Running
97 this command is the same as doing "killall iscsid". Neither should
98 normally not be used, because if iscsid is doing error recovery or if there
99 is an error while iscsid is not running, the system may not be able to recover.
100 This command and iscsid's SIGTERM handling are experimental.
103 \fB\-D\fR, \fB\-\-discover\fR
104 Discover targets using the discovery record with the  \fIrecid\fR matching
105 the the discovery type and portal passed in. If there is no matching record,
106 it will be created using the iscsid.conf discovery settings.
107 This must be passed in \fIdiscoverydb\fR mode to instruct iscsiadm to perform
108 discovery.
110 This option is only valid for SendTargets discovery mode.
113 \fB\-l\fR, \fB\-\-login\fR
114 For node and fw mode, login to a specified record. For discovery mode, login to
115 all discovered targets.
117 This option is only valid for discovery and node modes.
120 \fB\-L\fR, \fB\-\-loginall==\fI[all|manual|automatic]\fR
121 For node mode, login all sessions with the node or conn startup values passed
122 in or all running sesssion, except ones marked onboot, if all is passed in.
124 This option is only valid for node mode (it is valid but not functional
125 for session mode).
129 \fB\-m, \-\-mode \fIop\fR
130 specify the mode. \fIop\fR
131 must be one of \fIdiscoverydb\fR, \fInode\fR, \fIfw\fR, \fIhost\fR \fIiface\fR or \fIsession\fR.
133 If no other options are specified: for \fIdiscoverydb\fR and \fInode\fR, all
134 of their respective records are displayed; for \fIsession\fR, all active
135 sessions and connections are displayed; for \fIfw\fR, all boot firmware
136 values are displayed; for \fIhost\fR, all iSCSI hosts are displayed; and
137 for \fIiface\fR, all ifaces setup in /etc/iscsi/ifaces are displayed.
140 \fB\-n\fR, \fB\-\-name=\fIname\fR
141 Specify a field \fIname\fR in a record. For use with the \fIupdate\fR
142 operator.
146 \fB\-o\fR, \fB\-\-op=\fIop\fR
147 Specifies a database operator \fIop\fR. \fIop\fR must be one of
148 \fInew\fR, \fIdelete\fR, \fIupdate\fR, \fIshow\fR or \fInonpersistent\fR.
150 For iface mode, \fIapply\fR and \fIapplyall\fR  are also applicable.
152 This option is valid for all modes except fw. Delete should not be used on a running session. If it is iscsiadm will stop the session and then delete the
153 record.
155 \fInew\fR creates a new database record for a given object. In node mode, the
156 \fIrecid\fR is the target name and portal (IP:port). In iface mode, the \fIrecid\fR
157 is the iface name. In discovery mode, the \fIrecid\fR is the portal and
158 discovery type.
160 In session mode, the \fInew\fR operation logs in a new session using the same node database and iface information as the specified session.
162 In discovery mode, if the \fIrecid\fR and new operation is passed in, but the \fI--discover\fR argument is not, then iscsiadm will only create a discovery record (it will not perform discovery). If the \fI--discover\fR argument is passed in with the portal and discovery type, then iscsiadm will create the discovery record if needed, and it will create records for portals returned by the target that do not yet have a node DB record.
164 \fIdelete\fR deletes a specified \fIrecid\fR. In discovery node, if iscsiadm is performing discovery it will delete records for portals that are no longer returned.
166 \fIupdate\fR will update the \fIrecid\fR with \fIname\fR to the specified \fIvalue\fR. In discovery node, if iscsiadm is performing discovery the \fIrecid\fR, \fIname\fR  and \fIvalue\fR arguments are not needed. The update operation will operate on the portals returned by the target, and will update the node records with info from the config file and command line.
168 \fIshow\fR is the default behaviour for node, discovery and iface mode. It is
169 also used when there are no commands passed into session mode and a running
170 sid is passed in.
171 \fIname\fR and \fIvalue\fR are currently ignored when used with \fIshow\fR.
173 \fInonpersistent\fR instructs iscsiadm to not manipulate the node DB.
176 \fIapply\fR will cause the network settings to take effect on the specified iface.
179 \fIapplyall\fR will cause the network settings to take effect on all the ifaces whose MAC address or host number matches that of the specific host.
182 \fB\-p\fR, \fB\-\-portal=\fIip[:port]\fR
183 Use target portal with ip-address \fIip\fR and \fIport\fR. If port is not passed
184 in the default \fIport\fR value is 3260.
186 IPv6 addresses can bs specified as [ddd.ddd.ddd.ddd]:port or
187 ddd.ddd.ddd.ddd.
189 Hostnames can also be used for the ip argument.
192 This option is only valid for discovery, or for node operations with
193 the \fInew\fR operator.
195 This should be used along with \-\-target in node mode, to specify what the open-iscsi docs refer to as a node or node record. Note: open-iscsi's use of the word node, does not match the iSCSI RFC's iSCSI Node term.
198 \fB\-P\fR,  \fB\-\-print=\fIprintlevel\fR
199 If in node mode print nodes in tree format. If in session mode print
200 sessions in tree format. If in discovery mode print the nodes in
201 tree format.
204 \fB\-T\fR, \fB\-\-targetname=\fItargetname\fR
205 Use target \fItargetname\fR.
207 This should be used along with \-\-portal in node mode, to specify what the open-iscsi docs refer to as a node or node record. Note: open-iscsi's use of the word node, does not match the iSCSI RFC's iSCSI Node term.
210 \fB\-r\fR,  \fB\-\-sid=\fIsid | sysfsdir\fR
211 Use session ID \fIsid\fR. The sid of a session can be found from running
212 iscsiadm in session mode with the \-\-info argument.
214 Instead of sid, a sysfs path containing the session can be used. For example using one of the following: /sys/devices/platform/hostH/sessionS/targetH:B:I/H:B:I:L, /sys/devices/platform/hostH/sessionS/targetH:B:I, or /sys/devices/platform/hostH/sessionS, for the sysfsdir argument would result in the session with sid S to be used.
216 \fIsid | sysfsdir\fR is only required for session mode.
219 \fB\-R\fR,  \fB\-\-rescan\fR
220 In session mode, if sid is also passed in rescan the session. If no sid has
221 been passed in  rescan all running sessions.
223 In node mode, rescan a session running through the target, portal, iface
224 tuple passed in.
227 \fB\-s\fR, \fB\-\-stats\fR
228 Display session statistics.
231 \fB\-S\fR, \fB\-\-show\fR
232 When displaying records, do not hide masked values, such as the CHAP
233 secret (password).
235 This option is only valid for node and session mode.
238 \fB\-t\fR, \fB\-\-type=\fItype\fR
239 \fItype\fR must be \fIsendtargets\fR (or abbreviated as \fIst\fR),
240 \fIslp\fR, \fIisns\fR or \fIfw\fR. Currently only sendtargets, fw, and
241 iSNS is supported, see the DISCOVERY TYPES section.
243 This option is only valid for discovery mode.
246 \fB\-u\fR, \fB\-\-logout\fR
247 logout for a specified record.
249 This option is only valid for node and session mode.
252 \fB\-U\fR, \fB\-\-logoutall==\fI[all,manual,automatic]\fR
253 logout all sessions with the node or conn startup values passed in or all
254 running sesssion, except ones marked onboot, if all is passed in.
256 This option is only valid for node mode (it is valid but not functional
257 for session mode).
260 \fB\-v\fR, \fB\-\-value=\fIvalue\fR
261 Specify a \fIvalue\fR for use with the \fIupdate\fR operator.
263 This option is only valid for node mode.
266 \fB\-V\fR, \fB\-\-version\fR
267 display version and exit
269 .SH DISCOVERY TYPES
270 iSCSI defines 3 discovery types: SendTargets, SLP, and iSNS.
274 SendTargets 
275 A native iSCSI protocol which allows each iSCSI
276 target to send a list of available targets to the initiator.
281 Optionally an iSCSI target can use the Service Location Protocol (SLP)
282 to announce the available targets. The initiator can either implement
283 SLP queries directly or can use a separate tool to acquire the
284 information about available targets.
288 iSNS
289 iSNS (Internet Storage Name Service) records information about storage
290 volumes within a larger network. To utilize iSNS, pass the address and
291 optionally the port of the iSNS server to do discovery to.
296 Several NICs and systems contain a mini iSCSI initiator which can be used
297 for boot. To get the values used for boot the fw option can be used.
298 Doing fw discovery, does not store persistent records in the node or
299 discovery DB, because the values are stored in the system's or NIC's
300 resource.
302 Performing fw discovery will print the portals, like with other discovery
303 methods. To see other settings like CHAP values and initiator settings,
304 like you would in node mode, run "iscsiadm \-m fw".
306 fw support in open-iscsi is experimental. The settings and iscsiadm
307 syntax and output format may change.
310 iscsiadm supports the
312 iSNS (isns)
315 SendTargets (st)
316 discovery type. An SLP implementation is under development.
318 .SH EXIT STATUS
320 On success 0 is returned. On error one of the return codes below will
321 be returned.
323 Commands that operation on multiple objects (sessions, records, etc),
324 iscsiadm/iscsistart will return the first error that is encountered.
325 iscsiadm/iscsistart will attempt to execute the operation on the objects it
326 can. If no objects are found ISCSI_ERR_NO_OBJS_FOUND is returned.
332 ISCSI_SUCCESS - command executed successfully.
337 ISCSI_ERR - generic error code.
339 .TP     
342 ISCSI_ERR_SESS_NOT_FOUND - session could not be found.
347 ISCSI_ERR_NOMEM - could not allocate resource for operation.
351 ISCSI_ERR_TRANS - connect problem caused operation to fail.
356 ISCSI_ERR_LOGIN - generic iSCSI login failure.
361 ISCSI_ERR_IDBM - error accessing/managing iSCSI DB.
366 ISCSI_ERR_INVAL - invalid argument.
371 ISCSI_ERR_TRANS_TIMEOUT - connection timer exired while trying to connect.
376 ISCSI_ERR_INTERNAL - generic internal iscsid/kernel failure.
381 ISCSI_ERR_LOGOUT - iSCSI logout failed.
386 ISCSI_ERR_PDU_TIMEOUT - iSCSI PDU timedout.
391 ISCSI_ERR_TRANS_NOT_FOUND - iSCSI transport module not loaded in kernel or iscsid.
396 ISCSI_ERR_ACCESS - did not have proper OS permissions to access iscsid or execute iscsiadm command.
401 ISCSI_ERR_TRANS_CAPS - transport module did not support operation.
406 ISCSI_ERR_SESS_EXISTS - session is logged in.
411 ISCSI_ERR_INVALID_MGMT_REQ - invalid IPC MGMT request.
416 ISCSI_ERR_ISNS_UNAVAILABLE - iSNS service is not supported.
421 ISCSI_ERR_ISCSID_COMM_ERR - a read/write to iscsid failed.
426 ISCSI_ERR_FATAL_LOGIN - fatal iSCSI login error.
431 ISCSI_ERR_ISCSID_NOTCONN - could ont connect to iscsid.
436 ISCSI_ERR_NO_OBJS_FOUND - no records/targets/sessions/portals found to execute operation on.
441 ISCSI_ERR_SYSFS_LOOKUP - could not lookup object in sysfs.
446 ISCSI_ERR_HOST_NOT_FOUND - could not lookup host.
451 ISCSI_ERR_LOGIN_AUTH_FAILED - login failed due to authorization failure.
456 ISCSI_ERR_ISNS_QUERY - iSNS query failure.
461 ISCSI_ERR_ISNS_REG_FAILED - iSNS registration/deregistration failed.
464 .SH EXAMPLES
467 Discover targets at a given IP address:
469 .ft R
470         iscsiadm \-\-mode discoverydb \-\-type sendtargets \-\-portal 192.168.1.10 \-\-discover
473 Login, must use a node record id found by the discovery:
475 .ft R
476         iscsiadm \-\-mode node \-\-targetname iqn.2001-05.com.doe:test \-\-portal 192.168.1.1:3260 \-\-login
479 Logout:
481 .ft R
482         iscsiadm \-\-mode node \-\-targetname iqn.2001-05.com.doe:test \-\-portal 192.168.1.1:3260 \-\-logout
485 List node records:
487 .ft R
488         iscsiadm \-\-mode node
492 Display all data for a given node record:
494 .ft R
495         iscsiadm \-\-mode node \-\-targetname iqn.2001-05.com.doe:test \-\-portal 192.168.1.1:3260
497 .SH FILES
499 /etc/iscsi/iscsid.conf
500 The configuration file read by \fBiscsid\fR and \fBiscsiadm\fR on startup.
502 /etc/iscsi/initiatorname.iscsi
503 The file containing the iSCSI InitiatorName and InitiatorAlias read by
504 \fBiscsid\fR and \fBiscsiadm\fR on startup.
506 /etc/iscsi/nodes/
507 This directory contains the nodes with their targets.
509 /etc/iscsi/send_targets
510 This directory contains the portals.
512 .SH "SEE ALSO"
513 .BR iscsid (8)
515 .SH AUTHORS
516 Open-iSCSI project <http://www.open-iscsi.org/>
518 Alex Aizman <itn780@yahoo.com>
520 Dmitry Yusupov <dmitry_yus@yahoo.com>