🍨

Debian11 で iscsi

2023/08/10に公開

用語

  • ターゲット
    NFSでいうところの、エクスポートする側。

  • イニシエーター
    NFSでいうところの、マウントする側。

root@debian11-1:~# apt install --no-install-recommends parted

準備

必要なパッケージをインストールします。

ターゲット側

# apt install --no-install-recommends targetcli-fb

イニシエーター側

# apt install --no-install-recommends open-iscsi

仮想イメージファイルの利用

基本的な例として、仮想イメージファイルを利用してみます。

ターゲット側の設定

イメージファイルを保存するディレクトリを作成しておきます。

# mkdir /var/lib/iscsi_disks
# ls -ld /var/lib/iscsi_disks
drwxr-xr-x 2 root root 4096 Aug  9 18:10 /var/lib/iscsi_disks

targetcli を実行して、シェルから設定を進めます。

# targetcli
targetcli shell version 2.1.53
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/>

仮想イメージファイルを作成します。

/> cd backstores/fileio

/backstores/fileio> create disk01 /var/lib/iscsi_disks/disk01.img 1GB
Created fileio disk01 with size 1073741824

ターゲットを作成します。

/backstores/fileio> cd /iscsi

/iscsi> create iqn.2023-02.org.example:debian11-1.target01
Created target iqn.2023-02.org.example:debian11-1.target01.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.

LUNを作成します。

/iscsi> cd iqn.2023-02.org.example:debian11-1.target01/tpg1/luns

/iscsi/iqn.20...t01/tpg1/luns> create /backstores/fileio/disk01
Created LUN 0.
/iscsi/iqn.20...t01/tpg1/luns> cd ../acls

/iscsi/iqn.20...t01/tpg1/acls> create iqn.2023-02.org.example:node01.initiator01
Created Node ACL for iqn.2023-02.org.example:node01.initiator01
Created mapped LUN 0.

/iscsi/iqn.20...t01/tpg1/acls> cd iqn.2023-02.org.example:node01.initiator01

/iscsi/iqn.20...1.initiator01> set auth userid=user
Parameter userid is now 'user'.

/iscsi/iqn.20...1.initiator01> set auth password=password
Parameter password is now 'password'.

/iscsi/iqn.20...1.initiator01> exit
Global pref auto_save_on_exit=true
Configuration saved to /etc/rtslib-fb-target/saveconfig.json

設定を確認します。

# targetcli ls
o- / ......................................................................................................................... [...]
  o- backstores .............................................................................................................. [...]
  | o- block .................................................................................................. [Storage Objects: 0]
  | o- fileio ................................................................................................. [Storage Objects: 1]
  | | o- disk01 .................................................... [/var/lib/iscsi_disks/disk01.img (1.0GiB) write-back activated]
  | |   o- alua ................................................................................................... [ALUA Groups: 1]
  | |     o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]
  | o- pscsi .................................................................................................. [Storage Objects: 0]
  | o- ramdisk ................................................................................................ [Storage Objects: 0]
  o- iscsi ............................................................................................................ [Targets: 1]
  | o- iqn.2023-02.org.example:debian11-1.target01 ....................................................................... [TPGs: 1]
  |   o- tpg1 ............................................................................................... [no-gen-acls, no-auth]
  |     o- acls .......................................................................................................... [ACLs: 1]
  |     | o- iqn.2023-02.org.example:node01.initiator01 ........................................................... [Mapped LUNs: 1]
  |     |   o- mapped_lun0 ............................................................................... [lun0 fileio/disk01 (rw)]
  |     o- luns .......................................................................................................... [LUNs: 1]
  |     | o- lun0 ............................................. [fileio/disk01 (/var/lib/iscsi_disks/disk01.img) (default_tg_pt_gp)]
  |     o- portals .................................................................................................... [Portals: 1]
  |       o- 0.0.0.0:3260 ..................................................................................................... [OK]
  o- loopback ......................................................................................................... [Targets: 0]
  o- vhost ............................................................................................................ [Targets: 0]
  o- xen-pvscsi ....................................................................................................... [Targets: 0]

イニシエーター側の設定

設定ファイルを作成します。

/etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2023-02.org.example:node01.initiator01

認証の設定をします。

