Setting up iSCSI on Fedora

Getting Started

Install the utilities

dnf install scsi-target-utils

[root@ironman4 ~]# dnf install scsi-target-utils
Last metadata expiration check: 0:30:13 ago on Fri 12 Feb 2021 07:30:57 PM EST.
Dependencies resolved.
==================================================================================
 Package                   Architecture    Version         Repository   Size
==================================================================================
Installing:
 scsi-target-utils         aarch64         1.0.79-2.fc33   fedora       223 k
Installing dependencies:
 perl-Config-General       noarch          2.63-13.fc33    fedora        74 k
 perl-English              noarch          1.11-462.fc33   fedora        26 k
 sg3_utils                 aarch64         1.45-3.fc33     fedora       917 k

Transaction Summary
=================================================================================
Install  4 Packages

Total download size: 1.2 M
Installed size: 6.2 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): perl-English-1.11-462.fc33.noarch.rpm           47 kB/s |  26 kB     00:00
(2/4): perl-Config-General-2.63-13.fc33.noarch.rpm    103 kB/s |  74 kB     00:00
(3/4): scsi-target-utils-1.0.79-2.fc33.aarch64.rpm    286 kB/s | 223 kB     00:00
(4/4): sg3_utils-1.45-3.fc33.aarch64.rpm              1.7 MB/s | 917 kB     00:00
---------------------------------------------------------------------------------
Total                                                 902 kB/s | 1.2 MB     00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                             1/1
  Installing       : sg3_utils-1.45-3.fc33.aarch64               1/4
  Installing       : perl-English-1.11-462.fc33.noarch           2/4
  Installing       : perl-Config-General-2.63-13.fc33.noarch     3/4
  Installing       : scsi-target-utils-1.0.79-2.fc33.aarch64     4/4
  Running scriptlet: scsi-target-utils-1.0.79-2.fc33.aarch64     4/4
  Verifying        : perl-Config-General-2.63-13.fc33.noarch     1/4
  Verifying        : perl-English-1.11-462.fc33.noarch           2/4
  Verifying        : scsi-target-utils-1.0.79-2.fc33.aarch64     3/4
  Verifying        : sg3_utils-1.45-3.fc33.aarch64               4/4

Installed:
  perl-Config-General-2.63-13.fc33.noarch       perl-English-1.11-462.fc33.noarch
  scsi-target-utils-1.0.79-2.fc33.aarch64       sg3_utils-1.45-3.fc33.aarch64

Complete!
[root@ironman4 ~]# mkdir /var/lib/iscsi_disks
[root@ironman4 ~]# dd if=/dev/zero of=/var/lib/iscsi_disks/disk01.img count=0 bs=1 seek=1G

[3] If SELinux is enabled, change SELinux Context.

[root@ironman4 ~]# dnf -y install policycoreutils-python-utils
Last metadata expiration check: 2:24:38 ago on Fri 12 Feb 2021 07:30:57 PM EST.
Package policycoreutils-python-utils-3.1-4.fc33.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@ironman4 ~]# chcon -R -t tgtd_var_lib_t /var/lib/iscsi_disks
[root@ironman4 ~]# semanage fcontext -a -t tgtd_var_lib_t /var/lib/iscsi_disks

If Firewalld is running, allow iSCSI Target service.

[root@ironman4 ~]# firewall-cmd --add-service=iscsi-target --permanent 
success
[root@ironman4 ~]# firewall-cmd --reload
success

You can do it by creating the configuration file inside the /etc/tgt/conf.d directory:

nano /etc/tgt/conf.d/iscsi.conf

Add the following lines:

<target iqn.2019-11.example.com:lun1>
     # Provided device as an iSCSI target
     backing-store /dev/sdb1                             
     initiator-address 192.168.0.102 
     incominguser iscsi-user password
     outgoinguser iscsi-target secretpass
</target>

Actual

root@ironman7:~# nano /etc/tgt/conf.d/iscsi.conf
root@ironman7:~# cat /etc/tgt/conf.d/iscsi.conf
<target iqn.2019-11.example.com:lun1>
     # Provided device as an iSCSI target
     backing-store /dev/sda
     initiator-address 172.16.0.8
     incominguser iscsi-user ironmanforever
     outgoinguser iscsi-target tonystarklives
</target>
  • The first line defines the name of the LUN.
  • The second line defines the location and name of the storage device on the iSCSI Target server.
  • The third line defines the IP address of the iSCSI initiator.
  • The fourth line defines the incoming username/password.
  • The fifth line defines the username/password that the target will provide to the initiator to allow for mutual CHAP authentication to take place.

Start tgtd and verify status.

[root@ironman4 ~]# systemctl start tgtd
[root@ironman4 ~]# systemctl enable tgtd
Created symlink /etc/systemd/system/multi-user.target.wants/tgtd.service → /usr/lib/systemd/system/tgtd.service.

You should get the following output:

Target 1: iqn.2020-07.example.com:lun1
    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:
    Account information:
        iscsi-user
        iscsi-target (outgoing)
    ACL information:
	172.16.0.8

ACL Fix

root@ironman7:~# tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL

Install and Configure iSCSI Initiator

See Ubuntu