Skip to content

Instantly share code, notes, and snippets.

@dginhoux
Created July 23, 2024 17:09
Show Gist options
  • Save dginhoux/70ff97780fedbfedacb07f6047f6d610 to your computer and use it in GitHub Desktop.
Save dginhoux/70ff97780fedbfedacb07f6047f6d610 to your computer and use it in GitHub Desktop.
linux_targetd_mode_file

h1. installation d'une qla25xx dans tina-save-cat

h1. création des backstores/fileio


mkdir -p /var/ibm.quorum
chown -R root:root /var/ibm.quorum
dd if=/dev/zero of=/var/ibm.quorum/quorum1.disk count=1024 bs=1M
chown root:root /var/ibm.quorum/quorum1.disk
chmod 644 /var/ibm.quorum/quorum1.disk

h1. installation de targetcli et des firmware qla2xxxx


apt install -y targetcli-fb firmware-qlogic

tee /etc/modprobe.d/qla2xxx.conf <

h1. create targetd config folder


mkdir -p /etc/targetd
chown -R root:root /etc/targetd

h1. create targetd systemd unit


tee /etc/targetd/targetd.service <

h1. configuration de targetd


targetcli 

/> qla2xxx/ info
Fabric module name: qla2xxx
ConfigFS path: /sys/kernel/config/target/qla2xxx
Allowed WWN types: naa
Allowed WWNs list: naa.21000024ff2de292, naa.21000024ff2de293
Fabric module features: acls
Corresponding kernel module: tcm_qla2xxx

/> qla2xxx/ create naa.21000024ff2de292
/> qla2xxx/ create naa.21000024ff2de293

/> /backstores/fileio create file_or_dev=/var/ibm.quorum/quorum1.disk name=quorum1
/> qla2xxx/naa.21000024ff2de292/luns create /backstores/fileio/quorum1 lun=1
/> qla2xxx/naa.21000024ff2de293/luns create /backstores/fileio/quorum1 lun=1

/> qla2xxx/naa.21000024ff2de293/acls create wwn=50:05:07:68:10:14:bd:e9
/> qla2xxx/naa.21000024ff2de293/acls create wwn=50:05:07:68:10:14:bc:43
/> qla2xxx/naa.21000024ff2de293/acls create wwn=50:05:07:68:10:14:bc:30
/> qla2xxx/naa.21000024ff2de293/acls create wwn=50:05:07:68:10:14:bc:ae

/> qla2xxx/naa.21000024ff2de292/acls create wwn=50:05:07:68:10:13:bd:e9
/> qla2xxx/naa.21000024ff2de292/acls create wwn=50:05:07:68:10:13:bc:43
/> qla2xxx/naa.21000024ff2de292/acls create wwn=50:05:07:68:10:13:bc:30
/> qla2xxx/naa.21000024ff2de292/acls create wwn=50:05:07:68:10:13:bc:ae

/> saveconfig savefile=/etc/targetd/config.json

/> qla2xxx/ ls
o- qla2xxx ........................................................................................................... [Targets: 2]
  o- naa.21000024ff2de292 .............................................................................................. [gen-acls]
  | o- acls ............................................................................................................. [ACLs: 4]
  | | o- naa.500507681013bc30 .................................................................................... [Mapped LUNs: 1]
  | | | o- mapped_lun1 ................................................................................. [lun1 fileio/quorum1 (rw)]
  | | o- naa.500507681013bc43 .................................................................................... [Mapped LUNs: 1]
  | | | o- mapped_lun1 ................................................................................. [lun1 fileio/quorum1 (rw)]
  | | o- naa.500507681013bcae .................................................................................... [Mapped LUNs: 1]
  | | | o- mapped_lun1 ................................................................................. [lun1 fileio/quorum1 (rw)]
  | | o- naa.500507681013bde9 .................................................................................... [Mapped LUNs: 1]
  | |   o- mapped_lun1 ................................................................................. [lun1 fileio/quorum1 (rw)]
  | o- luns ............................................................................................................. [LUNs: 1]
  |   o- lun1 .................................................. [fileio/quorum1 (/var/ibm.quorum/quorum1.disk) (default_tg_pt_gp)]
  o- naa.21000024ff2de293 .............................................................................................. [gen-acls]
    o- acls ............................................................................................................. [ACLs: 4]
    | o- naa.500507681014bc30 .................................................................................... [Mapped LUNs: 1]
    | | o- mapped_lun1 ................................................................................. [lun1 fileio/quorum1 (rw)]
    | o- naa.500507681014bc43 .................................................................................... [Mapped LUNs: 1]
    | | o- mapped_lun1 ................................................................................. [lun1 fileio/quorum1 (rw)]
    | o- naa.500507681014bcae .................................................................................... [Mapped LUNs: 1]
    | | o- mapped_lun1 ................................................................................. [lun1 fileio/quorum1 (rw)]
    | o- naa.500507681014bde9 .................................................................................... [Mapped LUNs: 1]
    |   o- mapped_lun1 ................................................................................. [lun1 fileio/quorum1 (rw)]
    o- luns ............................................................................................................. [LUNs: 1]
      o- lun1 .................................................. [fileio/quorum1 (/var/ibm.quorum/quorum1.disk) (default_tg_pt_gp)]  