# cp -pi /etc/iscsi/iscsid.conf /etc/iscsi/iscsid.conf.000
# vi /etc/iscsi/iscsid.conf

# diff -u /etc/iscsi/iscsid.conf /etc/iscsi/iscsid.conf.000
--- /etc/iscsi/iscsid.conf      2023-08-09 18:26:21.912000000 -0400
+++ /etc/iscsi/iscsid.conf.000  2020-12-18 13:58:08.000000000 -0500
@@ -56,7 +56,6 @@
 # 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.
@@ -69,8 +68,6 @@
 # authentication by the target(s), uncomment the following lines:
 #node.session.auth.username = username
 #node.session.auth.password = password
-node.session.auth.username = user
-node.session.auth.password = password

 # To set a CHAP username and password for target(s)
 # authentication by the initiator, uncomment the following lines:

設定を変更したらサービスを再起動します。

# systemctl restart iscsid open-iscsi
# iscsiadm -m discovery -t sendtargets -p 10.2.1.242
10.2.1.242:3260,1 iqn.2023-02.org.example:debian11-1.target01

# iscsiadm -m node -o show
# BEGIN RECORD 2.1.3
node.name = iqn.2023-02.org.example:debian11-1.target01
node.tpgt = 1
node.startup = manual
node.leading_login = No
:
# iscsiadm -m node --login
Logging in to [iface: default, target: iqn.2023-02.org.example:debian11-1.target01, portal: 10.2.1.242,3260]
Login to [iface: default, target: iqn.2023-02.org.example:debian11-1.target01, portal: 10.2.1.242,3260] successful.

# iscsiadm -m session -o show
tcp: [1] 10.2.1.242:3260,1 iqn.2023-02.org.example:debian11-1.target01 (non-flash)

ブロックデバイスとして認識されているので、通常どおりに利用していきます。

# lsblk -S
NAME HCTL       TYPE VENDOR   MODEL         REV SERIAL                               TRAN
sda  2:0:0:0    disk LIO-ORG  disk01       4.0  de80b906-d590-4c9d-8418-197053c0325e iscsi
sr0  1:0:0:0    rom  QEMU     QEMU_DVD-ROM 2.5+ QM00003                              ata

# parted /dev/sda print
Error: /dev/sda: unrecognised disk label
Model: LIO-ORG disk01 (scsi)
Disk /dev/sda: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:

# parted /dev/sda mklabel msdos print
Model: LIO-ORG disk01 (scsi)
Disk /dev/sda: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start  End  Size  Type  File system  Flags

Information: You may need to update /etc/fstab.

ターゲット側で確認します。

# targetcli sessions
alias: debian11-1       sid: 1 type: Normal session-state: LOGGED_IN

利用の停止

イニシエーター側で、利用を停止します。

# iscsiadm --mode node --logoutall=all
Logging out of session [sid: 1, target: iqn.2023-02.org.example:debian11-1.target01, portal: 10.2.1.242,3260]
Logout of [sid: 1, target: iqn.2023-02.org.example:debian11-1.target01, portal: 10.2.1.242,3260] successful.


# iscsiadm -m session -o show
iscsiadm: No active sessions.

ターゲット側で確認します。

root@debian11-1:~# targetcli sessions
(no open sessions)

パーティションの利用

ドライブに切ったパーティションを利用してみます。

ターゲット側でパーティションを切ります。

# apt install --no-install-recommends parted

# parted /dev/vdb print
Error: /dev/vdb: unrecognised disk label
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 4295MB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:

# parted /dev/vdb mklabel msdos print
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 4295MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start  End  Size  Type  File system  Flags

Information: You may need to update /etc/fstab.

# parted /dev/vdb mkpart primary 0% 1GB print
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 4295MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size   Type     File system  Flags
 1      1049kB  1000MB  999MB  primary               lba

Information: You may need to update /etc/fstab.
# blkid
/dev/vda1: UUID="82315f0a-c6d0-4368-88f4-47818b5ebdab" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="2682f464-01"
/dev/vda5: UUID="62cebae5-4439-4149-8690-a99575d8dc8e" TYPE="swap" PARTUUID="2682f464-05"
/dev/vdb1: PARTUUID="1da448db-01"

ターゲット側の設定

