tgtadm --help
--lld <driver> --mode target --op new --tid <id> --targetname <name>
add a new target with <id> and <name>. <id>
must not be zero.
--lld <driver> --mode target --op delete [--force] --tid <id>
delete the specific target with <id>.
With force option, the specific target is
deleted even if there is an activity.
--lld <driver> --mode target --op show
show all the targets.
--lld <driver> --mode target --op show --tid <id>
show the specific target's parameters.
--lld <driver> --mode target --op update --tid <id> --name <param> --value <value>
change the target parameters of the specific
target with <id>.
--lld <driver> --mode target --op bind --tid <id> --initiator-address <address>
--lld <driver> --mode target --op bind --tid <id> --initiator-name <name>
enable the target to accept the specific initiators.
--lld <driver> --mode target --op unbind --tid <id> --initiator-address <address>
--lld <driver> --mode target --op unbind --tid <id> --initiator-name <name>
disable the specific permitted initiators.
--lld <driver> --mode logicalunit --op new --tid <id> --lun <lun> \
--backing-store <path> --bstype <type> --bsoflags <options>
add a new logical unit with <lun> to the specific
target with <id>. The logical unit is offered
to the initiators. <path> must be block device files
(including LVM and RAID devices) or regular files.
bstype option is optional.
bsoflags supported options are sync and direct
(sync:direct for both).
--lld <driver> --mode logicalunit --op delete --tid <id> --lun <lun>
delete the specific logical unit with <lun>
that the target with <id> has.
--lld <driver> --mode account --op new --user <name> --password <pass>
add a new account with <name> and <pass>.
--lld <driver> --mode account --op delete --user <name>
delete the specific account having <name>.
--lld <driver> --mode account --op bind --tid <id> --user <name> [--outgoing]
add the specific account having <name> to
the specific target with <id>.
<user> could be <IncomingUser> or <OutgoingUser>.
If you use --outgoing option, the account will be
added as an outgoing account.
--lld <driver> --mode account --op unbind --tid <id> --user <name>
delete the specific account having <name> from
specific target.
--control-port <port> use control port <port>
看上去很复杂。不过可以将上面的语法抛去driver部分,target、logicalunit和account这3种模式下的操作方式简化后如下:
这样就简单的多了。
上表中的选项都是长格式的,但他们都有对应的短格式选项。
target和logicalunit两个模式随后就会有示例,而account是和CHAP认证有关的,将在后文和配置文件放在一块解释。
2.2.2 target的命名方式iqn.YYYY-mm.<reversed domain name>[:identifier]
iqn是iscsi qualified name的缩写,就像fqdn一样。
YYYY-mm描述的是此target是何年何月创建的,如2016-06。
<reversed domain name>是域名的反写,起到了唯一性的作用,如longshuai.com写为com.longshuai。
identifier是可选的,是为了知道此target相关信息而设的描述性选项,如指明此target用到了哪些硬盘。
示例:
iqn.2016-06.com.longshuai:test.disk1
2.2.3 创建一个target