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 - Se7en (1995)

  My views Plot In an unnamed city overcome with violent crime and corruption, disillusioned police Detective Lieutenant William Somerset is one week from retirement. He is partnered with David Mills, a young, short-tempered, idealistic detective who recently relocated to the city with his wife, Tracy. On Monday, Somerset and Mills investigate an obese man who was forced to eat until his stomach burst, killing him. The detectives find the word " gluttony " written on a wall. Somerset, considering the case too extreme for his last investigation, asks to be reassigned, but his request is denied. The following day, another victim, who had been forced to cut one pound (0.45 kg) of flesh from his body, is found; the crime scene is marked " greed ." Clues at the scene lead Somerset and Mills to the  sloth  victim, a drug-dealing  pederast  whom they find emaciated and restrained to a bed. Photographs reveal the victim was restrained for precisely one year. Somers...

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 Gray Man (2022)

  My views Plot In 2003, senior  CIA  official Donald Fitzroy visits a prisoner named Courtland Gentry in Florida. Eight years earlier, Courtland was a minor convicted of killing his abusive father to protect his brother. Fitzroy offers him his freedom in exchange for working as an assassin in the CIA's  Sierra  program, an elite black ops unit, which will allow him to exist in the gray. In 2021, Courtland, now known as  Sierra Six , is working with fellow CIA agent Dani Miranda to assassinate a target named Dining Car suspected of selling off  national security  secrets in  Bangkok  during the national  Songkran  festival. Unable to do so stealthily without harming civilians, he attacks Dining Car directly, mortally wounding him. Before dying, he reveals he was also in the Sierra program as Sierra Four. He hands Six an encrypted drive detailing the corruption of CIA official Denny Carmichael, the lead agent on the assassinatio...