The cart is empty

iSCSI (Internet Small Computer System Interface) is a network protocol that enables the use of network infrastructure for connecting storage devices. This article provides a detailed guide on creating and managing iSCSI LUNs (Logical Unit Numbers) on CentOS 7 system, facilitating efficient utilization of network storage.

System Preparation

Before you begin, ensure your system is up to date. Use the following commands to update your CentOS 7 system:

sudo yum update
sudo yum install epel-release

Installation and Configuration of iSCSI Target

iSCSI target is the server-side component of iSCSI that provides storage to clients. To install the iSCSI target on CentOS 7, use:

sudo yum install targetcli

After installation, start and enable the target service with the following commands:

sudo systemctl start target
sudo systemctl enable target

Now, use targetcli to configure the iSCSI target. Launch targetcli:

sudo targetcli

Creating iSCSI LUN

In the targetcli prompt, follow these steps to create an iSCSI LUN:

  1. Create a backstore (storage). If using a file as storage, create it as follows:
    /backstores/fileio create name=mylun size=10G /path/to/file.img
    ​
  2. Create an iSCSI target:
    /iscsi create iqn.2024-04.com.example:target1
    ​
  3. Add ACL (Access Control List) for authentication and authorization of iSCSI initiators (clients):
    /iscsi/iqn.2024-04.com.example:target1/tpg1/acls create iqn.2024-04.client:initiator
    ​
  4. Assign the LUN to the target:
    /iscsi/iqn.2024-04.com.example:target1/tpg1/luns/ create /backstores/fileio/mylun
    ​

After completing the configuration, enter exit to exit targetcli.

Firewall and SELinux Configuration

To allow iSCSI communication, configure the firewall:

sudo firewall-cmd --add-service=iscsi-target --permanent
sudo firewall-cmd --reload

If you are using SELinux, ensure the configuration does not hinder iSCSI traffic. If needed, you can temporarily set SELinux to permissive mode:

sudo setenforce 0

You should now have a functional iSCSI target on CentOS 7, providing LUNs for network storage. For management and monitoring of iSCSI LUNs, you can utilize targetcli. It's also essential to regularly back up and monitor the status of your storage to ensure its reliability and security.