# targetcli
targetcli shell version 2.1.53
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/iscsi/iqn.20...1.initiator01> cd /backstores/block

/backstores/block> create block01 /dev/disk/by-partuuid/1da448db-01
Created block storage object block01 using /dev/disk/by-partuuid/1da448db-01.
/backstores/block> cd /iscsi

/iscsi> create iqn.2023-02.org.example:debian11-1.target02
Created target iqn.2023-02.org.example:debian11-1.target02.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.

/iscsi> cd iqn.2023-02.org.example:debian11-1.target02/tpg1/luns

/iscsi/iqn.20...t02/tpg1/luns> create /backstores/block/block01
Created LUN 0.
/iscsi/iqn.20...t02/tpg1/luns> cd ../acls

/iscsi/iqn.20...t02/tpg1/acls> create iqn.2023-02.org.example:node01.initiator01
Created Node ACL for iqn.2023-02.org.example:node01.initiator01
Created mapped LUN 0.

/iscsi/iqn.20...t02/tpg1/acls> cd iqn.2023-02.org.example:node01.initiator01

/iscsi/iqn.20...1.initiator01> set auth userid=user
Parameter userid is now 'user'.

/iscsi/iqn.20...1.initiator01> set auth password=password
Parameter password is now 'password'.

/iscsi/iqn.20...1.initiator01> exit
Global pref auto_save_on_exit=true
Configuration saved to /etc/rtslib-fb-target/saveconfig.json

設定を確認します。

# targetcli ls
o- / ......................................................................................................................... [...]
  o- backstores .............................................................................................................. [...]
  | o- block .................................................................................................. [Storage Objects: 1]
  | | o- block01 ............................................... [/dev/disk/by-partuuid/1da448db-01 (953.0MiB) write-thru activated]
  | |   o- alua ................................................................................................... [ALUA Groups: 1]
  | |     o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]
  | o- fileio ................................................................................................. [Storage Objects: 1]
  | | o- disk01 .................................................... [/var/lib/iscsi_disks/disk01.img (1.0GiB) write-back activated]
  | |   o- alua ................................................................................................... [ALUA Groups: 1]
  | |     o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]
  | o- pscsi .................................................................................................. [Storage Objects: 0]
  | o- ramdisk ................................................................................................ [Storage Objects: 0]
  o- iscsi ............................................................................................................ [Targets: 2]
  | o- iqn.2023-02.org.example:debian11-1.target01 ....................................................................... [TPGs: 1]
  | | o- tpg1 ............................................................................................... [no-gen-acls, no-auth]
  | |   o- acls .......................................................................................................... [ACLs: 1]
  | |   | o- iqn.2023-02.org.example:node01.initiator01 ........................................................... [Mapped LUNs: 1]
  | |   |   o- mapped_lun0 ............................................................................... [lun0 fileio/disk01 (rw)]
  | |   o- luns .......................................................................................................... [LUNs: 1]
  | |   | o- lun0 ............................................. [fileio/disk01 (/var/lib/iscsi_disks/disk01.img) (default_tg_pt_gp)]
  | |   o- portals .................................................................................................... [Portals: 1]
  | |     o- 0.0.0.0:3260 ..................................................................................................... [OK]
  | o- iqn.2023-02.org.example:debian11-1.target02 ....................................................................... [TPGs: 1]
  |   o- tpg1 ............................................................................................... [no-gen-acls, no-auth]
  |     o- acls .......................................................................................................... [ACLs: 1]
  |     | o- iqn.2023-02.org.example:node01.initiator01 ........................................................... [Mapped LUNs: 1]
  |     |   o- mapped_lun0 ............................................................................... [lun0 block/block01 (rw)]
  |     o- luns .......................................................................................................... [LUNs: 1]
  |     | o- lun0 ........................................... [block/block01 (/dev/disk/by-partuuid/1da448db-01) (default_tg_pt_gp)]
  |     o- portals .................................................................................................... [Portals: 1]
  |       o- 0.0.0.0:3260 ..................................................................................................... [OK]
  o- loopback ......................................................................................................... [Targets: 0]
  o- vhost ............................................................................................................ [Targets: 0]
  o- xen-pvscsi ....................................................................................................... [Targets: 0]

イニシエーター側の設定

/etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2023-02.org.example:node01.initiator01
# iscsiadm -m discovery -t sendtargets -p 10.2.1.242
10.2.1.242:3260,1 iqn.2023-02.org.example:debian11-1.target01
10.2.1.242:3260,1 iqn.2023-02.org.example:debian11-1.target02

# iscsiadm -m node -o show
# BEGIN RECORD 2.1.3
node.name = iqn.2023-02.org.example:debian11-1.target01
node.tpgt = 1
node.startup = manual
node.leading_login = No
:
:

# BEGIN RECORD 2.1.3
node.name = iqn.2023-02.org.example:debian11-1.target02
node.tpgt = 1
node.startup = manual
node.leading_login = No
:
:

# iscsiadm -m node --login
Logging in to [iface: default, target: iqn.2023-02.org.example:debian11-1.target02, portal: 10.2.1.242,3260]
Logging in to [iface: default, target: iqn.2023-02.org.example:debian11-1.target01, portal: 10.2.1.242,3260]
Login to [iface: default, target: iqn.2023-02.org.example:debian11-1.target02, portal: 10.2.1.242,3260] successful.
Login to [iface: default, target: iqn.2023-02.org.example:debian11-1.target01, portal: 10.2.1.242,3260] successful.

# iscsiadm -m session -o show
tcp: [2] 10.2.1.242:3260,1 iqn.2023-02.org.example:debian11-1.target02 (non-flash)
tcp: [3] 10.2.1.242:3260,1 iqn.2023-02.org.example:debian11-1.target01 (non-flash)
# lsblk -S
NAME HCTL       TYPE VENDOR   MODEL         REV SERIAL                               TRAN
sda  3:0:0:0    disk LIO-ORG  disk01       4.0  de80b906-d590-4c9d-8418-197053c0325e iscsi
sdb  2:0:0:0    disk LIO-ORG  block01      4.0  841357e3-4d9e-48fe-b0db-0ab24925688f iscsi
sr0  1:0:0:0    rom  QEMU     QEMU_DVD-ROM 2.5+ QM00003                              ata

# parted /dev/sdb print
Error: /dev/sdb: unrecognised disk label
Model: LIO-ORG block01 (scsi)
Disk /dev/sdb: 999MB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:

# parted /dev/sdb mklabel msdos print
Model: LIO-ORG block01 (scsi)
Disk /dev/sdb: 999MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start  End  Size  Type  File system  Flags

Information: You may need to update /etc/fstab.

ターゲット側で確認します。

# targetcli sessions
alias: debian11-1       sid: 1 type: Normal session-state: LOGGED_IN
alias: debian11-1       sid: 2 type: Normal session-state: LOGGED_IN

イニシエーターの追加

今度は、イニシエーターを追加してみます。

ターゲット側

root@debian11-1:~# targetcli
targetcli shell version 2.1.53
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/iscsi/iqn.20...1.initiator01> cd /iscsi/iqn.2023-02.org.example:debian11-1.target02/tpg1/acls

/iscsi/iqn.20...t02/tpg1/acls> create iqn.2023-02.org.example:node01.initiator02
Created Node ACL for iqn.2023-02.org.example:node01.initiator02
Created mapped LUN 0.

/iscsi/iqn.20...t02/tpg1/acls> cd iqn.2023-02.org.example:node01.initiator02

/iscsi/iqn.20...1.initiator02> set auth userid=user
Parameter userid is now 'user'.

/iscsi/iqn.20...1.initiator02> set auth password=password
Parameter password is now 'password'.

/iscsi/iqn.20...1.initiator02> cd /iscsi/iqn.2023-02.org.example:debian11-1.target01/tpg1/acls

/iscsi/iqn.20...t01/tpg1/acls> create iqn.2023-02.org.example:node01.initiator02
Created Node ACL for iqn.2023-02.org.example:node01.initiator02
Created mapped LUN 0.

/iscsi/iqn.20...t01/tpg1/acls> cd iqn.2023-02.org.example:node01.initiator02

/iscsi/iqn.20...1.initiator02> set auth userid=user
Parameter userid is now 'user'.

/iscsi/iqn.20...1.initiator02> set auth password=password
Parameter password is now 'password'.

