iscsiadm: fix discovery record management
[open-iscsi.git] / README
blob074fb56ae18bad9558460ae822112dc950247d56
1 =================================================================
3                 Linux* Open-iSCSI
5 =================================================================
7                                                    March 22, 2010
8 Contents
9 ========
11 - 1. In This Release
12 - 2. Introduction
13 - 3. Installation
14 - 4. Open-iSCSI daemon
15 - 5. Open-iSCSI Configuration Utility
16 - 6. Configuration
17 - 7. Getting Started
18 - 8. Advanced Configuration
19 - 9. iSCSI System Info
22 1. In This Release
23 ==================
25 This file describes the Linux* Open-iSCSI Initiator. The software was
26 tested on AMD Opteron (TM) and Intel Xeon (TM). 
28 The latest development release is available at:
29 http://www.open-iscsi.org
31 For questions, comments, contributions send e-mail to:
32 open-iscsi@googlegroups.com 
34     1.1. Features
35     
36     - highly optimized and very small-footprint data path;
37     - persistent configuration database;
38     - SendTargets discovery;
39     - CHAP;
40     - PDU header Digest;
41     - multiple sessions;
42     
43 2. Introduction
44 ===============
46 Open-iSCSI project is a high-performance, transport independent,
47 multi-platform implementation of RFC3720 iSCSI.
49 Open-iSCSI is partitioned into user and kernel parts.
51 The kernel portion of Open-iSCSI is a from-scratch code
52 licensed under GPL. The kernel part implements iSCSI data path
53 (that is, iSCSI Read and iSCSI Write), and consists of three
54 loadable modules: scsi_transport_iscsi.ko, libiscsi.ko and iscsi_tcp.ko.
56 User space contains the entire control plane: configuration
57 manager, iSCSI Discovery, Login and Logout processing,
58 connection-level error processing, Nop-In and Nop-Out handling,
59 and (in the future:) Text processing, iSNS, SLP, Radius, etc.
61 The user space Open-iSCSI consists of a daemon process called
62 iscsid, and a management utility iscsiadm.
65 3. Installation
66 ===============
68 As of today, the Open-iSCSI Initiator requires a host running the
69 Linux operating system with kernel version 2.6.16, or later. 2.6.14 and
70 2.6.15 are partially supported. Known issues with 2.6.14 - .15 support:
72 - If the device is using a write back cache, during session logout
73 the cache sync command will fail.
74 - iscsiadm's -P 3 option will not print out scsi devices.
75 - iscsid will not automatically online devices.
77 You need to enable "Cryptographic API" under "Cryptographic options" in the
78 kernel config. And you must enable "CRC32c CRC algorithm" even if
79 you do not use header or data digests. They are the kernel options,
80 CONFIG_CRYPTO and CONFIG_CRYPTO_CRC32C, respectively.
82 By default the kernel source found at
83 /lib/modules/`uname -a`/build
84 will be used to compile the open-iscsi modules. To specify a different
85 kernel to build against use:
87         make KSRC=<kernel-src>
89 or cross-compilation:
91         make KSRC=<kernel-src> KARCH="ARCH=um"
93 To compile on SUSE Linux you'll have to use
95         make KSRC=/usr/src/linux \
96              KBUILD_OUTPUT=/usr/src/linux-obj/<arch>/<config>
98 where <config> is the kernel configuration to use (eg. 'smp').
100 For Red Hat/Fedora and Debian distributions open-iscsi can be installed by
101 typing "make install". This will copy iscsid and iscsiadm to /usr/sbin, the
102 init script to /etc/init.d, and the kernel modules: iscsi_tcp.ko,
103 libiscsi_tcp.ko, libiscsi.ko and scsi_transport_iscsi to
104 /lib/modules/`uname -r`/kernel/drivers/scsi/ overwriting existing iscsi modules.
106 For Debian, be sure to install the linux-headers package that
107 corresponds to your kernel in order to compile the kernel modules
108 ('aptitude install linux-headers-`uname -r`').  You may also wish to
109 run 'make -C kernel/ dpkg_divert' before installing kernel modules if
110 you run a Debian-provided kernel.  This will use dpkg-divert(8) to
111 move the packaged kernel modules out of the way, and ensure that
112 future kernel upgrades will not overwrite them.
114 Also, please be aware that the compatibility patches that enable these
115 iscsi modules to run on kernels older than 2.6.25 will not update the
116 ib_iser module; you may get warnings related to mismatched symbols on
117 this driver, in which case you'll be unable to load ib_iser and
118 open-iscsi simultaneously.
120 4. Open-iSCSI daemon
121 ====================
123 The daemon implements control path of iSCSI protocol, plus some management
124 facilities. For example, the daemon could be configured to automatically 
125 re-start discovery at startup, based on the contents of persistent 
126 iSCSI database (see next section).
128 For help, run:
130         ./iscsid --help
132 Usage: iscsid [OPTION]
134   -c, --config=[path]     Execute in the config file (/etc/iscsi/iscsid.conf).
135   -f, --foreground        run iscsid in the foreground
136   -d, --debug debuglevel  print debugging information
137   -u, --uid=uid           run as uid, default is current user
138   -g, --gid=gid           run as gid, default is current user group
139   -h, --help              display this help and exit
140   -v, --version           display version and exit
144 5. Open-iSCSI Configuration Utility
145 ===================================
147 Open-iSCSI persistent configuration is implemented as a DBM database
148 available on all Linux installations.
150 The database contains two tables:
152 - Discovery table (/etc/iscsi/send_targets);
153 - Node table (/etc/iscsi/nodes).
155 The regular place for iSCSI database files: /etc/iscsi/nodes
157 The iscsiadm utility is a command-line tool to manage (update, delete,
158 insert, query) the persistent database.
160 The utility presents set of operations that a user can perform 
161 on iSCSI nodes, sessions, connections, and discovery records.
163 Open-iscsi does not use the term node as defined by the iSCSI RFC,
164 where a node is a single iSCSI initiator or target. Open-iscsi uses the
165 term node to refer to a portal on a target, so tools like iscsiadm
166 require that --targetname and --portal argument be used when in node mode.
168 For session mode, a session id (sid) is used. The sid of a session can be
169 found by running iscsiadm -m session -i. The session id is not currently
170 persistent and is partially determined by when the session is setup.
172 Note that some of the iSCSI Node and iSCSI Discovery operations 
173 do not require iSCSI daemon (iscsid) loaded.
175 For help, run:
177         ./iscsiadm --help
179 Usage: iscsiadm [OPTION]
181   -m, --mode <op>         specify operational mode op = <discovery|node>
182   -m discovery --type=[type] --interface=iscsi_ifacename \
183                         --portal=[ip:port] --login --print=[N] \
184                         --op=[op]=[NEW | UPDATE | DELETE | NONPERSISTENT]
185                         perform [type] discovery for target portal with
186                           ip-address [ip] and port [port].
188                           This command will not use the discovery record
189                           settings. It will use the iscsid.conf discovery
190                           settings and it will overwrite the discovery
191                           record with iscsid.conf discovery settings if it
192                           exists. By default, it will then remove records for
193                           portals no longer returned. And,
194                           if a portal is returned by the target, then the
195                           discovery command will create a new record or modify
196                           an existing one with values from iscsi.conf and the
197                           command line.
199                           [op] can be passed in multiple times to this
200                           command, and it will alter the DB manipulation.
202                           If [op] is passed in and the value is
203                           "new", iscsiadm will add records for portals that do
204                           not yet have records in the db.
206                           If [op] is passed in and the value is
207                           "update", iscsiadm will update node records using
208                           info from iscsi.conf and the command line for portals
209                           that are returned during discovery and have
210                           a record in the db.
212                           If [op] is passed in and the value is "delete",
213                           iscsiadm will delete records for portals that
214                           were not returned during discovery.
216                           If [op] is passed in and the value is
217                           "nonpersistent" iscsiadm will not store
218                           the portals found in the node DB.
220                           See the example section for more info.
222                           See below for how to setup iscsi ifaces for
223                           software iscsi or override the system defaults.
225                           Multiple ifaces can be passed in during discovery.
226   -m discovery --print=[N] display all discovery records from internal
227                           persistent discovery database.
228   -m discovery --interface --portal=[ip:port] --print=[N] --discover
229                           perform discovery based on portal in database. See
230                           above for info in the interface argument.
232                           For the above commands "print" is optional. If
233                           used, N can be 0 or 1.
234                           0 = The old flat style of output is used.
235                           1 = The tree style with the inteface info is used.
237                           If print is not used the old flay style is used.
238   -m discovery --interface --portal=[ip:port] --print=[N] --login
239                           perform discovery based on portal in database, and
240                           log into portals found during discovery. See
241                           above for info in the interface argument.
243                           For the above commands "print" is optional. If
244                           used, N can be 0 or 1.
245                           0 = The old flat style of output is used.
246                           1 = The tree style with the inteface info is used.
248                           If print is not used the old flay style is used.
249   -m discovery --portal=[ip:port] --op=[op] [--name=[name] --value=[value]]
250                           perform specific DB operation [op] for specific
251                           discovery portal. It could be one of:
252                           [new], [delete], [update] or [show]. In case of
253                           [update], you have to provide [name] and [value]
254                           you wish to update
255   -m node                 display all discovered nodes from internal
256                           persistent discovery database
257   -m node --targetname=[name] --portal=[ip:port] \
258                                         --interface=iscsi_ifacename] \
259                                         [--login|--logout|--rescan|--stats]
260   -m node --targetname=[name] --portal=[ip:port]
261                                 --interface=[driver,HWaddress] \
262                                 --op=[op] [--name=[name] --value=[value]]
263   -m node --targetname=[name] --portal=[ip:port]
264                                 --interface=iscsi_ifacename] \
265                                 --print=[level]
266                           perform specific DB operation [op] for specific
267                           interface on host that will connect to portal on
268                           target. targetname, portal and interface are optional.
269                           See below for how to setup iscsi ifaces for
270                           software iscsi or override the system defaults.
272                           op could be one of:
273                           [new], [delete], [update] or [show]. In case of
274                           [update], you have to provide [name] and [value]
275                           you wish to update.
276                           [delete] - Note that if a session is using the
277                           node record, the session will be logged out then
278                           the record will be deleted.
280                           Print level can be 0 to 1.
282                           Rescan will perform a SCSI layer scan of the session
283                           to find new LUNs.
285                           Stats prints the iSCSI stats for the session.
286   -m node --logoutall=[all|manual|automatic]
287                           Logout "all" the running sessions or just the ones
288                           with a node startup value manual or automatic.
289                           Nodes marked as ONBOOT are skipped.
290   -m node --loginall=[all|manual|automatic]
291                           Login "all" the running sessions or just the ones
292                           with a node startup value manual or automatic.
293                           Nodes marked as ONBOOT are skipped.
294   -m session              display all active sessions and connections
295   -m session --sid=[sid] [ --print=level | --rescan | --logout ]
296                                 --op=[op] [--name=[name] --value=[value]]
297                           perform operation for specific session with
298                           session id sid. If no sid is given the operation
299                           will be performed on all running sessions if possible.
300                           --logout and --op work like they do in node mode,
301                           but in session mode targetname and portal info is
302                           is not passed in.
304                           Print level can be 0 to 2.
305                           1 = Print basic session info like node we are
306                           connected to and whether we are connected.
307                           2 = Print iscsi params used.
308                           3 = Print SCSI info like LUNs, device state.
309                           If no sid and no operation is given print out the
310                           running sessions.
311   -m iface --interface=iscsi_ifacename --op=[op] [--name=[name] --value=[value]]
312                                 --print=level
313                           perform operation on fiven interface with name
314                           iscsi_ifacename.
316                           See below for examples.
317   -m host --host=hostno --print=level
318                           Display information for a specific host if hostno
319                           is passed in. If no hostno is passed in then info
320                           for all hosts is printed.
322                           Print level can be 0 to 4.
323                           1 = Print info for how like its state, MAC, and
324                           netinfo if possible.
325                           2 = Print basic session info for nodes the host
326                           is connected to.
327                           3 = Print iscsi params used.
328                           4 = Print SCSI info like LUNs, device state.
329   -d, --debug debuglevel  print debugging information
330   -V, --version           display version and exit
331   -h, --help              display this help and exit
335 5.1 iSCSI iface setup
336 =====================
338 The next sections describe how to setup iSCSI ifaces so you can bind
339 a session to a NIC port when using software iscsi (section 5.1.1), and
340 it describes how to setup ifaces for use with offload cards from Chelsio
341 and Broadcm (section 5.1.2).
344 5.1.1 How to setup iSCSI interfaces (iface) for binding
345 =======================================================
347 If you wish to allow the network susbsystem to figure out
348 the best path/NIC to use then you can skip this section. For example
349 if you have setup your portals and NICs on different subnets then
350 this the following is not needed for software iscsi.
352 Warning!!!!!!
353 This feature is experimental. The interface may change. When reporting
354 bugs, if you cannot do a "ping -I ethX target_portal", then check your
355 network settings first. If you cannot ping the portal, then you will
356 not be able to bind a session to a NIC.
358 What is a scsi_host and iface for software, hardware and partial
359 offload iscsi?
361 Software iscsi, like iscsi_tcp and iser, allocate a scsi_host per session
362 and does a single connection per session. As a result
363 /sys/class_scsi_host and /proc/scsi will report a scsi_host for
364 each connection/session you have logged into. Offload iscsi, like
365 Chelsio cxgb3i, allocates a scsi_host for each PCI device (each
366 port on a HBA will show up as a different PCI device so you get
367 a scsi_host per HBA port).
369 To manage both types of initiator stacks, iscsiadm uses the interface (iface)
370 structure. For each HBA port or for software iscsi for each network
371 device (ethX) or NIC, that you wish to bind sessions to you must create
372 a iface config /etc/iscsi/ifaces.
374 Running:
376 # iscsiadm -m iface
377 iface0 qla4xxx,00:c0:dd:08:63:e8,20.15.0.7,default,iqn.2005-06.com.redhat:madmax
378 iface1 qla4xxx,00:c0:dd:08:63:ea,20.15.0.9,default,iqn.2005-06.com.redhat:madmax
380 Will report iface configurations that are setup in /etc/iscsi/ifaces.
381 The format is:
383 iface_name transport_name,hwaddress,ipaddress,net_ifacename,initiatorname
385 For software iscsi, you can create the iface configs by hand, but it is
386 reccomended that you use iscsiadm's iface mode. There is a iface.example in
387 /etc/iscsi/ifaces which can be used as a template for the daring.
389 For each network object you wish to bind a session to you must create
390 a seperate iface config in /etc/iscsi/ifaces and each iface config file
391 must have a unique name which is less than or equal to 64 characters.
393 Example:
395 If you have NIC1 with MAC address 00:0F:1F:92:6B:BF and NIC2 with
396 MAC address 00:C0:DD:08:63:E7 and you wanted to do software iscsi over
397 TCP/IP. Then in /etc/iscsi/ifaces/iface0 you would enter:
399 iface.transport_name = tcp
400 iface.hwaddress = 00:0F:1F:92:6B:BF
402 and in /etc/iscsi/ifaces/iface1 you would enter:
404 iface.transport_name = tcp
405 iface.hwaddress = 00:C0:DD:08:63:E7
407 Warning: Do not name a iface config file  "default" or "iser".
408 They are special value/file that is used by the iscsi tools for
409 backward compatibility. If you name a iface default or iser, then
410 the behavior is not defined.
412 To use iscsiadm to create iface0 above for you run:
414 (This will create a new empty iface config. If there was already a iface
415 with the name "iface0" this command will overwrite it.)
416 # iscsiadm -m iface -I iface0 --op=new
418 (This will set the hwaddress.)
419 # iscsiadm -m iface -I iface0 --op=update -n iface.hwaddress -v 00:0F:1F:92:6B:BF
421 If you had sessions logged in iscsiadm will not update, overwrite
422 a iface. You must log out first. If you have a iface bound to a node/portal
423 but you have not logged in then, iscsiadm will update the config and
424 all existing bindings.
427 You should now skip to 5.1.3 to see how to log in using the iface and for
428 some helpful management commands.
432 5.1.2 Setting up a iface for a iSCSI offload card
433 =================================================
435 This section describes how to setup ifaces for use with Chelsio
436 and Broadcom cards.
438 By default, iscsiadm will create a iface for each Broadcom and Chelsio
439 port. The iface name will be of the form:
441 $transport/driver_name.$MAC_ADDRESS
443 Running:
445 # iscsiadm -m iface
446 default tcp,<empty>,<empty>,<empty>,<empty>
447 iser iser,<empty>,<empty>,<empty>,<empty>
448 cxgb3i.00:07:43:05:97:07 cxgb3i,00:07:43:05:97:07,<empty>,<empty>,<empty>
451 Will report iface configurations that are setup in /etc/iscsi/ifaces.
452 The format is:
454 iface_name transport_name,hwaddress,ipaddress,net_ifacename,initiatorname
456 iface_name:             name of iface
457 transport_name:         name of driver
458 hwaddress:              MAC address
459 ipaddress:              IP address to use for this port
460 net_iface_name:         Net_ifacename will be <empty> because change between
461 reboots. It is used for software iSCSI's vlan or alias binding.
462 initiatorname:          Initiatorname to be used if you want to override the
463 default one in /etc/iscsi/initiatorname.iscsi.
467 To display these values in a more friendly run:
469 iscsiadm -m iface -I cxgb3i.00:07:43:05:97:07
470 # BEGIN RECORD 2.0-871
471 iface.iscsi_ifacename = cxgb3i.00:07:43:05:97:07
472 iface.net_ifacename = <empty>
473 iface.ipaddress = <empty>
474 iface.hwaddress = 00:07:43:05:97:07
475 iface.transport_name = cxgb3i
476 iface.initiatorname = <empty>
477 # END RECORD
480 Before you can use the iface, you must set the IP address for the port
481 with the following command:
483 iscsiadm -m iface -I cxgb3i.00:07:43:05:97:07 -o update -n iface.ipaddress -v 20.15.0.66
485 Note1.
487 For the name of the value we want to update we use the name from
488 the "iscsiadm -m iface -I cxgb3i.00:07:43:05:97:07" command which is
489 "iface.ipaddress".
492 Now, we can use this iface to login into targets, which is described in the
493 next section.
496 5.1.3 Discoverying iSCSI targets/portals 
497 ========================================
499 Be aware that iscsiadm will use the default route to do discovery. It will
500 not use the iface specified. So if you are using a offload card, you will
501 need a seperate network connection to the target for discovery purposes.
502 *This will be fixed in the next version of open-iscsi*
504 For compatibility reasons, when you run iscsiadm to do discovery, it
505 will check for interfaces in /etc/iscsi/iscsi/ifaces that are using
506 tcp for the iface.transport and it will bind the portals that are discovered
507 so that they will be logged in through those ifaces. This behavior can also
508 be overriden by passing in the interfaces you want to use. For the case
509 of offload like with cxgb3i and bnx2i this is required because the transport
510 will not be tcp.
512 For example if you had defined two interface but only wanted to use one
513 you can use the --interface/-I argument:
515 iscsiadm -m discovery -t st -p ip:port -I iface1 -P 1
517 If you had defined interfaces but wanted the old behavior, where 
518 we do not bind a session to a iface, then you can use the special iface
519 "default":
521 iscsiadm -m discovery -t st -p ip:port -I default -P 1
523 And if you did not define any interfaces in /etc/iscsi/ifaces and do
524 not pass anything into iscsiadm, running iscsiadm will do the default
525 behavior, where we allow the network subsystem to decide which
526 device to use.
528 If you later want to remove the bindings for a specific target and
529 iface then  you can run:
531 iscsiadm -m node -T my_target -I iface0 --op=delete
533 To do this for a specific portal on a target run:
535 iscsiadm -m node -T my_target -p ip:port -I iface0 --op=delete
537 If you wanted to delete all bindinds for iface0 then you can run
539 iscsiadm -m node -I iface0 --op=delete
541 And for equalogic targets it is sometimes useful to remove by just portal
543 iscsiadm -m node -p ip:port -I iface0 --op=delete
546 To now log into targets it is the same as with sofware iscsi. See section
547 7 for how to get started.
552 5.2 iscsiadm examples
553 =====================
554     Usage examples using the one-letter options (see iscsiadm man page
555     for long options):
557     Discovery mode:
559     - SendTargets iSCSI Discovery using the default driver and interface:
561             ./iscsiadm -m discovery -t sendtargets -p 192.168.1.1:3260
563         This will first search /etc/iscsi/ifaces for interfaces
564         using software iscsi. If any are found then nodes found during
565         discovery will be setup so that they can logged in through
566         those interfaces.
568     - SendTargets iSCSI Discovery updating existing records:
570             ./iscsiadm -m discovery -t sendtargets -p 192.168.1.1:3260 \
571                 -o update
573         If there a record for targetX and portalY exists in the DB, and
574         is returned during discovery, it will be updated with the info
575         from the iscsi.conf. No new portals will be added and stale
576         portals will not be removed.
578     - SendTargets iSCSI Discovery deleting existing records:
580             ./iscsiadm -m discovery -t sendtargets -p 192.168.1.1:3260 \
581                 -o delete
583         If there a record for targetX and portalY exists in the DB, but
584         is not returned during discovery it will be removed from the DB.
585         No new portals will be added and existing portal records will not
586         be changed.
588         Note: If a session is logged into portal we are going to delete
589         a record for, it will be logged out then the record will be
590         deleted.
592      - SendTargets iSCSI Discovery adding new records:
594             ./iscsiadm -m discovery -t sendtargets -p 192.168.1.1:3260 \
595                 -o new
597         If there targetX and portalY is returned during discovery and does
598         not have a record, it will be added. Existing records are not
599         modified.
601      - SendTargets iSCSI Discovery using multiple ops:
603             ./iscsiadm -m discovery -t sendtargets -p 192.168.1.1:3260 \
604                 -o new -o delete
606         This command will add new portals and delete records for portals
607         no longer returned. It will not change the record information for
608         existing portals.
610      - SendTargets iSCSI Discovery in nonpersistent mode:
612             ./iscsiadm -m discovery -t sendtargets -p 192.168.1.1:3260 \
613                 -o nonpersistent
615         This command will perform discovery, but not manipulate the node DB.
617   - SendTargets iSCSI Discovery with a specific interface. If you
618         wish to only use a subset of the interfaces in /etc/iscsi/ifaces
619         then you can pass them in during discovery:
621              ./iscsiadm -m discovery -t sendtargets -p 192.168.1.1:3260 \
622               --interface=iface0 --interface=iface1
624         Note that for software iscsi, we let the network layer select
625         which NIC to use for discovery, but for later logins iscsiadm
626         will use the NIC defined in the iface config.
628         qla4xxx support is very basic and experimental. It does not store
629         the record info in the card's FLASH or the node DB, so you must
630         rerun discovery every time the driver is reloaded.
632     - SendTargets iSCSI Discovery using the default driver and interface and
633         using the discovery settings for the discovery record with the
634         ID [192.168.1.1:3260].
636             ./iscsiadm -m discovery -p 192.168.1.1:3260 --discover
638         This will search /etc/iscsi/send_targets for a record with the
639         ID [192.168.1.1:3260]. If found it will perform discovery using
640         the settings stored in the record. For the ifaces,
641         This will first search /etc/iscsi/ifaces for interfaces
642         using software iscsi. If any are found then nodes found during
643         discovery will be setup so that they can logged in through
644         those interfaces.
646         This command also accepts the -o new, delete and update settings
647         like above.
649     Node mode. In node mode you can specify which records you want to log
650     into by specifying the targetname, ip address, port or interface
651     (if specifying the interface it must already be setup in the node db).
652     iscsiadm will search the node db, for records which match the values
653     you pass in, so if you pass in the targetname and interface, iscsiadm
654     will search for records with those values and operate on only them.
655     Passing in none of them will result in all node records being operated on.
657     - iSCSI Login to all portals on every node/starget through each interface
658         set in the db:
660             ./iscsiadm -m node -l
662     - iSCSI login to all portals on a node/target through each interface set
663         in the db:
665             ./iscsiadm -m node -T iqn.2005-03.com.max -l
667     - iSCSI login to a specific portal through each interface set in the db:
669             ./iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260 -l
671         To specify a IPv6 address the following can be used:
673             ./iscsiadm -m node -T iqn.2005-03.com.max \
674                                         -p 2001:c90::211:9ff:feb8:a9e9 -l
676         The above command would use the default port, 3260. To specify a
677         port use the following:
679             ./iscsiadm -m node -T iqn.2005-03.com.max \
680                                 -p [2001:c90::211:9ff:feb8:a9e9]:3260 -l
682     - iSCSI Login to a specific portal through the NIC setup as iface0:
684             ./iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260 \
685                                 -I iface0  -l
687     - iSCSI Logout to all portals on every node/starget through each interface
688         set in the db:
690             ./iscsiadm -m node -u
692         Warning: this does not check startup values like the logout/login all
693         option. Do not use this if you are running iscsi on your root disk.     
695     - iSCSI logout to all portals on a node/target through each interface set
696         in the db:
698             ./iscsiadm -m node -T iqn.2005-03.com.max -u
700     - iSCSI logout to a specific portal through each interface set in the db:
702             ./iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260 -u
704     - iSCSI Logout to a specific portal through the NIC setup as iface0:
706             ./iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260 \
707                                 -I iface0
709     - Changing iSCSI parameter:
711             ./iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260 \
712                -o update -n node.cnx[0].iscsi.MaxRecvDataSegmentLength -v 65536
714         You can also change paramaters for multiple records at once, by
715         specifying different combinations of the target, portal and interface
716         like above.
718     - Adding custom iSCSI portal:
720             ./iscsiadm -m node -o new -T iqn.2005-03.com.max \
721                         -p 192.168.0.1:3260,2 -I iface4
723         The -I/--interface is optional. If not passed in, "default" is used.
724         For tcp or iser, this would allow the network layer to decide what is
725         best.
727         Note that for this command the target portal group tag (TPGT) should
728         be passed in. If it is not passed in on the initial creation command
729         then the user must run iscsiadm again to set the value. Also
730         if the TPGT is not initially passed in, the old behavior of not
731         tracking whether the record was statically or dynamically created
732         is used.
734     - Adding custom NIC config to multiple targets:
736             ./iscsiadm -m node -o new -I iface4
738         This command will add a interface config using the iSCSI and SCSI
739         settings from iscsid.conf to every target that is in the node db.
741     - Removing iSCSI portal:
743             ./iscsiadm -m node -o delete -T iqn.2005-03.com.max -p 192.168.0.4:3260
745         You can also delete multiple records at once, by specifying different
746         combinations of the target, portal and interface like above.
748     - Display iSCSI portal onfiguration:
750             ./iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260
752         or
754             ./iscsiadm -m node -o show -T iqn.2005-03.com.max -p 192.168.0.4:3260
755         You can also display multiple records at once, by specifying different
756         combinations of the target, portal and interface like above.
758         Note: running "iscsiadm -m node" will only display the records. It
759         will not display the configuration info. You must run,
760         "iscsiadm -m node -o show".
762     - Show all node records:
764             ./iscsiadm -m node
766         This will print the nodes using the old flat format where the
767         interface and driver are not displayed. To display that info
768         use the -P argument with the arguent "1":
770             ./iscsiadm -m node -P 1
772     - Show all records in discovery database:
774             ./iscsiadm -m discovery
776     - Show all records in discovery database and show the targets that
777         were discovered from each record:
779             ./iscsiadm -m discovery -P 1
781     - Display discovery record setting:
783             ./iscsiadm -m discovery -p 192.168.0.4:3260
785     - Display session statistics:
787             ./iscsiadm -m session -r 1 --stats
789         This function also works in node mode. Instead of the "-r $sid"
790         argument, you would pass in the node info like targetname and/or portal,
791         and/or interface.
793     - Perform a SCSI scan on a session
795             ./iscsiadm -m session -r 1 --rescan
797         This function also works in node mode. Instead of the "-r $sid"
798         argument, you would pass in the node info like targetname and/or portal,
799         and/or interface.
801         Note: Rescanning does not delete old LUNs. It will only pick up new
802         ones.
804     - Display running sessions:
806             ./iscsiadm -m session -P 1
808 6. Configuration
809 ================
811 The default configuration file is /etc/iscsi/iscsid.conf. This file contains
812 only configuration that could be overwritten by iSCSI Discovery,
813 or manualy updated via iscsiadm utility. Its OK if this file does not
814 exist in which case compiled-in default configuration will take place
815 for newer discovered Target nodes.
817 See the man page and the example file for the current syntax.
818 The manpages for iscsid, iscsiadm are in the doc subdirectory and can be
819 installed in the appropriate man page directories and need to be manually
820 copied into e.g. /usr/local/share/man8.
822 7. Getting Started
823 ==================
824 There are three steps needed to set up a system to use iSCSI storage:
825 7.1. iSCSI startup using the init script or manual startup.
826 7.2. Discover targets.
827 7.3. Automate target logins for future system reboots.
829 The init scripts will start the iSCSI daemon and log into any
830 portals that are set up for automatic login (discussed in 7.2)
831 or discovered through the discover daemon iscsid.conf params
832 (discussed in 7.1.2).
834 If your distro does not have a init script, then you will have to start the
835 daemon and log into the targets manually.
838 7.1.1 iSCSI startup using the init script
839 -----------------------------------------------
841 Red Hat or Fedora:
842 -----------------
843 To start open-iscsi in Red Hat/Fedora you can do:
845         service open-iscsi start
847 To get open-iscsi to automatically start at run time you may have to
848 run:
849         chkconfig --level <levels> open-iscsi on
850 Where <levels> are the run levels.
852 And, to automatically mount a file system during startup
853 you must have the partition entry in /etc/fstab marked with the "_netdev"
854 option. For example this would mount a iscsi disk sdb:
856         /dev/sdb /mnt/iscsi ext3 _netdev 0 0
858 SUSE or Debian:
859 ---------------
860 Otherwise, if there is a initd script for your distro in etc/initd that
861 gets installed with "make install"
863         /etc/init.d/open-iscsi start
865 will usually get you started.
868 7.1.2 Automatic Discovery and Login
869 -----------------------------------
871 When iscsid starts it will check iscsid.conf for:
873 discovery.daemon.sendtargets.addresses =
874 discovery.daemon.sendtargets.poll_interval =
876 discovery.daemon.isns.addresses =
877 discovery.daemon.isns.poll_interval =
879 being set. If an address or addresses are set, iscsid will perform discovery
880 to the address every poll_interval seconds, and it will log into any portals
881 found from the discovery source using the ifaces in /etc/iscsi/ifaces.
883 Note that for iSNS the poll_interval does not have to be set. If not set,
884 iscsid will only perform rediscovery when it gets a SCN from the server.
885 SCNs are not supported when using the Microsoft or SLES iSNS server. If
886 using one of them you should set the poll_interval.
888 See the iscsid.conf for more examples.
891 7.1.2 Manual Startup:
892 ---------------------
894 7.1.2.1 Starting up the iSCSI daemon (iscsid) and loading modules:
895 -----------------------------------------------------------------
896 If there is no initd script, you must start the tools by hand. First load the
897 iscsi modules with:
899         modprobe -q iscsi_tcp
901 after that start iSCSI daemon process:
903         ./iscsid
905 or alternatively, start it with debug enabled and with output
906 redirected to the current console:
908         ./iscsid -d 8 -f &
910 7.1.2.2 Logging into Targets:
911 ---------------------------
912 Use the configuration utility, iscsiadm, to add/remove/update Discovery
913 records, iSCSI Node records or monitor active iSCSI sessions (see above or the
914 iscsiadm man files and see section 7.2 below for how to discover targets).
916         ./iscsiadm  -m node
918 will print out the nodes that have been discovered as:
920         10.15.85.19:3260,3 iqn.1992-08.com.netapp:sn.33615311 
921         10.15.84.19:3260,2 iqn.1992-08.com.netapp:sn.33615311
923 The format is:
925 ip:port,target_portal_group_tag targetname
927 If you are using the iface argument or want to see the driver
928 info use the following:
930         ./iscsiadm -m node -P 1
932 Target: iqn.1992-08.com.netapp:sn.33615311
933         Portal: 10.15.84.19:3260,2
934                 Iface Name: iface2
935         Portal: 10.15.85.19:3260,3
936                 Iface Name: iface2
938 The format is:
940 Target: targetname
941         Portal ip_address:port,tpgt
942                 Iface: iface
944 where targetname is the name of the target and ip_address:port is the address
945 and port of the portal. tpgt, is the portal group tag of
946 the portal, and is not used in iscsiadm commands except for static
947 record creation. And iface name is the name of the iscsi interface
948 defined in /etc/iscsi/ifaces. If no interface was defined in
949 /etc/iscsi/ifaces or passed in, the default behavior is used.
950 Default here is iscsi_tcp/tcp to be used over which ever NIC the
951 network layer decides is best.
953 To login, take the ip, port and targetname from above and run:
955         ./iscsiadm -m node -T targetname -p ip:port -l
957 In this example we would run
959         ./iscsiadm -m node -T iqn.1992-08.com.netapp:sn.33615311 -p 10.15.84.19:3260 -l
961         Note: drop the portal group tag from the "iscsiadm -m node" output.
963 7.2. Discover Targets
964 ---------------------
965 Once the iSCSI service is running, you can perform discovery using
966 SendTarget with:
968 iscsiadm -m discovery -t sendtargets -p ip:port
970 where "ip" is the address of the portal and port is the port.
972 To use iSNS you can run the discovery command with the type as "isns"
973 and pass in the ip:port:
975 iscsiadm -m discovery -t isns -p ip:port
977 Both commands will print out the list of all discovered targets and their
978 portals:
980 # iscsiadm -m discovery -t st -p 10.15.85.19:3260
981 10.15.84.19:3260,2 iqn.1992-08.com.netapp:sn.33615311
982 10.15.85.19:3260,3 iqn.1992-08.com.netapp:sn.33615311
984 The format for the output is:
986 ip:port,tpgt targetname
988 In this example, for the first target the ip address is 10.15.85.19.
989 The port is 3260. The target portal group is 3. The target name
990 is iqn.1992-08.com.netapp:sn.33615311.
992 If you would also like to see the iscsi inteface which will be used
993 for each session then use the --print[N] option.
995 iscsiadm -m discovery -t sendtargets -p ip:port -P 1
997 will print:
998     Target: iqn.1992-08.com.netapp:sn.33615311
999         Portal: 10.15.84.19:3260,2
1000            Iface Name: iface2
1001         Portal: 10.15.85.19:3260,3
1002            Iface Name: iface2
1004 In this example, The IP address of the first portal is 10.15.84.19.
1005 The port is 3260. The target portal group is 3. The target name
1006 is iqn.1992-08.com.netapp:sn.33615311. The iface being used is iface2.
1008 While discovery targets are kept in the discovery db, they are
1009 useful only for re-discovery. The discovered targets (a.k.a. nodes)
1010 are stored as records in the node db.
1012 The discovered targets are not logged into yet. Rather than logging
1013 into the discovered nodes (making LUs from those nodes available as
1014 storage), it is better to automate the login to the nodes we need.
1016 If you wish to log into a target manually now, see section
1017 "7.1.2.2 Logging in targets" above.
1019 7.3. Automate Target Logins for Future System Statups
1020 -----------------------------------------------------
1021 Note: this may only work for distros with init scripts.
1023 To automate login to a node, use the following with the record ID
1024 (record ID is the targetname and portal) of the node discovered in the
1025 discovery above:
1026         iscsiadm -m node -T targetname -p ip:port --op update -n node.startup -v automatic
1028 To set the automatic setting to all portals on a target through every
1029 interface setup for each protal, the following can be run:
1030         iscsiadm -m node -T targetname --op update -n node.startup -v automatic
1032 Or to set the "node.startup" attribute to "startup" as default for
1033 all sessions add the following to the /etc/iscsi/iscsid.conf:
1035         node.startup = automatic
1037 Setting this in iscsid.conf, will not affect existing nodes. It will only
1038 affect nodes that are discovered after setting the value.
1040 To login to all the automated nodes, simply restart the iscsi service:
1041 e.g /etc/init.d/open-iscsi restart. On your next startup the nodes will
1042 be logged into autmotically.
1045 8. Advanced Configuration
1046 =========================
1048 8.1 iSCSI settings for dm-multipath
1049 -----------------------------------
1051 When using dm-multipath, the iSCSI timers should be set so that commands
1052 are quickly failed to the dm-multipath layer. For dm-multipath you should
1053 then set values like queue if no path, so that IO errors are retried and
1054 queued if all paths are failed in the multipath layer.
1057 8.1.1 iSCSI ping/Nop-Out settings
1058 ---------------------------------
1059 To quickly detect problems in the network, the iSCSI layer will send iSCSI
1060 pings (iSCSI NOP-Out requests) to the target. If a NOP-Out times out the
1061 iSCSI layer will respond by failing running commands and asking the SCSI
1062 layer to requeue them if possible (SCSI disk commands get 5 retries if not
1063 using multipath). If dm-multipath is being used the SCSI layer will fail
1064 the command to the multipath layer instead of retrying. The multipath layer
1065 will then retry the command on another path.
1067 To control how often a NOP-Out is sent the following value can be set:
1069 node.conn[0].timeo.noop_out_interval = X
1071 Where X is in seconds and the default is 10 seconds. To control the
1072 timeout for the NOP-Out the noop_out_timeout value can be used:
1074 node.conn[0].timeo.noop_out_timeout = X
1076 Again X is in seconds and the default is 15 seconds.
1078 Normally for these values you can use:
1080 node.conn[0].timeo.noop_out_interval = 5
1081 node.conn[0].timeo.noop_out_timeout = 10
1083 If there are a lot of IO error messages, then the above values may be too
1084 aggressive and you may need to increase the values for your network conditions
1085 and workload, or you may need to check your network for possible problems.
1088 8.1.2 replacement_timeout
1089 -------------------------
1090 The next iSCSI timer that will need to be tweaked is:
1092 node.session.timeo.replacement_timeout = X
1094 Here X is in seconds.
1096 replacement_timeout will control how long to wait for session re-establishment
1097 before failing pending SCSI commands and commands that are being operated on by
1098 the SCSI layer's error handler up to a higher level like multipath or to
1099 an application if multipath is not being used.
1102 8.1.2.1 Running Commands, the SCSI Error Handler, and replacement_timeout
1103 -------------------------------------------------------------------------
1104 Remember, from the Nop-out discussion that if a network problem is detected,
1105 the running commands are failed immediately. There is one exception to this
1106 and that is when the SCSI layer's error handler is running. To check if
1107 the SCSI error handler is running iscsiadm can be run as:
1109 iscsiadm -m session -P 3
1111 You will then see:
1113 Host Number: X State: Recovery
1115 When the SCSI EH is running, commands will not be failed until
1116 node.session.timeo.replacement_timeout seconds.
1118 To modify the timer that starts the SCSI EH, you can either write
1119 directly to the device's sysfs file:
1121 echo X > /sys/block/sdX/device/timeout
1123 where X is in seconds or on most distros you can modify the udev rule.
1125 To modify the udev rule open /etc/udev/rules.d/50-udev.rules, and find the
1126 following lines:
1128 ACTION=="add", SUBSYSTEM=="scsi" , SYSFS{type}=="0|7|14", \
1129         RUN+="/bin/sh -c 'echo 60 > /sys$$DEVPATH/timeout'"
1131 And change the echo 60 part of the line to the value that you want.
1133 The default timeout for normal File System commands is 30 seconds when udev
1134 is not being used. If udev is used the default is the above value which
1135 is normally 60 seconds.
1138 8.1.2.2 Pending Commands and replacement_timeout
1139 ------------------------------------------------
1140 Commonly, the SCSI/BLOCK layer will queue 256 commands, but the path can
1141 only take 32. When a network problem is detected, the 32 commands
1142 in flight will be sent back to the SCSI layer immediately and because
1143 multipath is being used this will cause the commands to be sent to the multipath
1144 layer for execution on another path. However the other 96 commands that were
1145 still in the SCSI/BLOCK queue, will remain here until the session is
1146 re-established or until node.session.timeo.replacement_timeout seconds has
1147 gone by. After replacement_timeout seconds, the pending commands will be
1148 failed to the multipath layer, and all new incoming commands will be
1149 immediately failed back to the multipath layer. If a session is later
1150 re-established, then new commands will be queued and executed. Normally,
1151 multipathd's path tester mechanism will detect that the session has been
1152 re-established and the path is accessible again, and it will inform
1153 dm-multipath.
1156 8.1.3 Optimal replacement_timeout Value
1157 ---------------------------------------
1159 The default value for replacement_timeout is 120 seconds, but because
1160 multipath's queue_if_no_path and no_path_retry setting can prevent IO errors
1161 from being propagated to the application, replacement_timeout can be set to a
1162 shorter value like 5 to 15 seconds. By setting it lower pending IO is quickly
1163 sent to a new path and executed while the iSCSI layer attempts
1164 re-establishment of the session. If all paths end up being failed, then the
1165 multipath and device mapper layer will internally queue IO based on the
1166 multipath.conf settings, instead of the iSCSI layer.
1169 8.2 iSCSI settings for iSCSI root
1170 ---------------------------------
1172 When accessing the root partition directly through a iSCSI disk, the
1173 iSCSI timers should be set so that iSCSI layer has several chances to try to
1174 re-establish a session and so that commands are not quickly requeued to
1175 the SCSI layer. Basically you want the opposite of when using dm-multipath.
1177 For this setup, you can turn off iSCSI pings by setting:
1179 node.conn[0].timeo.noop_out_interval = 0
1180 node.conn[0].timeo.noop_out_timeout = 0
1182 And you can turn the replacement_timer to a very long value:
1184 node.session.timeo.replacement_timeout = 86400
1187 9. iSCSI System Info
1188 ====================
1190 To get information about the running sessions: including the session and
1191 device state, session ids (sid) for session mode, and some of the
1192 negotiated parameters, run:
1194         iscsiadm -m session -P 2
1196 If you are looking for something shorter like just the sid to node mapping
1197 run:
1199         iscsiadm -m session -P 0
1200         or
1201         iscsiadm -m session
1203 This will print the list of running sessions with the format:
1205 driver [sid] ip:port,target_portal_group_tag targetname
1207 # iscsiadm -m session
1208 tcp [2] 10.15.84.19:3260,2 iqn.1992-08.com.netapp:sn.33615311
1209 tcp [3] 10.15.85.19:3260,3 iqn.1992-08.com.netapp:sn.33615311
1211 To print the hw address info use the -P option with "1":
1213        iscsiadm -m session -P 1
1215 This will print the sessions with the following format:
1216 Target: targetname
1217         Current Portal: portal currently logged into
1218         Persistent Portal: portal we would fall back to if we had got redirected                                during login
1219                 Iface Transport: driver/transport_name
1220                 Iface IPaddress: IP address of iface being used
1221                 Iface HWaddress: HW address used to bind session
1222                 Iface Netdev: netdev value used to bind session
1223                 SID: iscsi sysfs session id
1224                 iSCSI Connection State: iscsi state
1226 Note: if a older kernel is being used or if the session is not bound
1227 then the keyword "default" is print to indicate that the default
1228 network behavior is being used.
1230 Example:
1231 #iscsiadm -m session -P 1
1232 Target: iqn.1992-08.com.netapp:sn.33615311
1233         Current Portal: 10.15.85.19:3260,3
1234         Persistent Portal: 10.15.85.19:3260,3
1235                 Iface Transport: tcp
1236                 Iface IPaddress: 10.11.14.37
1237                 Iface HWaddress: default
1238                 Iface Netdev: default
1239                 SID: 7
1240                 iSCSI Connection State: LOGGED IN
1241                 Internal iscsid Session State: NO CHANGE
1243 The connection state is currently not available for qla4xxx.
1246 To get a HBA/Host view of the session there is the host mode.
1248 Example:
1250 iscsiadm -m host
1251 cxgb3i: [7] 10.10.15.51,[00:07:43:05:97:07],eth3 <empty>
1253 This prints the list of iSCSI hosts in the system with the format:
1254 driver [hostno] ipaddress,[hwaddress],net_ifacename,initiatorname
1257 To print this info in a more user friendly way the -P argument can be used:
1259 iscsiadm -m host -P 1
1260 Host Number: 7
1261         State: running
1262         Transport: cxgb3i
1263         Initiatorname: <empty>
1264         IPaddress: 10.10.15.51
1265         HWaddress: 00:07:43:05:97:07
1266         Netdev: eth3
1268 Here, you can also see the sate of the host.
1270 You can also pass in any value from 1 - 4 to print more info like the
1271 sessions running through the host, what ifaces are being used and what
1272 devices are accessed through it.
1274 To print the info for a specific host then you can pass in the -H argument
1275 with the host number:
1276 iscsiadm -m host -P 1 -H 7