Saturday, November 22, 2025

iSCSI : Configure iSCSI Initiator

 

iSCSI : 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  ] |
|     dlp.srv.world    +----------+----------+   node01.srv.world   |
|                      |                     |                      |
+----------------------+                     +----------------------+

[1]Configure iSCSI Initiator to connect to iSCSI Target.
root@node01:~# 
apt -y install open-iscsi
root@node01:~# 
vi /etc/iscsi/initiatorname.iscsi
# change to the same IQN you set on the iSCSI target server

InitiatorName=
iqn.2025-08.world.srv:node01.initiator
root@node01:~# 
vi /etc/iscsi/iscsid.conf
# line 74 : uncomment

node.session.auth.authmethod = CHAP
# line 86,87: 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@node01:~# 
systemctl restart iscsid open-iscsi
# discover target

root@node01:~# 
iscsiadm -m discovery -t sendtargets -p 10.0.0.30

10.0.0.30:3260,1 iqn.2025-08.world.srv:dlp.target01
# confirm status after discovery

root@node01:~# 
iscsiadm -m node -o show

# BEGIN RECORD 2.1.11
node.name = iqn.2025-08.world.srv:dlp.target01
node.tpgt = 1
node.startup = manual
node.leading_login = No
iface.iscsi_ifacename = default
.....
.....

# login to the target

root@node01:~# 
iscsiadm -m node --login -p 10.0.0.30

Login to [iface: default, target: iqn.2025-08.world.srv:dlp.target01, portal: 10.0.0.30,3260] successful.

# confirm the established session

root@node01:~# 
iscsiadm -m session -o show

tcp: [1] 10.0.0.30:3260,1 iqn.2025-08.world.srv:dlp.target01 (non-flash)
# if enable automatic login for system starting, set like follows

root@node01:~# 
iscsiadm -m node -p 10.0.0.30 -o update -n node.startup -v automatic
# confirm the partitions

root@node01:~# 
cat /proc/partitions

major minor  #blocks  name

 254        0   31457280 sda
 254        1     999424 sda1
 254        2          1 sda2
 254        5   30454784 sda5
 253        0   28844032 dm-0
 253        1    1609728 dm-1
   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.
root@node01:~# 
apt -y install parted
# create label

root@node01:~# 
parted --script /dev/sdb "mklabel gpt"

# create partition

root@node01:~# 
parted --script /dev/sdb "mkpart primary 0% 100%"

# format with ext4

root@node01:~# 
mkfs.ext4 /dev/sdb1

mke2fs 1.47.2 (1-Jan-2025)
Creating filesystem with 2617344 4k blocks and 655360 inodes
Filesystem UUID: 519582a5-9609-4d24-84dd-7b2867a0785f
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@node01:~# 
mount /dev/sdb1 /mnt

root@node01:~# 
df -hT

Filesystem                  Type      Size  Used Avail Use% Mounted on
udev                        devtmpfs  1.9G     0  1.9G   0% /dev
tmpfs                       tmpfs     392M  572K  392M   1% /run
/dev/mapper/debian--vg-root ext4       27G  940M   25G   4% /
tmpfs                       tmpfs     2.0G     0  2.0G   0% /dev/shm
tmpfs                       tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs                       tmpfs     1.0M     0  1.0M   0% /run/credentials/systemd-journald.service
tmpfs                       tmpfs     2.0G     0  2.0G   0% /tmp
/dev/vda1                   ext4      943M   75M  804M   9% /boot
tmpfs                       tmpfs     1.0M     0  1.0M   0% /run/credentials/getty@tty1.service
tmpfs                       tmpfs     1.0M     0  1.0M   0% /run/credentials/serial-getty@ttyS0.service
tmpfs                       tmpfs     392M  4.0K  392M   1% /run/user/0
/dev/sda1                   ext4      9.8G  2.1M  9.3G   1% /mnt

No comments:

Post a Comment