0845680984
  1. Configure Target (Targetcli)
  2. Configure iSCSI Target (tgt)
  3. Configure iSCSI Initiator

Configure iSCSI Initiator.
This example is based on the environment like follows.

+----------------------+          |          +----------------------+
| [   iSCSI Target   ] |10.0.0.30 | 10.0.0.51| [ iSCSI Initiator  ] |
|     iscsi.srv.local  +----------+----------+   client.srv.local   |
|                      |                     |                      |
+----------------------+                     +----------------------+

[1] Configure iSCSI Initiator to connect to iSCSI Target.

root@client:~# apt -y install open-iscsi
root@client:~# vi /etc/iscsi/initiatorname.iscsi
# change to the same IQN you set on the iSCSI target server
InitiatorName=iqn.2022-10.local.srv:client.initiator01
root@client:~# vi /etc/iscsi/iscsid.conf
# line 57: uncomment
node.session.auth.authmethod = CHAP
# line 61,62: uncomment and specify the username and password you set on the iSCSI target server
node.session.auth.username = username
node.session.auth.password = password
root@client:~# systemctl restart iscsid open-iscsi
# discover target
root@client:~# iscsiadm -m discovery -t sendtargets -p 10.0.0.30
10.0.0.30:3260,1 iqn.2022-10.local.srv:iscsi.target01
# confirm status after discovery
root@client:~# iscsiadm -m node -o show
# BEGIN RECORD 2.0-874
node.name = iqn.2022-10.local.srv:iscsi.target01
node.tpgt = 1
node.startup = manual
node.leading_login = No
.....
.....
node.conn[0].iscsi.IFMarker = No
node.conn[0].iscsi.OFMarker = No
# END RECORD

# login to the target
root@client:~# iscsiadm -m node --login
Logging in to [iface: default, target: iqn.2022-10.local.srv:iscsi.target01, portal: 10.0.0.30,3260] (multiple)
Login to [iface: default, target: iqn.2022-10.local.srv:iscsi.target01, portal: 10.0.0.30,3260] successful.

# confirm the established session
root@client:~# iscsiadm -m session -o show
tcp: [1] 10.0.0.30:3260,1 iqn.2022-10.local.srv:iscsi.target01 (non-flash)
# confirm the partitions
root@client:~# cat /proc/partitions
major minor  #blocks  name

   7        0      56264 loop0
   7        1      56268 loop1
   7        2      70624 loop2
   7        3      70764 loop3
   7        4      27740 loop4
 252        0   31457280 sda
 252        1       1024 sda1
 252        2    1048576 sda2
 252        3   30405632 sda3
 253        0   26214400 dm-0
  11        0    1048575 sr0
   8        0   10485760 sdb
# added new device provided from the target server as [sdb]

[2] After setting iSCSI device, configure on Initiator to use it like follows.

# create label
root@client:~# parted --script /dev/sdb "mklabel gpt"
# create partiton
root@client:~# parted --script /dev/sdb "mkpart primary 0% 100%"
# format with ext4
root@client:~# mkfs.ext4 /dev/sdb1
mke2fs 1.45.5 (06-Oct-2022)
Creating filesystem with 2617344 4k blocks and 655360 inodes
Filesystem UUID: f4255883-6b01-4ec1-b17c-358f86df1eba
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

root@client:~# mount /dev/sdb1 /mnt
root@client:~# df -hT
Filesystem                        Type      Size  Used Avail Use% Mounted on
udev                              devtmpfs  1.9G     0  1.9G   0% /dev
tmpfs                             tmpfs     394M  1.1M  393M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv ext4       25G  2.2G   22G  10% /
tmpfs                             tmpfs     2.0G     0  2.0G   0% /dev/shm
tmpfs                             tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs                             tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/vda2                         ext4      976M  103M  806M  12% /boot
/dev/loop0                        squashfs   55M   55M     0 100% /snap/core18/1705
/dev/loop1                        squashfs   55M   55M     0 100% /snap/core18/1754
/dev/loop2                        squashfs   69M   69M     0 100% /snap/lxd/14804
/dev/loop3                        squashfs   70M   70M     0 100% /snap/lxd/14890
/dev/loop4                        squashfs   28M   28M     0 100% /snap/snapd/7264
/dev/sdb1                         ext4      9.8G   37M  9.3G   1% /mnt
tmpfs                             tmpfs     394M     0  394M   0% /run/user/0

Leave a Comment

Your email address will not be published. Required fields are marked *

Bài viết gần đây:

Shopping Cart