English Chinese (Simplified) (zh_CN)
The iSCSI initiator described in this section is supported starting with FreeBSD 10.0-RELEASE. To use the iSCSI initiator available in older versions, refer to man:iscontrol[8].
The iSCSI initiator requires that the man:iscsid[8] daemon is running. This daemon does not use a configuration file. To start it automatically at boot, add this line to [.filename]#/etc/rc.conf#:
iscsid_enable="YES"
iscsid_enable="YES"
To start man:iscsid[8] now, run this command:
# service iscsid start
Connecting to a target can be done with or without an [.filename]#/etc/iscsi.conf# configuration file. This section demonstrates both types of connections. 可以用<filename>/etc/iscsi.conf</filename>配置文件连接到目标,也可以不使用。本节演示了两种连接类型。
To connect an initiator to a single target, specify the IP address of the portal and the name of the target:
# iscsictl -A -p 10.10.10.10 -t iqn.2012-06.com.example:target0
To verify if the connection succeeded, run `iscsictl` without any arguments. The output should look similar to this:
Target name Target portal State
iqn.2012-06.com.example:target0 10.10.10.10 Connected: da0
Target name Target portal State
iqn.2012-06.com.example:target0 10.10.10.10 Connected: da0
In this example, the iSCSI session was successfully established, with [.filename]#/dev/da0# representing the attached LUN. If the `iqn.2012-06.com.example:target0` target exports more than one LUN, multiple device nodes will be shown in that section of the output:
Connected: da0 da1 da2.
Connected: da0 da1 da2.
Any errors will be reported in the output, as well as the system logs. For example, this message usually means that the man:iscsid[8] daemon is not running:
Target name Target portal State
iqn.2012-06.com.example:target0 10.10.10.10 Waiting for iscsid(8)
Target name Target portal State
iqn.2012-06.com.example:target0 10.10.10.10 Waiting for iscsid(8)
The following message suggests a networking problem, such as a wrong IP address or port:
Target name Target portal State
iqn.2012-06.com.example:target0 10.10.10.11 Connection refused
Target name Target portal State
iqn.2012-06.com.example:target0 10.10.10.11 Connection refused
Target name Target portal State
iqn.2012-06.com.example:target0 10.10.10.10 Not found
Target name Target portal State
iqn.2012-06.com.example:target0 10.10.10.10 Not found
Target name Target portal State
iqn.2012-06.com.example:target0 10.10.10.10 Authentication failed
Target name Target portal State
iqn.2012-06.com.example:target0 10.10.10.10 Authentication failed
To specify a CHAP username and secret, use this syntax:
# iscsictl -A -p 10.10.10.10 -t iqn.2012-06.com.example:target0 -u user -s secretsecret