Skip to main content

IT - iSCSI target (Fedora Linux 36 / 37 / 38 / 39)

iSCSI

Terminology

Server (target) side

  • Install iSCSI software
    $ sudo  dnf -y install targetcli
  • Create IQN with iscsi-iname (see the example above)
  • Create backstore data areas
    • Quite simple example for most of systems:
      • $ sudo targetcli /backstores/block create disk0 /dev/sdb
      • $ sudo targetcli /backstores/block create disk1 /dev/sdc
      • $ sudo targetcli /backstores/block create disk2 /dev/sdd
    • Note: For entire physical disks I recommend using the WWN instead of disk device or partition id. This ensures that the disk reference will not change during system restarts (quite common when using USB disks). Another option is to use the disk UUID. However, a new partition map is created (using fdisk), the UUID will change. Also, if you are using more tan one iSCSI target, the block name (disk0, disk1 etc) is used as the disk type on the client side. I recommend to use a more clear disk name to help identify disks. On my case, I decide to use the format tid-case-diskn. For example: t14-A-disk0. The case is in upper case to help avoid mixing case ids (A, B etc).
      • $ sudo targetcli /backstores/block create t14-A-disk0 /dev/sdb
      • $ sudo targetcli /backstores/block create t14-A-disk2 /dev/sdc
      • $ sudo targetcli /backstores/block create t14-A-disk4 /dev/sdd
  • Create LUNs

    /> /iscsi/iqn.2003-01.org.linux-iscsi.fedora.x8664:sn.34fb1fb1c6aa/tpg1/luns create /backstores/block/disk7
    Created LUN 7.
    Created LUN 7->7 mapping in node ACL iqn.1994-05.com.redhat:ecdd17858d7
    Created LUN 7->7 mapping in node ACL iqn.2022-05.world.srv:node01.initiator01
    /> /iscsi/iqn.2003-01.org.linux-iscsi.fedora.x8664:sn.34fb1fb1c6aa/tpg1/luns create /backstores/block/disk8
    Created LUN 8.
    Created LUN 8->8 mapping in node ACL iqn.1994-05.com.redhat:ecdd17858d7
    Created LUN 8->8 mapping in node ACL iqn.2022-05.world.srv:node01.initiator01
    /> /iscsi/iqn.2003-01.org.linux-iscsi.fedora.x8664:sn.34fb1fb1c6aa/tpg1/luns create /backstores/block/disk9
    Created LUN 9.
    Created LUN 9->9 mapping in node ACL iqn.1994-05.com.redhat:ecdd17858d7
    Created LUN 9->9 mapping in node ACL iqn.2022-05.world.srv:node01.initiator01
no ACL


Client (initiator) side

    1. Install iSCSI software with dnf
      $ sudo dnf -y install targetcli
    2. Record the iSCSI initiator name on the system where data is to be restored. The iSCSI initiator name is in the /etc/iscsi/initiatorname.iscsi file. If the InitiatorName= value is empty, create an initiator name with the command /sbin/iscsi-iname.  For example:

      $ sudo /sbin/iscsi-iname
      iqn.1994-05.com.redhat:514c64da1856
    3. Add the initiator name to the /etc/iscsi/initiatorname.iscsi file.
      1. Edit the /etc/iscsi/initiatorname.iscsi file with vi command. For example:

        $ sudo vi /etc/iscsi/initiatorname.iscsi
      2. Update the InitiatorName= parameter with the initiator name. For example:

        InitiatorName=iqn.1994-05.com.redhat:514c64da1856

Troubleshooting

