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

Movie - The Wizard of Oz (1939)

  My views Plot In rural  Kansas ,  Dorothy Gale  lives on a farm owned by her Uncle Henry and Aunt Em, and wishes she could be somewhere else. Dorothy's neighbor, Almira Gulch, who had been bitten by Dorothy's dog, Toto, obtains a sheriff's order authorizing her to seize Toto. Toto escapes and returns to Dorothy, who runs away to protect him. Professor Marvel, a charlatan fortune-teller, convinces Dorothy that Em is heartbroken, which prompts Dorothy to return home. She returns just as a  tornado  approaches the farm. Unable to get into the locked storm cellar, Dorothy takes cover in the farmhouse and is knocked unconscious. She seemingly awakens to find the house moving through the air, with her and Toto still inside it. The house comes down in an unknown land, and Dorothy is greeted by a good witch named  Glinda , who floats down in a bubble and explains that Dorothy has landed in Munchkinland in the  Land of Oz , and that the Munchkins are cel...

Movie - Bastille Day | The Take (2016)

  My views Plot On the eve of  Bastille Day  in  Paris , American drifter and  pickpocket  Michael Mason steals a woman's handbag, not knowing that it contains  explosives . After taking the cash from the bag, he discards it, caught unwittingly on  CCTV  as he does so. The bag then detonates and kills four people. Upon being captured by  CIA  agent Sean Briar, who is being reprimanded for irresponsible conduct on the job, Mason protests that he is not a  terrorist  and tells Briar that the bag contained a cellphone owned by a woman named Zoé. The bomb was set up by a group of  corrupt policemen , all of them members in the  French special police RAPID unit  led by Rafi Bertrand, who intend to pull a robbery at the  Bank of France . Zoé was told to plant the bomb at the office of the  French Nationalist Party  (as part of a diversion for the heist), but after seeing the night cleaning crew arri...

Movie - The Gorge (2025)

  My views For 80 years everything was ok ... until they sent a woman For sure is DTV ... really bad Inside the gorge is clearly designed and written by a gamer Plot Two elite  snipers  receive identical missions: travel to an undisclosed location and guard the West and East sides of a deep gorge for one year without any contact with the outside world nor their counterpart on the opposite side. Levi Kane, a former  U.S. Marine  and current  private contractor  accepts the offer to guard the West tower. Drasa, a  Lithuanian  covert operative frequently employed by the  Kremlin , agrees to guard the East side. Upon arriving, Levi relieves his predecessor, J.D., a  British   Royal Marine  of duty and asks for specifics about the mission. J.D. explains that in addition to the towers on the East and West, there are automated turret defenses to the North and South, a powerful signal ‘ cloak ,’ and  explosives on the walls ...