Ubuntu 21.04
Sponsored Link

iSCSI : Configure iSCSI Initiator
2021/05/07
 
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.2021-05.world.srv:node01.initiator01
root@node01:~#
vi /etc/iscsi/iscsid.conf
# line 59 : uncomment

node.session.auth.authmethod = CHAP
# line 70,71: 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.2021-05.world.srv:dlp.target01
# confirm status after discovery

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

# BEGIN RECORD 2.1.3
node.name = iqn.2021-05.world.srv:dlp.target01
node.tpgt = 1
node.startup = manual
node.leading_login = No
iface.iscsi_ifacename = default
.....
.....
node.conn[0].iscsi.HeaderDigest = None
node.conn[0].iscsi.DataDigest = None
node.conn[0].iscsi.IFMarker = No
node.conn[0].iscsi.OFMarker = No
# END RECORD

# login to the target

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

Logging in to [iface: default, target: iqn.2021-05.world.srv:dlp.target01, portal: 10.0.0.30,3260]
Login to [iface: default, target: iqn.2021-05.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.2021-05.world.srv:dlp.target01 (non-flash)
# confirm the partitions

root@node01:~#
cat /proc/partitions

major minor  #blocks  name

   7        0      70896 loop0
   7        1      33048 loop1
   7        2      70848 loop2
   7        3      56780 loop3
 252        0   31457280 sda
 252        1       1024 sda1
 252        2    1048576 sda2
 252        3   30405632 sda3
 253        0   20971520 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 follwos.
# create label

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

# create partiton

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

# format with ext4

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

mke2fs 1.45.7 (28-Jan-2021)
Creating filesystem with 2617344 4k blocks and 655360 inodes
Filesystem UUID: 2b21d713-b106-4161-a299-5a199a3b866d
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
tmpfs                             tmpfs  393M  1.1M  392M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv ext4    20G  6.4G   13G  34% /
tmpfs                             tmpfs  2.0G     0  2.0G   0% /dev/shm
tmpfs                             tmpfs  5.0M     0  5.0M   0% /run/lock
tmpfs                             tmpfs  4.0M     0  4.0M   0% /sys/fs/cgroup
/dev/sda2                         ext4   976M  128M  782M  14% /boot
tmpfs                             tmpfs  393M  4.0K  393M   1% /run/user/0
/dev/sdb1                         ext4   9.8G   37M  9.3G   1% /mnt
Matched Content