/iscsi/iqn.20...1.initiator02> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/rtslib-fb-target/backup/.
Configuration saved to /etc/rtslib-fb-target/saveconfig.json
# targetcli ls
o- / ......................................................................................................................... [...]
  o- backstores .............................................................................................................. [...]
  | o- block .................................................................................................. [Storage Objects: 1]
  | | o- block01 ............................................... [/dev/disk/by-partuuid/1da448db-01 (953.0MiB) write-thru activated]
  | |   o- alua ................................................................................................... [ALUA Groups: 1]
  | |     o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]
  | o- fileio ................................................................................................. [Storage Objects: 1]
  | | o- disk01 .................................................... [/var/lib/iscsi_disks/disk01.img (1.0GiB) write-back activated]
  | |   o- alua ................................................................................................... [ALUA Groups: 1]
  | |     o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]
  | o- pscsi .................................................................................................. [Storage Objects: 0]
  | o- ramdisk ................................................................................................ [Storage Objects: 0]
  o- iscsi ............................................................................................................ [Targets: 2]
  | o- iqn.2023-02.org.example:debian11-1.target01 ....................................................................... [TPGs: 1]
  | | o- tpg1 ............................................................................................... [no-gen-acls, no-auth]
  | |   o- acls .......................................................................................................... [ACLs: 2]
  | |   | o- iqn.2023-02.org.example:node01.initiator01 ........................................................... [Mapped LUNs: 1]
  | |   | | o- mapped_lun0 ............................................................................... [lun0 fileio/disk01 (rw)]
  | |   | o- iqn.2023-02.org.example:node01.initiator02 ........................................................... [Mapped LUNs: 1]
  | |   |   o- mapped_lun0 ............................................................................... [lun0 fileio/disk01 (rw)]
  | |   o- luns .......................................................................................................... [LUNs: 1]
  | |   | o- lun0 ............................................. [fileio/disk01 (/var/lib/iscsi_disks/disk01.img) (default_tg_pt_gp)]
  | |   o- portals .................................................................................................... [Portals: 1]
  | |     o- 0.0.0.0:3260 ..................................................................................................... [OK]
  | o- iqn.2023-02.org.example:debian11-1.target02 ....................................................................... [TPGs: 1]
  |   o- tpg1 ............................................................................................... [no-gen-acls, no-auth]
  |     o- acls .......................................................................................................... [ACLs: 2]
  |     | o- iqn.2023-02.org.example:node01.initiator01 ........................................................... [Mapped LUNs: 1]
  |     | | o- mapped_lun0 ............................................................................... [lun0 block/block01 (rw)]
  |     | o- iqn.2023-02.org.example:node01.initiator02 ........................................................... [Mapped LUNs: 1]
  |     |   o- mapped_lun0 ............................................................................... [lun0 block/block01 (rw)]
  |     o- luns .......................................................................................................... [LUNs: 1]
  |     | o- lun0 ........................................... [block/block01 (/dev/disk/by-partuuid/1da448db-01) (default_tg_pt_gp)]
  |     o- portals .................................................................................................... [Portals: 1]
  |       o- 0.0.0.0:3260 ..................................................................................................... [OK]
  o- loopback ......................................................................................................... [Targets: 0]
  o- vhost ............................................................................................................ [Targets: 0]
  o- xen-pvscsi ....................................................................................................... [Targets: 0]

イニシエーター側

新たなイニシエータで、必要なパッケージをインストールします。

# apt install --no-install-recommends open-iscsi
/etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2023-02.org.example:node01.initiator02
# cp -pi /etc/iscsi/iscsid.conf /etc/iscsi/iscsid.conf.000
# vi /etc/iscsi/iscsid.conf

# diff -u /etc/iscsi/iscsid.conf /etc/iscsi/iscsid.conf.000
--- /etc/iscsi/iscsid.conf      2023-08-09 19:20:09.180000000 -0400
+++ /etc/iscsi/iscsid.conf.000  2020-12-18 13:58:08.000000000 -0500
@@ -56,7 +56,6 @@
 # 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.
@@ -69,8 +68,6 @@
 # authentication by the target(s), uncomment the following lines:
 #node.session.auth.username = username
 #node.session.auth.password = password
-node.session.auth.username = user
-node.session.auth.password = password

 # To set a CHAP username and password for target(s)
 # authentication by the initiator, uncomment the following lines:
