1 =================================================================
5 =================================================================
14 - 4. Open-iSCSI daemon
15 - 5. Open-iSCSI Configuration Utility
18 - 8. Advanced Configuration
19 - 9. iSCSI System Info
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
36 - highly optimized and very small-footprint data path;
37 - persistent configuration database;
38 - SendTargets discovery;
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.
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>
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.
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).
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.
179 Usage: iscsiadm [OPTION]
181 -m, --mode <op> specify operational mode op =
182 <discovery|discoverydb|fw|iface|host|node>
184 -m discoverydb --type=[type] --interface=[iface...] --portal=[ip:port] \
186 --op=[op]=[NEW | UPDATE | DELETE | NONPERSISTENT] \ --discover
188 This command will use the discovery record settings
189 matching the record with type=type and
190 portal=ip:port]. If a record does not exist, it will
191 create a record using the iscsid.conf discovery
194 By default, it will then remove records for
195 portals no longer returned. And,
196 if a portal is returned by the target, then the
197 discovery command will create a new record or modify
198 an existing one with values from iscsi.conf and the
201 [op] can be passed in multiple times to this
202 command, and it will alter the node DB manipulation.
204 If [op] is passed in and the value is
205 "new", iscsiadm will add records for portals that do
206 not yet have records in the db.
208 If [op] is passed in and the value is
209 "update", iscsiadm will update node records using
210 info from iscsi.conf and the command line for portals
211 that are returned during discovery and have
214 If [op] is passed in and the value is "delete",
215 iscsiadm will delete records for portals that
216 were not returned during discovery.
218 If [op] is passed in and the value is
219 "nonpersistent" iscsiadm will not store
220 the portals found in the node DB. This
221 only useful with the --login command.
223 See the example section for more info.
225 See below for how to setup iscsi ifaces for
226 software iscsi or override the system defaults.
228 Multiple ifaces can be passed in during discovery.
230 For the above commands "print" is optional. If
231 used, N can be 0 or 1.
232 0 = The old flat style of output is used.
233 1 = The tree style with the inteface info is used.
235 If print is not used the old flay style is used.
236 -m discoverydb --interface=[iface...] --type=[type] --portal=[ip:port] \
238 --op=[op]=[NEW | UPDATE | DELETE | NONPERSISTENT] \
241 This works like the previous discoverydb command
242 with the --login argument passed in will also
243 log into the portals that are found.
244 -m discoverydb --portal=[ip:port] --type=[type] \
245 --op=[op] [--name=[name] --value=[value]]
247 Perform specific DB operation [op] for
248 discovery portal. It could be one of:
249 [new], [delete], [update] or [show]. In case of
250 [update], you have to provide [name] and [value]
253 op=NEW will create a new discovery record
254 using the iscsid.conf discovery settings. If it
255 already exists, it will be overwritten using
256 iscsid.conf discovery settings.
258 op=DELETE will delete the discovery record
259 and records for the targets found through
260 that discovery source.
262 op=SHOW will display the discovery record
263 values. The --show arguemnt can be used to
264 force the CHAP passwords to be displayed.
265 -m discovery --type=[type] --interface=iscsi_ifacename \
266 --portal=[ip:port] --login --print=[N] \
267 --op=[op]=[NEW | UPDATE | DELETE | NONPERSISTENT]
268 perform [type] discovery for target portal with
269 ip-address [ip] and port [port].
271 This command will not use the discovery record
272 settings. It will use the iscsid.conf discovery
273 settings and it will overwrite the discovery
274 record with iscsid.conf discovery settings if it
275 exists. By default, it will then remove records for
276 portals no longer returned. And,
277 if a portal is returned by the target, then the
278 discovery command will create a new record or modify
279 an existing one with values from iscsi.conf and the
282 [op] can be passed in multiple times to this
283 command, and it will alter the DB manipulation.
285 If [op] is passed in and the value is
286 "new", iscsiadm will add records for portals that do
287 not yet have records in the db.
289 If [op] is passed in and the value is
290 "update", iscsiadm will update node records using
291 info from iscsi.conf and the command line for portals
292 that are returned during discovery and have
295 If [op] is passed in and the value is "delete",
296 iscsiadm will delete records for portals that
297 were not returned during discovery.
299 If [op] is passed in and the value is
300 "nonpersistent" iscsiadm will not store
301 the portals found in the node DB.
303 See the example section for more info.
305 See below for how to setup iscsi ifaces for
306 software iscsi or override the system defaults.
308 Multiple ifaces can be passed in during discovery.
309 -m discovery --print=[N] display all discovery records from internal
310 persistent discovery database.
312 -m node display all discovered nodes from internal
313 persistent discovery database
314 -m node --targetname=[name] --portal=[ip:port] \
315 --interface=iscsi_ifacename] \
316 [--login|--logout|--rescan|--stats]
317 -m node --targetname=[name] --portal=[ip:port]
318 --interface=[driver,HWaddress] \
319 --op=[op] [--name=[name] --value=[value]]
320 -m node --targetname=[name] --portal=[ip:port]
321 --interface=iscsi_ifacename] \
323 perform specific DB operation [op] for specific
324 interface on host that will connect to portal on
325 target. targetname, portal and interface are optional.
326 See below for how to setup iscsi ifaces for
327 software iscsi or override the system defaults.
330 [new], [delete], [update] or [show]. In case of
331 [update], you have to provide [name] and [value]
333 [delete] - Note that if a session is using the
334 node record, the session will be logged out then
335 the record will be deleted.
337 Print level can be 0 to 1.
339 Rescan will perform a SCSI layer scan of the session
342 Stats prints the iSCSI stats for the session.
343 -m node --logoutall=[all|manual|automatic]
344 Logout "all" the running sessions or just the ones
345 with a node startup value manual or automatic.
346 Nodes marked as ONBOOT are skipped.
347 -m node --loginall=[all|manual|automatic]
348 Login "all" the running sessions or just the ones
349 with a node startup value manual or automatic.
350 Nodes marked as ONBOOT are skipped.
351 -m session display all active sessions and connections
352 -m session --sid=[sid] [ --print=level | --rescan | --logout ]
353 --op=[op] [--name=[name] --value=[value]]
354 perform operation for specific session with
355 session id sid. If no sid is given the operation
356 will be performed on all running sessions if possible.
357 --logout and --op work like they do in node mode,
358 but in session mode targetname and portal info is
361 Print level can be 0 to 2.
362 1 = Print basic session info like node we are
363 connected to and whether we are connected.
364 2 = Print iscsi params used.
365 3 = Print SCSI info like LUNs, device state.
366 If no sid and no operation is given print out the
368 -m iface --interface=iscsi_ifacename --op=[op] [--name=[name] --value=[value]]
370 perform operation on fiven interface with name
373 See below for examples.
374 -m host --host=hostno --print=level
375 Display information for a specific host if hostno
376 is passed in. If no hostno is passed in then info
377 for all hosts is printed.
379 Print level can be 0 to 4.
380 1 = Print info for how like its state, MAC, and
382 2 = Print basic session info for nodes the host
384 3 = Print iscsi params used.
385 4 = Print SCSI info like LUNs, device state.
386 -d, --debug debuglevel print debugging information
387 -V, --version display version and exit
388 -h, --help display this help and exit
391 5.1 iSCSI iface setup
392 =====================
394 The next sections describe how to setup iSCSI ifaces so you can bind
395 a session to a NIC port when using software iscsi (section 5.1.1), and
396 it describes how to setup ifaces for use with offload cards from Chelsio
397 and Broadcm (section 5.1.2).
400 5.1.1 How to setup iSCSI interfaces (iface) for binding
401 =======================================================
403 If you wish to allow the network susbsystem to figure out
404 the best path/NIC to use then you can skip this section. For example
405 if you have setup your portals and NICs on different subnets then
406 this the following is not needed for software iscsi.
409 This feature is experimental. The interface may change. When reporting
410 bugs, if you cannot do a "ping -I ethX target_portal", then check your
411 network settings first. If you cannot ping the portal, then you will
412 not be able to bind a session to a NIC.
414 What is a scsi_host and iface for software, hardware and partial
417 Software iscsi, like iscsi_tcp and iser, allocate a scsi_host per session
418 and does a single connection per session. As a result
419 /sys/class_scsi_host and /proc/scsi will report a scsi_host for
420 each connection/session you have logged into. Offload iscsi, like
421 Chelsio cxgb3i, allocates a scsi_host for each PCI device (each
422 port on a HBA will show up as a different PCI device so you get
423 a scsi_host per HBA port).
425 To manage both types of initiator stacks, iscsiadm uses the interface (iface)
426 structure. For each HBA port or for software iscsi for each network
427 device (ethX) or NIC, that you wish to bind sessions to you must create
428 a iface config /etc/iscsi/ifaces.
433 iface0 qla4xxx,00:c0:dd:08:63:e8,20.15.0.7,default,iqn.2005-06.com.redhat:madmax
434 iface1 qla4xxx,00:c0:dd:08:63:ea,20.15.0.9,default,iqn.2005-06.com.redhat:madmax
436 Will report iface configurations that are setup in /etc/iscsi/ifaces.
439 iface_name transport_name,hwaddress,ipaddress,net_ifacename,initiatorname
441 For software iscsi, you can create the iface configs by hand, but it is
442 reccomended that you use iscsiadm's iface mode. There is a iface.example in
443 /etc/iscsi/ifaces which can be used as a template for the daring.
445 For each network object you wish to bind a session to you must create
446 a seperate iface config in /etc/iscsi/ifaces and each iface config file
447 must have a unique name which is less than or equal to 64 characters.
451 If you have NIC1 with MAC address 00:0F:1F:92:6B:BF and NIC2 with
452 MAC address 00:C0:DD:08:63:E7 and you wanted to do software iscsi over
453 TCP/IP. Then in /etc/iscsi/ifaces/iface0 you would enter:
455 iface.transport_name = tcp
456 iface.hwaddress = 00:0F:1F:92:6B:BF
458 and in /etc/iscsi/ifaces/iface1 you would enter:
460 iface.transport_name = tcp
461 iface.hwaddress = 00:C0:DD:08:63:E7
463 Warning: Do not name a iface config file "default" or "iser".
464 They are special value/file that is used by the iscsi tools for
465 backward compatibility. If you name a iface default or iser, then
466 the behavior is not defined.
468 To use iscsiadm to create iface0 above for you run:
470 (This will create a new empty iface config. If there was already a iface
471 with the name "iface0" this command will overwrite it.)
472 # iscsiadm -m iface -I iface0 --op=new
474 (This will set the hwaddress.)
475 # iscsiadm -m iface -I iface0 --op=update -n iface.hwaddress -v 00:0F:1F:92:6B:BF
477 If you had sessions logged in iscsiadm will not update, overwrite
478 a iface. You must log out first. If you have a iface bound to a node/portal
479 but you have not logged in then, iscsiadm will update the config and
480 all existing bindings.
483 You should now skip to 5.1.3 to see how to log in using the iface and for
484 some helpful management commands.
488 5.1.2 Setting up a iface for a iSCSI offload card
489 =================================================
491 This section describes how to setup ifaces for use with Chelsio
494 By default, iscsiadm will create a iface for each Broadcom and Chelsio
495 port. The iface name will be of the form:
497 $transport/driver_name.$MAC_ADDRESS
502 default tcp,<empty>,<empty>,<empty>,<empty>
503 iser iser,<empty>,<empty>,<empty>,<empty>
504 cxgb3i.00:07:43:05:97:07 cxgb3i,00:07:43:05:97:07,<empty>,<empty>,<empty>
507 Will report iface configurations that are setup in /etc/iscsi/ifaces.
510 iface_name transport_name,hwaddress,ipaddress,net_ifacename,initiatorname
512 iface_name: name of iface
513 transport_name: name of driver
514 hwaddress: MAC address
515 ipaddress: IP address to use for this port
516 net_iface_name: Net_ifacename will be <empty> because change between
517 reboots. It is used for software iSCSI's vlan or alias binding.
518 initiatorname: Initiatorname to be used if you want to override the
519 default one in /etc/iscsi/initiatorname.iscsi.
523 To display these values in a more friendly run:
525 iscsiadm -m iface -I cxgb3i.00:07:43:05:97:07
526 # BEGIN RECORD 2.0-871
527 iface.iscsi_ifacename = cxgb3i.00:07:43:05:97:07
528 iface.net_ifacename = <empty>
529 iface.ipaddress = <empty>
530 iface.hwaddress = 00:07:43:05:97:07
531 iface.transport_name = cxgb3i
532 iface.initiatorname = <empty>
536 Before you can use the iface, you must set the IP address for the port
537 with the following command:
539 iscsiadm -m iface -I cxgb3i.00:07:43:05:97:07 -o update -n iface.ipaddress -v 20.15.0.66
543 For the name of the value we want to update we use the name from
544 the "iscsiadm -m iface -I cxgb3i.00:07:43:05:97:07" command which is
548 Now, we can use this iface to login into targets, which is described in the
552 5.1.3 Discoverying iSCSI targets/portals
553 ========================================
555 Be aware that iscsiadm will use the default route to do discovery. It will
556 not use the iface specified. So if you are using a offload card, you will
557 need a seperate network connection to the target for discovery purposes.
558 *This will be fixed in the next version of open-iscsi*
560 For compatibility reasons, when you run iscsiadm to do discovery, it
561 will check for interfaces in /etc/iscsi/iscsi/ifaces that are using
562 tcp for the iface.transport and it will bind the portals that are discovered
563 so that they will be logged in through those ifaces. This behavior can also
564 be overriden by passing in the interfaces you want to use. For the case
565 of offload like with cxgb3i and bnx2i this is required because the transport
568 For example if you had defined two interface but only wanted to use one
569 you can use the --interface/-I argument:
571 iscsiadm -m discoverydb -t st -p ip:port -I iface1 --discover -P 1
573 If you had defined interfaces but wanted the old behavior, where
574 we do not bind a session to a iface, then you can use the special iface
577 iscsiadm -m discoverydb -t st -p ip:port -I default --discover -P 1
579 And if you did not define any interfaces in /etc/iscsi/ifaces and do
580 not pass anything into iscsiadm, running iscsiadm will do the default
581 behavior, where we allow the network subsystem to decide which
584 If you later want to remove the bindings for a specific target and
585 iface then you can run:
587 iscsiadm -m node -T my_target -I iface0 --op=delete
589 To do this for a specific portal on a target run:
591 iscsiadm -m node -T my_target -p ip:port -I iface0 --op=delete
593 If you wanted to delete all bindinds for iface0 then you can run
595 iscsiadm -m node -I iface0 --op=delete
597 And for equalogic targets it is sometimes useful to remove by just portal
599 iscsiadm -m node -p ip:port -I iface0 --op=delete
602 To now log into targets it is the same as with sofware iscsi. See section
603 7 for how to get started.
608 5.2 iscsiadm examples
609 =====================
610 Usage examples using the one-letter options (see iscsiadm man page
615 - SendTargets iSCSI Discovery using the default driver and interface and
616 using the discovery settings for the discovery record with the
617 ID [192.168.1.1:3260].
619 ./iscsiadm -m discoverydb -t st -p 192.168.1.1:3260 --discover
621 This will search /etc/iscsi/send_targets for a record with the
622 ID [portal = 192.168.1.1:3260 and type = sendtargets. If found it
623 will perform discovery using the settings stored in the record.
624 If a record does not exist, it will be created using the iscsid.conf
627 For the ifaces, iscsiadm will first search /etc/iscsi/ifaces for
628 interfaces using software iscsi. If any are found then nodes found
629 during discovery will be setup so that they can logged in through
630 those interfaces. To specify a specific iface, pass the
631 -I argument for each iface.
633 - SendTargets iSCSI Discovery updating existing target records:
635 ./iscsiadm -m discoverydb -t sendtargets -p 192.168.1.1:3260 \
638 If there is a record for targetX and portalY exists in the DB, and
639 is returned during discovery, it will be updated with the info
640 from the iscsi.conf. No new portals will be added and stale
641 portals will not be removed.
643 - SendTargets iSCSI Discovery deleting existing target records:
645 ./iscsiadm -m discoverydb -t sendtargets -p 192.168.1.1:3260 \
648 If there a record for targetX and portalY exists in the DB, but
649 is not returned during discovery it will be removed from the DB.
650 No new portals will be added and existing portal records will not
653 Note: If a session is logged into portal we are going to delete
654 a record for, it will be logged out then the record will be
657 - SendTargets iSCSI Discovery adding new records:
659 ./iscsiadm -m discoverydb -t sendtargets -p 192.168.1.1:3260 \
662 If there targetX and portalY is returned during discovery and does
663 not have a record, it will be added. Existing records are not
666 - SendTargets iSCSI Discovery using multiple ops:
668 ./iscsiadm -m discoverydb -t sendtargets -p 192.168.1.1:3260 \
669 -o new -o delete --discover
671 This command will add new portals and delete records for portals
672 no longer returned. It will not change the record information for
675 - SendTargets iSCSI Discovery in nonpersistent mode:
677 ./iscsiadm -m discoverydb -t sendtargets -p 192.168.1.1:3260 \
678 -o nonpersistent --discover
680 This command will perform discovery, but not manipulate the node DB.
682 - SendTargets iSCSI Discovery with a specific interface. If you
683 wish to only use a subset of the interfaces in /etc/iscsi/ifaces
684 then you can pass them in during discovery:
686 ./iscsiadm -m discoverydb -t sendtargets -p 192.168.1.1:3260 \
687 --interface=iface0 --interface=iface1 --discover
689 Note that for software iscsi, we let the network layer select
690 which NIC to use for discovery, but for later logins iscsiadm
691 will use the NIC defined in the iface config.
693 qla4xxx support is very basic and experimental. It does not store
694 the record info in the card's FLASH or the node DB, so you must
695 rerun discovery every time the driver is reloaded.
697 - Manipulate SendTargets DB.
699 Create new SendTargets discovery record or overwrite an existing
700 discovery record with iscsid.conf discovery settings.
701 ./iscsiadm -m discoverydb -t sendtargets -p 192.168.1.1:3260 -o new
703 See discovery settings.
704 ./iscsiadm -m discoverydb -t sendtargets -p 192.168.1.1:3260 -o show
706 See hidden discovery settings like CHAP passwords
707 ./iscsiadm -m discoverydb -t sendtargets -p 192.168.1.1:3260 \
710 Set discovery setting.
711 ./iscsiadm -m discoverydb -t sendtargets -p 192.168.1.1:3260 \
712 -o update -n name -v value
714 Delete discovery record. This will also delete the records for
715 the targets found through the discovery source.
716 ./iscsiadm -m discoverydb -t sendtargets -p 192.168.1.1:3260 -o delete
718 Node mode. In node mode you can specify which records you want to log
719 into by specifying the targetname, ip address, port or interface
720 (if specifying the interface it must already be setup in the node db).
721 iscsiadm will search the node db, for records which match the values
722 you pass in, so if you pass in the targetname and interface, iscsiadm
723 will search for records with those values and operate on only them.
724 Passing in none of them will result in all node records being operated on.
726 - iSCSI Login to all portals on every node/starget through each interface
729 ./iscsiadm -m node -l
731 - iSCSI login to all portals on a node/target through each interface set
734 ./iscsiadm -m node -T iqn.2005-03.com.max -l
736 - iSCSI login to a specific portal through each interface set in the db:
738 ./iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260 -l
740 To specify a IPv6 address the following can be used:
742 ./iscsiadm -m node -T iqn.2005-03.com.max \
743 -p 2001:c90::211:9ff:feb8:a9e9 -l
745 The above command would use the default port, 3260. To specify a
746 port use the following:
748 ./iscsiadm -m node -T iqn.2005-03.com.max \
749 -p [2001:c90::211:9ff:feb8:a9e9]:3260 -l
751 - iSCSI Login to a specific portal through the NIC setup as iface0:
753 ./iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260 \
756 - iSCSI Logout to all portals on every node/starget through each interface
759 ./iscsiadm -m node -u
761 Warning: this does not check startup values like the logout/login all
762 option. Do not use this if you are running iscsi on your root disk.
764 - iSCSI logout to all portals on a node/target through each interface set
767 ./iscsiadm -m node -T iqn.2005-03.com.max -u
769 - iSCSI logout to a specific portal through each interface set in the db:
771 ./iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260 -u
773 - iSCSI Logout to a specific portal through the NIC setup as iface0:
775 ./iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260 \
778 - Changing iSCSI parameter:
780 ./iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260 \
781 -o update -n node.cnx[0].iscsi.MaxRecvDataSegmentLength -v 65536
783 You can also change paramaters for multiple records at once, by
784 specifying different combinations of the target, portal and interface
787 - Adding custom iSCSI portal:
789 ./iscsiadm -m node -o new -T iqn.2005-03.com.max \
790 -p 192.168.0.1:3260,2 -I iface4
792 The -I/--interface is optional. If not passed in, "default" is used.
793 For tcp or iser, this would allow the network layer to decide what is
796 Note that for this command the target portal group tag (TPGT) should
797 be passed in. If it is not passed in on the initial creation command
798 then the user must run iscsiadm again to set the value. Also
799 if the TPGT is not initially passed in, the old behavior of not
800 tracking whether the record was statically or dynamically created
803 - Adding custom NIC config to multiple targets:
805 ./iscsiadm -m node -o new -I iface4
807 This command will add a interface config using the iSCSI and SCSI
808 settings from iscsid.conf to every target that is in the node db.
810 - Removing iSCSI portal:
812 ./iscsiadm -m node -o delete -T iqn.2005-03.com.max -p 192.168.0.4:3260
814 You can also delete multiple records at once, by specifying different
815 combinations of the target, portal and interface like above.
817 - Display iSCSI portal onfiguration:
819 ./iscsiadm -m node -T iqn.2005-03.com.max -p 192.168.0.4:3260
823 ./iscsiadm -m node -o show -T iqn.2005-03.com.max -p 192.168.0.4:3260
824 You can also display multiple records at once, by specifying different
825 combinations of the target, portal and interface like above.
827 Note: running "iscsiadm -m node" will only display the records. It
828 will not display the configuration info. You must run,
829 "iscsiadm -m node -o show".
831 - Show all node records:
835 This will print the nodes using the old flat format where the
836 interface and driver are not displayed. To display that info
837 use the -P argument with the arguent "1":
839 ./iscsiadm -m node -P 1
841 - Show all records in discovery database:
843 ./iscsiadm -m discovery
845 - Show all records in discovery database and show the targets that
846 were discovered from each record:
848 ./iscsiadm -m discovery -P 1
850 - Display session statistics:
852 ./iscsiadm -m session -r 1 --stats
854 This function also works in node mode. Instead of the "-r $sid"
855 argument, you would pass in the node info like targetname and/or portal,
858 - Perform a SCSI scan on a session
860 ./iscsiadm -m session -r 1 --rescan
862 This function also works in node mode. Instead of the "-r $sid"
863 argument, you would pass in the node info like targetname and/or portal,
866 Note: Rescanning does not delete old LUNs. It will only pick up new
869 - Display running sessions:
871 ./iscsiadm -m session -P 1
876 The default configuration file is /etc/iscsi/iscsid.conf. This file contains
877 only configuration that could be overwritten by iSCSI Discovery,
878 or manualy updated via iscsiadm utility. Its OK if this file does not
879 exist in which case compiled-in default configuration will take place
880 for newer discovered Target nodes.
882 See the man page and the example file for the current syntax.
883 The manpages for iscsid, iscsiadm are in the doc subdirectory and can be
884 installed in the appropriate man page directories and need to be manually
885 copied into e.g. /usr/local/share/man8.
889 There are three steps needed to set up a system to use iSCSI storage:
890 7.1. iSCSI startup using the init script or manual startup.
891 7.2. Discover targets.
892 7.3. Automate target logins for future system reboots.
894 The init scripts will start the iSCSI daemon and log into any
895 portals that are set up for automatic login (discussed in 7.2)
896 or discovered through the discover daemon iscsid.conf params
897 (discussed in 7.1.2).
899 If your distro does not have a init script, then you will have to start the
900 daemon and log into the targets manually.
903 7.1.1 iSCSI startup using the init script
904 -----------------------------------------------
908 To start open-iscsi in Red Hat/Fedora you can do:
910 service open-iscsi start
912 To get open-iscsi to automatically start at run time you may have to
914 chkconfig --level <levels> open-iscsi on
915 Where <levels> are the run levels.
917 And, to automatically mount a file system during startup
918 you must have the partition entry in /etc/fstab marked with the "_netdev"
919 option. For example this would mount a iscsi disk sdb:
921 /dev/sdb /mnt/iscsi ext3 _netdev 0 0
925 Otherwise, if there is a initd script for your distro in etc/initd that
926 gets installed with "make install"
928 /etc/init.d/open-iscsi start
930 will usually get you started.
933 7.1.2 Manual Startup:
934 ---------------------
936 7.1.2.1 Starting up the iSCSI daemon (iscsid) and loading modules:
937 -----------------------------------------------------------------
938 If there is no initd script, you must start the tools by hand. First load the
941 modprobe -q iscsi_tcp
943 after that start iSCSI daemon process:
947 or alternatively, start it with debug enabled and with output
948 redirected to the current console:
952 7.1.2.2 Logging into Targets:
953 ---------------------------
954 Use the configuration utility, iscsiadm, to add/remove/update Discovery
955 records, iSCSI Node records or monitor active iSCSI sessions (see above or the
956 iscsiadm man files and see section 7.2 below for how to discover targets).
960 will print out the nodes that have been discovered as:
962 10.15.85.19:3260,3 iqn.1992-08.com.netapp:sn.33615311
963 10.15.84.19:3260,2 iqn.1992-08.com.netapp:sn.33615311
967 ip:port,target_portal_group_tag targetname
969 If you are using the iface argument or want to see the driver
970 info use the following:
972 ./iscsiadm -m node -P 1
974 Target: iqn.1992-08.com.netapp:sn.33615311
975 Portal: 10.15.84.19:3260,2
977 Portal: 10.15.85.19:3260,3
983 Portal ip_address:port,tpgt
986 where targetname is the name of the target and ip_address:port is the address
987 and port of the portal. tpgt, is the portal group tag of
988 the portal, and is not used in iscsiadm commands except for static
989 record creation. And iface name is the name of the iscsi interface
990 defined in /etc/iscsi/ifaces. If no interface was defined in
991 /etc/iscsi/ifaces or passed in, the default behavior is used.
992 Default here is iscsi_tcp/tcp to be used over which ever NIC the
993 network layer decides is best.
995 To login, take the ip, port and targetname from above and run:
997 ./iscsiadm -m node -T targetname -p ip:port -l
999 In this example we would run
1001 ./iscsiadm -m node -T iqn.1992-08.com.netapp:sn.33615311 -p 10.15.84.19:3260 -l
1003 Note: drop the portal group tag from the "iscsiadm -m node" output.
1005 7.2. Discover Targets
1006 ---------------------
1007 Once the iSCSI service is running, you can perform discovery using
1010 iscsiadm -m discoverydb -t sendtargets -p ip:port --discover
1012 where "ip" is the address of the portal and port is the port.
1014 To use iSNS you can run the discovery command with the type as "isns"
1015 and pass in the ip:port:
1017 iscsiadm -m discoverydb -t isns -p ip:port --discover
1019 Both commands will print out the list of all discovered targets and their
1022 # iscsiadm -m discoverydb -t st -p 10.15.85.19:3260 --discover
1023 10.15.84.19:3260,2 iqn.1992-08.com.netapp:sn.33615311
1024 10.15.85.19:3260,3 iqn.1992-08.com.netapp:sn.33615311
1026 The format for the output is:
1028 ip:port,tpgt targetname
1030 In this example, for the first target the ip address is 10.15.85.19.
1031 The port is 3260. The target portal group is 3. The target name
1032 is iqn.1992-08.com.netapp:sn.33615311.
1034 If you would also like to see the iscsi inteface which will be used
1035 for each session then use the --print[N] option.
1037 iscsiadm -m discoverydb -t sendtargets -p ip:port -P 1 --discover
1040 Target: iqn.1992-08.com.netapp:sn.33615311
1041 Portal: 10.15.84.19:3260,2
1043 Portal: 10.15.85.19:3260,3
1046 In this example, The IP address of the first portal is 10.15.84.19.
1047 The port is 3260. The target portal group is 3. The target name
1048 is iqn.1992-08.com.netapp:sn.33615311. The iface being used is iface2.
1050 While discovery targets are kept in the discovery db, they are
1051 useful only for re-discovery. The discovered targets (a.k.a. nodes)
1052 are stored as records in the node db.
1054 The discovered targets are not logged into yet. Rather than logging
1055 into the discovered nodes (making LUs from those nodes available as
1056 storage), it is better to automate the login to the nodes we need.
1058 If you wish to log into a target manually now, see section
1059 "7.1.2.2 Logging in targets" above.
1061 7.3. Automate Target Logins for Future System Statups
1062 -----------------------------------------------------
1063 Note: this may only work for distros with init scripts.
1065 To automate login to a node, use the following with the record ID
1066 (record ID is the targetname and portal) of the node discovered in the
1068 iscsiadm -m node -T targetname -p ip:port --op update -n node.startup -v automatic
1070 To set the automatic setting to all portals on a target through every
1071 interface setup for each protal, the following can be run:
1072 iscsiadm -m node -T targetname --op update -n node.startup -v automatic
1074 Or to set the "node.startup" attribute to "startup" as default for
1075 all sessions add the following to the /etc/iscsi/iscsid.conf:
1077 node.startup = automatic
1079 Setting this in iscsid.conf, will not affect existing nodes. It will only
1080 affect nodes that are discovered after setting the value.
1082 To login to all the automated nodes, simply restart the iscsi service:
1083 e.g /etc/init.d/open-iscsi restart. On your next startup the nodes will
1084 be logged into autmotically.
1087 7.4 Automatic Discovery and Login
1088 -----------------------------------
1090 Instead of running the iscsiadm discovery command and editing the
1091 startup setting, iscsid can be configured so that every X seconds
1092 it performs discovery and logs in and out of the portals return or
1093 no longer returned. In this mode, when iscsid starts it will check the
1094 discovery db for iSNS records with:
1096 discovery.isns.use_discoveryd = Yes
1098 and it will check for SendTargets discovery records that have the setting:
1100 discovery.sendtargets.use_discoveryd = Yes
1102 If set, iscsid will perform discovery to the address every
1103 discovery.isns.discoveryd_poll_inval or
1104 discovery.sendtargets.discoveryd_poll_inval seconds,
1105 and it will log into any portals found from the discovery source using
1106 the ifaces in /etc/iscsi/ifaces.
1108 Note that for iSNS the poll_interval does not have to be set. If not set,
1109 iscsid will only perform rediscovery when it gets a SCN from the server.
1112 # For servers like Microsofts where they allow SCN registrations, but do not
1113 # send SCN events, discovery.isns.poll_interval should be set to a non zero
1114 # value to auto discover new targets. This is also useful for servers like
1115 # linux-isns (SLES's iSNS server) where it sometimes does not send SCN
1116 # events in the proper format, so they may not get handled.
1124 - Create a SendTargets record by passing iscsiadm the "-o new" argument in
1126 # iscsiadm -m discoverydb -t st -p 20.15.0.7:3260 -o new
1127 New discovery record for [20.15.0.7,3260] added.
1129 - Set the use_discoveryd setting for the record.
1130 # iscsiadm -m discoverydb -t st -p 20.15.0.7:3260 -o update -n discovery.sendtargets.use_discoveryd -v Yes
1132 - Set the polling interval.
1133 # iscsiadm -m discoverydb -t st -p 20.15.0.7:3260 -o update -n discovery.sendtargets.discoveryd_poll_inval -v 30
1135 To have the new settings take effect restart iscsid by restarting the
1139 When iscsiadm is run with the -o new argument, it will use the
1140 discovery.sendtargets.use_discoveryd and
1141 discovery.sendtargets.discoveryd_poll_inval
1142 settings in iscsid.conf for the records initial settings. So if those
1143 are set in iscsid.conf, then you can skip the iscsiadm -o update
1149 - Create a iSNS record by passing iscsiadm the "-o new" argument in
1151 # iscsiadm -m discoverydb -t isns -p 20.15.0.7:3205 -o new
1152 New discovery record for [20.15.0.7,3205] added.
1154 - Set the use_discoveryd setting for the record.
1155 # iscsiadm -m discoverydb -t isns -p 20.15.0.7:3205 -o update -n discovery.isns.use_discoveryd -v Yes
1157 - [OPTIONAL: see iSNS note above] Set the polling interval if needed.
1158 # iscsiadm -m discoverydb -t st -p 20.15.0.7:3205 -o update -n discovery.isns.discoveryd_poll_inval -v 30
1160 To have the new settings take effect restart iscsid by restarting the
1164 When iscsiadm is run with the -o new argument, it will use the
1165 discovery.isns.use_discoveryd and discovery.isns.discoveryd_poll_inval
1166 settings in iscsid.conf for the records initial settings. So if those
1167 are set in iscsid.conf, then you can skip the iscsiadm -o update
1171 8. Advanced Configuration
1172 =========================
1174 8.1 iSCSI settings for dm-multipath
1175 -----------------------------------
1177 When using dm-multipath, the iSCSI timers should be set so that commands
1178 are quickly failed to the dm-multipath layer. For dm-multipath you should
1179 then set values like queue if no path, so that IO errors are retried and
1180 queued if all paths are failed in the multipath layer.
1183 8.1.1 iSCSI ping/Nop-Out settings
1184 ---------------------------------
1185 To quickly detect problems in the network, the iSCSI layer will send iSCSI
1186 pings (iSCSI NOP-Out requests) to the target. If a NOP-Out times out the
1187 iSCSI layer will respond by failing running commands and asking the SCSI
1188 layer to requeue them if possible (SCSI disk commands get 5 retries if not
1189 using multipath). If dm-multipath is being used the SCSI layer will fail
1190 the command to the multipath layer instead of retrying. The multipath layer
1191 will then retry the command on another path.
1193 To control how often a NOP-Out is sent the following value can be set:
1195 node.conn[0].timeo.noop_out_interval = X
1197 Where X is in seconds and the default is 10 seconds. To control the
1198 timeout for the NOP-Out the noop_out_timeout value can be used:
1200 node.conn[0].timeo.noop_out_timeout = X
1202 Again X is in seconds and the default is 15 seconds.
1204 Normally for these values you can use:
1206 node.conn[0].timeo.noop_out_interval = 5
1207 node.conn[0].timeo.noop_out_timeout = 10
1209 If there are a lot of IO error messages, then the above values may be too
1210 aggressive and you may need to increase the values for your network conditions
1211 and workload, or you may need to check your network for possible problems.
1214 8.1.2 replacement_timeout
1215 -------------------------
1216 The next iSCSI timer that will need to be tweaked is:
1218 node.session.timeo.replacement_timeout = X
1220 Here X is in seconds.
1222 replacement_timeout will control how long to wait for session re-establishment
1223 before failing pending SCSI commands and commands that are being operated on by
1224 the SCSI layer's error handler up to a higher level like multipath or to
1225 an application if multipath is not being used.
1228 8.1.2.1 Running Commands, the SCSI Error Handler, and replacement_timeout
1229 -------------------------------------------------------------------------
1230 Remember, from the Nop-out discussion that if a network problem is detected,
1231 the running commands are failed immediately. There is one exception to this
1232 and that is when the SCSI layer's error handler is running. To check if
1233 the SCSI error handler is running iscsiadm can be run as:
1235 iscsiadm -m session -P 3
1239 Host Number: X State: Recovery
1241 When the SCSI EH is running, commands will not be failed until
1242 node.session.timeo.replacement_timeout seconds.
1244 To modify the timer that starts the SCSI EH, you can either write
1245 directly to the device's sysfs file:
1247 echo X > /sys/block/sdX/device/timeout
1249 where X is in seconds or on most distros you can modify the udev rule.
1251 To modify the udev rule open /etc/udev/rules.d/50-udev.rules, and find the
1254 ACTION=="add", SUBSYSTEM=="scsi" , SYSFS{type}=="0|7|14", \
1255 RUN+="/bin/sh -c 'echo 60 > /sys$$DEVPATH/timeout'"
1257 And change the echo 60 part of the line to the value that you want.
1259 The default timeout for normal File System commands is 30 seconds when udev
1260 is not being used. If udev is used the default is the above value which
1261 is normally 60 seconds.
1264 8.1.2.2 Pending Commands and replacement_timeout
1265 ------------------------------------------------
1266 Commonly, the SCSI/BLOCK layer will queue 256 commands, but the path can
1267 only take 32. When a network problem is detected, the 32 commands
1268 in flight will be sent back to the SCSI layer immediately and because
1269 multipath is being used this will cause the commands to be sent to the multipath
1270 layer for execution on another path. However the other 96 commands that were
1271 still in the SCSI/BLOCK queue, will remain here until the session is
1272 re-established or until node.session.timeo.replacement_timeout seconds has
1273 gone by. After replacement_timeout seconds, the pending commands will be
1274 failed to the multipath layer, and all new incoming commands will be
1275 immediately failed back to the multipath layer. If a session is later
1276 re-established, then new commands will be queued and executed. Normally,
1277 multipathd's path tester mechanism will detect that the session has been
1278 re-established and the path is accessible again, and it will inform
1282 8.1.3 Optimal replacement_timeout Value
1283 ---------------------------------------
1285 The default value for replacement_timeout is 120 seconds, but because
1286 multipath's queue_if_no_path and no_path_retry setting can prevent IO errors
1287 from being propagated to the application, replacement_timeout can be set to a
1288 shorter value like 5 to 15 seconds. By setting it lower pending IO is quickly
1289 sent to a new path and executed while the iSCSI layer attempts
1290 re-establishment of the session. If all paths end up being failed, then the
1291 multipath and device mapper layer will internally queue IO based on the
1292 multipath.conf settings, instead of the iSCSI layer.
1295 8.2 iSCSI settings for iSCSI root
1296 ---------------------------------
1298 When accessing the root partition directly through a iSCSI disk, the
1299 iSCSI timers should be set so that iSCSI layer has several chances to try to
1300 re-establish a session and so that commands are not quickly requeued to
1301 the SCSI layer. Basically you want the opposite of when using dm-multipath.
1303 For this setup, you can turn off iSCSI pings by setting:
1305 node.conn[0].timeo.noop_out_interval = 0
1306 node.conn[0].timeo.noop_out_timeout = 0
1308 And you can turn the replacement_timer to a very long value:
1310 node.session.timeo.replacement_timeout = 86400
1313 9. iSCSI System Info
1314 ====================
1316 To get information about the running sessions: including the session and
1317 device state, session ids (sid) for session mode, and some of the
1318 negotiated parameters, run:
1320 iscsiadm -m session -P 2
1322 If you are looking for something shorter like just the sid to node mapping
1325 iscsiadm -m session -P 0
1329 This will print the list of running sessions with the format:
1331 driver [sid] ip:port,target_portal_group_tag targetname
1333 # iscsiadm -m session
1334 tcp [2] 10.15.84.19:3260,2 iqn.1992-08.com.netapp:sn.33615311
1335 tcp [3] 10.15.85.19:3260,3 iqn.1992-08.com.netapp:sn.33615311
1337 To print the hw address info use the -P option with "1":
1339 iscsiadm -m session -P 1
1341 This will print the sessions with the following format:
1343 Current Portal: portal currently logged into
1344 Persistent Portal: portal we would fall back to if we had got redirected during login
1345 Iface Transport: driver/transport_name
1346 Iface IPaddress: IP address of iface being used
1347 Iface HWaddress: HW address used to bind session
1348 Iface Netdev: netdev value used to bind session
1349 SID: iscsi sysfs session id
1350 iSCSI Connection State: iscsi state
1352 Note: if a older kernel is being used or if the session is not bound
1353 then the keyword "default" is print to indicate that the default
1354 network behavior is being used.
1357 #iscsiadm -m session -P 1
1358 Target: iqn.1992-08.com.netapp:sn.33615311
1359 Current Portal: 10.15.85.19:3260,3
1360 Persistent Portal: 10.15.85.19:3260,3
1361 Iface Transport: tcp
1362 Iface IPaddress: 10.11.14.37
1363 Iface HWaddress: default
1364 Iface Netdev: default
1366 iSCSI Connection State: LOGGED IN
1367 Internal iscsid Session State: NO CHANGE
1369 The connection state is currently not available for qla4xxx.
1372 To get a HBA/Host view of the session there is the host mode.
1377 cxgb3i: [7] 10.10.15.51,[00:07:43:05:97:07],eth3 <empty>
1379 This prints the list of iSCSI hosts in the system with the format:
1380 driver [hostno] ipaddress,[hwaddress],net_ifacename,initiatorname
1383 To print this info in a more user friendly way the -P argument can be used:
1385 iscsiadm -m host -P 1
1389 Initiatorname: <empty>
1390 IPaddress: 10.10.15.51
1391 HWaddress: 00:07:43:05:97:07
1394 Here, you can also see the sate of the host.
1396 You can also pass in any value from 1 - 4 to print more info like the
1397 sessions running through the host, what ifaces are being used and what
1398 devices are accessed through it.
1400 To print the info for a specific host then you can pass in the -H argument
1401 with the host number:
1402 iscsiadm -m host -P 1 -H 7