targetcli command examples

targetcli command examples

targetcli – administration shell for storage targets

DEFINING A STORAGE OBJECT WITHIN A BACKSTORE

backstores/fileio create disk1 /disks/disk1.img 140M

Creates a storage object named disk1 with the given path and size. targetcli supports common size abbreviations like ‘M’, ‘G’, and ‘T’.

EXPORTING A STORAGE OBJECT VIA ISCSI

#iscsi/ create

Creates an iSCSI target with a default WWN. It will also create an initial target portal group called tpg1.

iqn.2003-01.org.linux-iscsi.test2.x8664:sn123456789012/tpg1/

An example of changing to the configuration node for the given target’s first target portal group (TPG). This is equivalent to giving the command prefixed by “cd”. (Although more can be useful for certain setups, most configurations have a single TPG per target. In this case, configuring the TPG is equivalent to configuring the overall target.)

portals/ create

Add a portal, i.e. an IP address and TCP port via which the target can be contacted by initiators. Only required if

the default 0.0.0.0:3260 portal is not present.

luns/ create /backstores/fileio/disk1

Create a new LUN in the TPG, attached to the storage object that has previously been defined. The storage object now shows up under the /backstores configuration node as activated.

acls/ create iqn.1994-05.com.redhat:4321576890

Creates an ACL (access control list) entry for the given iSCSI initiator.

acls/iqn.1994-05.com.redhat:4321576890 create 2 0

Gives the initiator access to the first exported LUN (lun0), which the initiator will see as lun2. The default is to give the initiator read/write access; if read-only access was desired, an additional “1” argument would be added to enable write-protect. (Note: if global setting auto_add_mapped_luns is true, this step is not necessary.)

EXPORTING A STORAGE OBJECT VIA FCOE

tcm_fc/ create 20:00:00:19:99:a8:34:bc

Create an FCoE target with the given WWN. targetcli can tab-complete the WWN based on registered FCoE interfaces. If none are found, verify that they are properly configured and are shown in the output of fcoeadm -i.

tcm_fc/20:00:00:19:99:a8:34:bc/

If auto_cd_after_create is set to false, change to the configuration node for the given target, equivalent to giving the command prefixed by cd.

luns/ create /backstores/fileio/disk1

Create a new LUN for the interface, attached to a previously defined storage object. The storage object now shows up under the /backstores configuration node as activated.

acls/ create 00:99:88:77:66:55:44:33

Create an ACL (access control list), for defining the resources each initiator may access. The default behavior is to auto-map existing LUNs to the ACL; see help for more information.

The LUN should now be accessible via FCoE.

Leave a Reply

Your email address will not be published. Required fields are marked *