Debian 9 Stretch
Sponsored Link

Configure iSCSI Initiator(Debian)
2017/06/21
 
Configure iSCSI Initiator on Debian.
This example is based on the environment below.
+----------------------+          |          +----------------------+
| [   iSCSI Target   ] |10.0.0.30 | 10.0.0.31| [ iSCSI Initiator  ] |
|     dlp.srv.world    +----------+----------+     www.srv.world    |
|                      |                     |                      |
+----------------------+                     +----------------------+

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

InitiatorName=
iqn.2017-06.world.srv:www.srv.world
root@www:~#
vi /etc/iscsi/iscsid.conf
# line 56: uncomment

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

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

10.0.0.30:3260,1 iqn.2017-06.world.srv:storage.target01

# confirm status after discovery

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

# BEGIN RECORD 2.0-874
node.name = iqn.2017-06.world.srv:storage.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@www:~#
iscsiadm -m node --login

Logging in to [iface: default, target: iqn.2017-06.world.srv:storage.target01, portal: 10.0.0.30,3260] (multiple)
Login to [iface: default, target: iqn.2017-06.world.srv:storage.target01, portal: 10.0.0.30,3260] successful.
# confirm the established session

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

tcp: [1] 10.0.0.30:3260,1 iqn.2017-06.world.srv:storage.target01 (non-flash)
# confirm the partitions

root@www:~#
cat /proc/partitions

major minor  #blocks  name

 254        0   31457280 sda
 254        1     248832 sda1
 254        2          1 sda2
 254        5   31205376 sda5
 253        0   27009024 dm-0
 253        1    4194304 dm-1
   8        0   10485760 sdb

# added new device provided from the target server as [sdb]
[2] After setting iSCSI devide, configure on Initiator to use it like follwos.
# create label

root@www:~#
parted --script /dev/sdb "mklabel msdos"

# create partiton

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

# format with ext4

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

mke2fs 1.43.4 (31-Jan-2017)
Creating filesystem with 2619392 4k blocks and 655360 inodes
Filesystem UUID: a1161e5e-5a1a-41f4-a674-dce56a82313d
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@www:~#
mount /dev/sdb1 /mnt

root@www:~#
df -hT

Filesystem                  Type      Size  Used Avail Use% Mounted on
udev                        devtmpfs  2.0G     0  2.0G   0% /dev
tmpfs                       tmpfs     396M  5.4M  391M   2% /run
/dev/mapper/debian--vg-root ext4       26G  916M   24G   4% /
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/sda1                   ext2      236M   37M  187M  17% /boot
tmpfs                       tmpfs     396M     0  396M   0% /run/user/0
/dev/sdb1                   ext4      9.8G   37M  9.3G   1% /mnt
Matched Content
 
Tweet