# systemctl restart iscsid open-iscsi
# iscsiadm -m discovery -t sendtargets -p 10.2.1.242
10.2.1.242:3260,1 iqn.2023-02.org.example:debian11-1.target01
10.2.1.242:3260,1 iqn.2023-02.org.example:debian11-1.target02
# iscsiadm -m node -o show
# BEGIN RECORD 2.1.3
node.name = iqn.2023-02.org.example:debian11-1.target01
node.tpgt = 1
node.startup = manual
node.leading_login = No
:
:
# BEGIN RECORD 2.1.3
node.name = iqn.2023-02.org.example:debian11-1.target02
node.tpgt = 1
node.startup = manual
node.leading_login = No
:
:
# iscsiadm -m node --login
Logging in to [iface: default, target: iqn.2023-02.org.example:debian11-1.target02, portal: 10.2.1.242,3260]
Logging in to [iface: default, target: iqn.2023-02.org.example:debian11-1.target01, portal: 10.2.1.242,3260]
Login to [iface: default, target: iqn.2023-02.org.example:debian11-1.target02, portal: 10.2.1.242,3260] successful.
Login to [iface: default, target: iqn.2023-02.org.example:debian11-1.target01, portal: 10.2.1.242,3260] successful.
# iscsiadm -m session -o show
tcp: [1] 10.2.1.242:3260,1 iqn.2023-02.org.example:debian11-1.target02 (non-flash)
tcp: [2] 10.2.1.242:3260,1 iqn.2023-02.org.example:debian11-1.target01 (non-flash)
# lsblk -S
NAME HCTL       TYPE VENDOR   MODEL         REV SERIAL                               TRAN
sda  3:0:0:0    disk LIO-ORG  disk01       4.0  de80b906-d590-4c9d-8418-197053c0325e iscsi
sdb  2:0:0:0    disk LIO-ORG  block01      4.0  841357e3-4d9e-48fe-b0db-0ab24925688f iscsi
sr0  1:0:0:0    rom  QEMU     QEMU_DVD-ROM 2.5+ QM00003                              ata

# parted /dev/sda print
Model: LIO-ORG disk01 (scsi)
Disk /dev/sda: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start  End  Size  Type  File system  Flags

# parted /dev/sdb print
Model: LIO-ORG block01 (scsi)
Disk /dev/sdb: 999MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start  End  Size  Type  File system  Flags

ターゲット側で確認します。

# targetcli sessions
alias: debian11-0       sid: 2 type: Normal session-state: LOGGED_IN
alias: debian11-1       sid: 1 type: Normal session-state: LOGGED_IN
alias: debian11-0       sid: 3 type: Normal session-state: LOGGED_IN
alias: debian11-1       sid: 2 type: Normal session-state: LOGGED_IN

雑多

自動ログイン設定

ターゲット側でOS起動時に自動ログインする設定

# iscsiadm --mode node -o update -n node.startup -v automatic

# iscsiadm -m node -o show
# BEGIN RECORD 2.1.3
node.name = iqn.2023-02.org.example:debian11-1.target01
node.tpgt = 1
node.startup = automatic
node.leading_login = No
:
# BEGIN RECORD 2.1.3
node.name = iqn.2023-02.org.example:debian11-1.target02
node.tpgt = 1
node.startup = automatic
node.leading_login = No
:

特定のターゲットだけログアウト

# iscsiadm --mode node --target iqn.2023-02.org.example:debian11-1.target01 --portal 10.2.1.242 --logout
Logging out of session [sid: 2, target: iqn.2023-02.org.example:debian11-1.target01, portal: 10.2.1.242,3260]
Logout of [sid: 2, target: iqn.2023-02.org.example:debian11-1.target01, portal: 10.2.1.242,3260] successful.

特定のターゲットだけログイン

# iscsiadm --mode node --target iqn.2023-02.org.example:debian11-1.target01 --login
Logging in to [iface: default, target: iqn.2023-02.org.example:debian11-1.target01, portal: 10.2.1.242,3260]
Login to [iface: default, target: iqn.2023-02.org.example:debian11-1.target01, portal: 10.2.1.242,3260] successful.
GitHubで編集を提案

Discussion