iscsiadm: No portals found

  • Client side

    $ sudo iscsiadm --mode discovery --type sendtargets --portal 192.168.0.251
    [sudo] password for afberendsen:
    iscsiadm: No portals found
  • Server side


  • Very likely another process is listening on 3260. Check with lsof -i :3260. For me, the output is

    $ sudo lsof -i :3260
    COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
    tgtd    1456 root    6u  IPv4  25757      0t0  TCP *:iscsi-target (LISTEN)
    tgtd    1456 root    7u  IPv6  25758      0t0  TCP *:iscsi-target (LISTEN)
  • $ sudo systemctl disable iscsid.socket
    $ sudo systemctl disable tgtd.service
  • reboot server and confirm tgtd is not running
  • Back to targetcli and add the default portal



  • Check the client again
    $ sudo iscsiadm --mode discovery --type sendtargets --portal 192.168.0.251
    [sudo] password for afberendsen:
    192.168.0.251:3260,1 iqn.2003-01.org.linux-iscsi.fedora.x8664:sn.34fb1fb1c6aa
    $ cat /proc/scsi/scsi
    Attached devices:
    ....
    Host: scsi26 Channel: 00 Id: 00 Lun: 00
      Vendor: LIO-ORG  Model: disk0            Rev: 4.0
      Type:   Direct-Access                    ANSI  SCSI revision: 06
    Host: scsi26 Channel: 00 Id: 00 Lun: 01
      Vendor: LIO-ORG  Model: disk1            Rev: 4.0
      Type:   Direct-Access                    ANSI  SCSI revision: 06
    Host: scsi26 Channel: 00 Id: 00 Lun: 02
      Vendor: LIO-ORG  Model: disk2            Rev: 4.0
      Type:   Direct-Access                    ANSI  SCSI revision: 06
    Host: scsi26 Channel: 00 Id: 00 Lun: 03
      Vendor: LIO-ORG  Model: disk3            Rev: 4.0
      Type:   Direct-Access                    ANSI  SCSI revision: 06
    Host: scsi26 Channel: 00 Id: 00 Lun: 04
      Vendor: LIO-ORG  Model: disk4            Rev: 4.0
      Type:   Direct-Access                    ANSI  SCSI revision: 06
    Host: scsi26 Channel: 00 Id: 00 Lun: 05
      Vendor: LIO-ORG  Model: disk5            Rev: 4.0
      Type:   Direct-Access                    ANSI  SCSI revision: 06
    Host: scsi26 Channel: 00 Id: 00 Lun: 06
      Vendor: LIO-ORG  Model: disk6            Rev: 4.0
      Type:   Direct-Access                    ANSI  SCSI revision: 06

Sources

  • https://www.ibm.com/docs/en/tsmfve/7.1.1?topic=vmware-manually-configuring-iscsi-device-linux-system
  • https://www.thegeekdiary.com/how-to-configure-iscsi-target-and-initiator-using-targetcli-in-centos-rhel-7/
  • https://www.thegeekdiary.com/how-to-troubleshoot-iscsi-issue-is-centos-rhel-67/

Comments

Popular posts from this blog

Movies - Deadpool & Wolverine (2024)

 

Movie - Trap (2024)

 

Movie - Some Like It Hot (1959)

  My views See other movies with: Marilyn Monroe Jack Lemmon Tony Curtis Plot In Prohibition-era  Chicago , Joe is a jazz  saxophone  player and an irresponsible, impulsive gambler and  ladies' man ; Jerry, his anxious friend, is a jazz  double bass  player. They work in a  speakeasy  owned by local Mafia boss "Spats" Colombo. Tipped off by informant "Toothpick" Charlie, the police raid the joint. Joe and Jerry escape, but later accidentally witness Spats and his henchmen gunning down Toothpick and his gang in revenge (an incident inspired by the  Saint Valentine's Day Massacre ). [ 7 ]  Spats and his gang see them as they flee. Broke, terrified, and desperate to leave Chicago, Joe and Jerry  disguise themselves as women  named Josephine and Daphne so they can join Sweet Sue and her Society Syncopators, an all-female band headed by train to  Miami . On the train, Joe and Jerry befriend Sugar Kane, the band's vocalist ...