kk@Jackson:/etc/iscsi$ ls -la
total 36
drwxr-xr-x 2 root root 4096 Feb 6 12:01 .
drwxr-xr-x 149 root root 12288 Feb 6 12:01 ..
-rw------- 1 root root 348 Feb 6 12:01 initiatorname.iscsi <<< このファイルを編集
-rw-r--r-- 1 root root 13334 Jan 19 2022 iscsid.conf
kk@Jackson:/etc/iscsi$
kk@Jackson:/etc/iscsi$ sido vim initiatorname.iscsi
iSCSI ターゲットとなるストレージ側で設定しているターゲット名(IQN)を指定します。
## DO NOT EDIT OR REMOVE THIS FILE!
## If you remove this file, the iSCSI daemon will not start.
## If you change the InitiatorName, existing access control lists
## may reject this initiator. The InitiatorName must be unique
## for each iSCSI initiator. Do NOT duplicate iSCSI InitiatorNames.
# InitiatorName=iqn.2004-10.com.ubuntu:01:c317f55f6df
InitiatorName=iqn.2004-04.com.qnap:ts-231k:iscsi.jonathan.45e748 <<< iSCSI ターゲットを指定
次に、同じフォルダーにある「iscsid.conf」ファイルを編集します。
kk@Jackson:/etc/iscsi$ ls -la
total 36
drwxr-xr-x 2 root root 4096 Feb 6 12:10 .
drwxr-xr-x 149 root root 12288 Feb 6 12:01 ..
-rw------- 1 root root 415 Feb 6 12:10 initiatorname.iscsi
-rw-r--r-- 1 root root 13334 Jan 19 2022 iscsid.conf <<< このファイルを編集
kk@Jackson:/etc/iscsi$
kk@Jackson:/etc/iscsi$ sido vim iscsid.conf
58行目から70行目にかけて設定をしていきます。
まず、CHAP 認証を有効にします。
次に、iSCSI ターゲット側で設定しているユーザー名とパスワードを指定します。
# *************
# CHAP Settings
# *************
# To enable CHAP authentication set node.session.auth.authmethod
# to CHAP. The default is None.
#node.session.auth.authmethod = CHAP
node.session.auth.authmethod = CHAP <<< コメントを外して有効化
# To configure which CHAP algorithms to enable set
# node.session.auth.chap_algs to a comma seperated list.
# The algorithms should be listen with most prefered first.
# Valid values are MD5, SHA1, SHA256, and SHA3-256.
# The default is MD5.
#node.session.auth.chap_algs = SHA3-256,SHA256,SHA1,MD5
# To set a CHAP username and password for initiator
# authentication by the target(s), uncomment the following lines:
#node.session.auth.username = username
#node.session.auth.password = password
node.session.auth.username = kkint <<< ユーザー名を指定
node.session.auth.password = 1234567890abcde <<< パスワードを指定
iSCSI のデーモンを再起動して、設定変更を読み込ませます。
kk@Jackson:/etc/iscsi$ sudo systemctl restart iscsid open-iscsi
kk@Jackson:/etc/iscsi$ systemctl status iscsid open-iscsi.service
● iscsid.service - iSCSI initiator daemon (iscsid)
Loaded: loaded (/lib/systemd/system/iscsid.service; disabled; vendor preset: enabled)
Active: active (running) since Tue 2024-02-06 12:18:43 JST; 18s ago
TriggeredBy: ● iscsid.socket
Docs: man:iscsid(8)
Process: 808615 ExecStartPre=/lib/open-iscsi/startup-checks.sh (code=exited, status=0/SUCCESS)
Process: 808618 ExecStart=/sbin/iscsid (code=exited, status=0/SUCCESS)
Main PID: 808620 (iscsid)
Tasks: 2 (limit: 4488)
Memory: 4.4M
CPU: 42ms
CGroup: /system.slice/iscsid.service
├─808619 /sbin/iscsid
└─808620 /sbin/iscsid
Feb 06 12:18:43 Jackson systemd[1]: Starting iSCSI initiator daemon (iscsid)...
Feb 06 12:18:43 Jackson iscsid[808618]: iSCSI logger with pid=808619 started!
Feb 06 12:18:43 Jackson systemd[1]: Started iSCSI initiator daemon (iscsid).
Feb 06 12:18:44 Jackson iscsid[808619]: iSCSI daemon with pid=808620 started!
○ open-iscsi.service - Login to default iSCSI targets
Loaded: loaded (/lib/systemd/system/open-iscsi.service; enabled; vendor preset: enabled)
Active: inactive (dead)
Condition: start condition failed at Tue 2024-02-06 12:18:43 JST; 18s ago
├─ ConditionDirectoryNotEmpty=|/etc/iscsi/nodes was not met
└─ ConditionDirectoryNotEmpty=|/sys/class/iscsi_session was not met
Docs: man:iscsiadm(8)
man:iscsid(8)
Feb 06 12:01:54 Jackson systemd[1]: Condition check resulted in Login to default iSCSI targets be>
Feb 06 12:18:43 Jackson systemd[1]: Condition check resulted in Login to default iSCSI targets be>
kk@Jackson:/etc/iscsi$