h1. test systemd unit


/usr/bin/targetctl clear
targetcli qla2xxx/ ls
o- qla2xxx ........................................................................................................... [Targets: 0]
systemctl status targetd.service
systemctl stop targetd.service
targetcli qla2xxx/ ls
o- qla2xxx ........................................................................................................... [Targets: 0]

systemctl start targetd.service
systemctl status targetd.service
● targetd.service - Restore LIO kernel target configuration
   Loaded: loaded (/etc/systemd/system/targetd.service; enabled; vendor preset: enabled)
   Active: active (exited) since Wed 2024-01-31 10:45:20 CET; 9s ago
  Process: 6498 ExecStart=/usr/bin/targetctl restore /etc/targetd/config.json (code=exited, status=0/SUCCESS)
 Main PID: 6498 (code=exited, status=0/SUCCESS)
janv. 31 10:45:10 tina-save-cat systemd[1]: Starting Restore LIO kernel target configuration...
janv. 31 10:45:20 tina-save-cat systemd[1]: Started Restore LIO kernel target configuration.


root@tina-save-cat:/etc/targetd# targetcli qla2xxx/ ls
o- qla2xxx ........................................................................................................... [Targets: 2]
  o- naa.21000024ff2de292 .............................................................................................. [gen-acls]
  | o- acls ............................................................................................................. [ACLs: 4]
  | | o- naa.500507681013bc30 .................................................................................... [Mapped LUNs: 1]
  | | | o- mapped_lun1 ................................................................................. [lun1 fileio/quorum1 (rw)]
  | | o- naa.500507681013bc43 .................................................................................... [Mapped LUNs: 1]
  | | | o- mapped_lun1 ................................................................................. [lun1 fileio/quorum1 (rw)]
  | | o- naa.500507681013bcae .................................................................................... [Mapped LUNs: 1]
  | | | o- mapped_lun1 ................................................................................. [lun1 fileio/quorum1 (rw)]
  | | o- naa.500507681013bde9 .................................................................................... [Mapped LUNs: 1]
  | |   o- mapped_lun1 ................................................................................. [lun1 fileio/quorum1 (rw)]
  | o- luns ............................................................................................................. [LUNs: 1]
  |   o- lun1 .................................................. [fileio/quorum1 (/var/ibm.quorum/quorum1.disk) (default_tg_pt_gp)]
  o- naa.21000024ff2de293 .............................................................................................. [gen-acls]
    o- acls ............................................................................................................. [ACLs: 4]
    | o- naa.500507681014bc30 .................................................................................... [Mapped LUNs: 1]
    | | o- mapped_lun1 ................................................................................. [lun1 fileio/quorum1 (rw)]
    | o- naa.500507681014bc43 .................................................................................... [Mapped LUNs: 1]
    | | o- mapped_lun1 ................................................................................. [lun1 fileio/quorum1 (rw)]
    | o- naa.500507681014bcae .................................................................................... [Mapped LUNs: 1]
    | | o- mapped_lun1 ................................................................................. [lun1 fileio/quorum1 (rw)]
    | o- naa.500507681014bde9 .................................................................................... [Mapped LUNs: 1]
    |   o- mapped_lun1 ................................................................................. [lun1 fileio/quorum1 (rw)]
    o- luns ............................................................................................................. [LUNs: 1]
      o- lun1 .................................................. [fileio/quorum1 (/var/ibm.quorum/quorum1.disk) (default_tg_pt_gp)]

systemctl stop targetd.service
targetcli qla2xxx/ ls
o- qla2xxx ........................................................................................................... [Targets: 0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment