Introduction
In this article, we will explore the what, who, where, when, why, and how of Internet Small Computer Systems Interface (iSCSI) as Storage Server functionality on the Debian 12 Bookworm platform, so let's get started.
Introduction
Overview
What
iSCSI (Internet Small Computer Systems Interface) is a network protocol that allows the transport of block-level storage over TCP/IP networks. This guide explains how to set up an iSCSI storage server on Debian 12 Bookworm.
Who
iSCSI (Internet Small Computer Systems Interface) is a network protocol that allows the transport of block-level storage over TCP/IP networks. This guide explains how to set up an iSCSI storage server on Debian 12 Bookworm.
Where
The setup can be performed on any server running Debian 12 Bookworm, with network connectivity to the clients that will access the storage.
When
Install iSCSI as a storage server whenever you need to provide centralized storage that can be accessed over a network, particularly in environments where high performance and reliability are required.
Why
Installing iSCSI as a storage server has several advantages and disadvantages:
Pros | Cons |
---|---|
Centralized management of storage | Requires network configuration and management |
Scalability and flexibility | Potential network bottlenecks |
Cost-effective compared to traditional SAN | Dependence on network infrastructure |
How
To install and configure iSCSI on Debian 12 Bookworm, follow these steps:
Step 1: | Install the iSCSI target package: sudo apt-get install tgt |
Step 2: | Edit the configuration file: /etc/tgt/conf.d/iscsi.conf |
Step 3 | Start and enable the iSCSI target service: sudo systemctl start tgt and sudo systemctl enable tgt |
Step 4 | Configure the iSCSI target and logical units using tgt-admin commands |
Step 5 | Ensure the iSCSI target is accessible from client machines |
Consequences
The following consequences can result from setting up iSCSI storage:
Positive |
|
Negative |
|
Conclusion
Setting up iSCSI as a storage server on Debian 12 Bookworm provides an effective solution for centralized storage management. While it offers several advantages, such as scalability and cost-effectiveness, it also comes with potential challenges, including network dependency and configuration complexities. By following the steps outlined in this guide, administrators can successfully deploy iSCSI and enhance their network's storage capabilities.
Configure Target (Targetcli)
Configure Storage Server with iSCSI. Storage server with iSCSI on network is called iSCSI Target, Client Host that connects to iSCSI Target is called iSCSI Initiator. This example is based on the environment like follows.
+----------------------+ | +------------------------+ | [ iSCSI Target ] |10.0.0.30 | 10.0.0.51| [ iSCSI Initiator ] | | dlp.bizantum.lab +----------+----------+ node01.bizantum.lab | | | | | +----------------------+ +------------------------+
Step [1]Install administration tool.
root@dlp:~# apt -y install targetcli-fb
Step [2]Configure iSCSI Target. For example, Create an disk-image under the [/var/lib/iscsi_disks] directory and set it as a SCSI device.
# create a directory
root@dlp:~# mkdir /var/lib/iscsi_disks
# enter the admin console
root@dlp:~# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.53
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.
/> cd /backstores/fileio
# create a disk-image with the name [disk01] on [/var/lib/iscsi_disks/disk01.img] with 10G
/backstores/fileio> create disk01 /var/lib/iscsi_disks/disk01.img 10G
Created fileio disk01 with size 10737418240
/backstores/fileio> cd /iscsi
# create a target
# naming rule : [ iqn.(year)-(month).(reverse of domain name):(any name you like) ]
/iscsi> create iqn.2023-06.lab.bizantum:dlp.target01
Created target iqn.2023-06.lab.bizantum:dlp.target01.
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-06.lab.bizantum:dlp.target01/tpg1
# enale authentication
/iscsi/iqn.20...target01/tpg1> set attribute authentication=1
Parameter authentication is now '1'.
/iscsi/iqn.20...target01/tpg1> cd luns
# set LUN
/iscsi/iqn.20...t01/tpg1/luns> create /backstores/fileio/disk01
Created LUN 0.
/iscsi/iqn.20...t01/tpg1/luns> cd ../acls
# set ACL (it's the IQN of an initiator you permit to connect)
/iscsi/iqn.20...t01/tpg1/acls> create iqn.2023-06.lab.bizantum:node01.initiator
Created Node ACL for iqn.2023-06.lab.bizantum:node01.initiator
Created mapped LUN 0.
/iscsi/iqn.20...t01/tpg1/acls> cd iqn.2023-06.lab.bizantum:node01.initiator
# set UserID and Password for authentication
/iscsi/iqn.20...w.initiator> set auth userid=username
Parameter userid is now 'username'.
/iscsi/iqn.20...w.initiator> set auth password=password
Parameter password is now 'password'.
/iscsi/iqn.20...w.initiator> exit
Global pref auto_save_on_exit=true
Configuration saved to /etc/rtslib-fb-target/saveconfig.json
# after configuration above, the target enters in listening like follows
root@dlp:~# ss -napt | grep 3260
LISTEN 0 256 0.0.0.0:3260 0.0.0.0:*
root@dlp:~# systemctl enable rtslib-fb-targetctl
Configure Target (tgt)
Configure Storage Server with iSCSI. This is the example of configuring iSCSI Target with scsi-target-utils. (tgt) Storage server with iSCSI on network is called iSCSI Target, Client Host that connects to iSCSI Target is called iSCSI Initiator. This example is based on the environment like follows.
+----------------------+ | +-------------------------+ | [ iSCSI Target ] |10.0.0.30 | 10.0.0.51| [ iSCSI Initiator ] | | dlp.bizantum.lab +----------+----------+ node01.bizantum.lab | | | | | +----------------------+ +-------------------------+
Step [1]Install administration tools.
root@dlp:~# apt -y install tgt
Step [2] Configure iSCSI Target. For example, create an disk-image under the [/var/lib/iscsi_disks] directory and set it as a SCSI device.
# create a disk image
root@dlp:~# mkdir /var/lib/iscsi_disks
root@dlp:~# dd if=/dev/zero of=/var/lib/iscsi_disks/disk01.img count=0 bs=1 seek=10G
[root@dlp ~]# vi /etc/tgt/conf.d/target01.conf
# create new
# if you set some devices, add <target>-</target> and set the same way with follows
# naming rule : [ iqn.(year)-(month).(reverse of domain name):(any name you like) ]
<target iqn.2023-06.lab.bizantum:dlp.target01>
# provided devicce as a iSCSI target
backing-store /var/lib/iscsi_disks/disk01.img
# iSCSI Initiator's IQN you allow to connect
initiator-name iqn.2023-06.lab.bizantum:node01.initiator
# authentication info ( set anyone you like for "username", "password" )
incominguser username password
</target>
root@dlp:~# systemctl restart tgt
# show status
root@dlp:~# tgtadm --mode target --op show
Target 1: iqn.2023-06.lab.bizantum:dlp.target01
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 10737 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: rdwr
Backing store path: /var/lib/iscsi_disks/disk01.img
Backing store flags:
Account information:
username
ACL information:
ALL
iqn.2023-06.lab.bizantum:node01.initiator
Configure 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.bizantum.lab +----------+----------+ node01.bizantum.lab | | | | | +----------------------+ +------------------------+
Step [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.2023-06.lab.bizantum:node01.initiator
root@node01:~# vi /etc/iscsi/iscsid.conf
# line 67 : uncomment
node.session.auth.authmethod = CHAP
# line 79,80: 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.2023-06.lab.bizantum:dlp.target01
# confirm status after discovery
root@node01:~# iscsiadm -m node -o show
# BEGIN RECORD 2.1.8
node.name = iqn.2023-06.lab.bizantum:dlp.target01
node.tpgt = 1
node.startup = manual
node.leading_login = No
iface.iscsi_ifacename = default
.....
.....
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 -p 10.0.0.30
Logging in to [iface: default, target: iqn.2023-06.lab.bizantum:dlp.target01, portal: 10.0.0.30,3260]
Login to [iface: default, target: iqn.2023-06.lab.bizantum: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.2023-06.lab.bizantum: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 498688 sda1
254 2 1 sda2
254 5 30955520 sda5
253 0 29949952 dm-0
253 1 1003520 dm-1
11 0 1048575 sr0
8 0 10485760 sdb
# added new device provided from the target server as [sdb]
Step [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.0 (5-Feb-2023)
Creating filesystem with 2620928 4k blocks and 655360 inodes
Filesystem UUID: 823052bc-d0d2-43f3-9e77-ee6baf23c57e
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 580K 391M 1% /run
/dev/mapper/debian--vg-root ext4 28G 3.4G 24G 13% /
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda1 ext2 455M 58M 373M 14% /boot
tmpfs tmpfs 392M 0 392M 0% /run/user/0
/dev/sdb1 ext4 9.8G 24K 9.3G 1% /mnt
- Get link
- X
- Other Apps
Comments
Post a Comment
Thank you for your comment! We appreciate your feedback, feel free to check out more of our articles.
Best regards, Bizantum Blog Team.