FUJITA Tomonori wrote:
Ok, we also move doc/targets.conf.example to the new conf/examples/ directory, right? I'm waiting for someone to send a patch to do such (needs to update Makefiles too). Thanks,
I've attached the patches to move targets.conf.example to conf/examples/ as well as the vtl examples (with the name Tomo suggested). As for the Makefile changes, I couldn't find anything to change, as only the empty targets.conf is installed as a dummy from conf/ which I just left as it was. Albert
--- /dev/null 2009-12-14 11:04:54.000000000 +0100 +++ conf/examples/targets.conf.example 2009-12-13 08:17:16.000000000 +0100 @@ -0,0 +1,239 @@ +# This is a sample config file for tgt-admin. +# By default, tgt-admin looks for its config file in /etc/tgt/targets.conf + +# This one includes other config files: + +include /etc/tgt/temp/*.conf + + +# Set the driver. If not specified, defaults to "iscsi". + +default-driver iscsi + + +# Continue if tgtadm exits with non-zero code (equivalent of +# --ignore-errors command line option) +#ignore-errors yes + + +# Sample target with one LUN only. Defaults to allow access for all initiators: + +<target iqn.2008-09.com.example:server.target1> + backing-store /dev/LVM/somedevice +</target> + + +# Similar, but we use "direct-store" instead of "backing-store". +# "direct-store" reads drive parameters with sg_inq command and sets them to +# the target. +# Parameters fatched with sg_inq are: +# - Vendor identification +# - Product identification +# - Product revision level +# - Unit serial number (if present) +# We also specify "incominguser". + +<target iqn.2008-09.com.example:server.target2> + direct-store /dev/sdd + incominguser someuser secretpass12 +</target> + + +# An example with multiple LUNs, disabled write-cache (tgtd enables write-cache +# by default) and vendor identification set to "MyVendor" + +<target iqn.2008-09.com.example:server.target3> + backing-store /dev/LVM/somedevice1 # Becomes LUN 1 + backing-store /dev/LVM/somedevice2 # Becomes LUN 2 + backing-store /dev/LVM/somedevice3 # Becomes LUN 3 + write-cache off + vendor_id MyCompany Inc. +</target> + + +# Similar to the one above, but we fetch vendor_id, product_id, product_rev and +# scsi_sn from the disks. +# Vendor identification (vendor_id) is replaced in all disks by "MyVendor" + +<target iqn.2008-09.com.example:server.target4> + direct-store /dev/sdb # Becomes LUN 1 + direct-store /dev/sdc # Becomes LUN 2 + direct-store /dev/sdd # Becomes LUN 3 + write-cache off + vendor_id MyCompany Inc. +</target> + + +# Note that "first-device-first-lun numbering" will work only for simple +# scenarios above, where _only_ direct-store _or_ backing-store is used. +# If you mix backing-store and direct-store, then all backing-store entries +# are processed before direct-store-entries. + +<target iqn.2008-09.com.example:server.target4> + direct-store /dev/sdb # Becomes LUN 3 + backing-store /dev/sdc # Becomes LUN 1 + direct-store /dev/sdd # Becomes LUN 4 + backing-store /dev/sde # Becomes LUN 2 +</target> + + +# Even more complicated example - each device has different parameters. +# You can use indentation to make the config file more readable. +# Note that LUNs will be assigned more or less randomly here (and still +# backing-store get LUNs assigned before drect-store). +# You can specify multiple mode_page parameters (they are commented out +# in this example). +# Note that some parameters (write-cache, scsi_sn) were specified "globally". +# "Global" parameters will be applied to all LUNs; they can be overwritten +# "locally", per LUN. +# If lun is not specified, it will be allocated automatically (first available). + +<target iqn.2008-09.com.example:server.target5> + + <direct-store /dev/sdd> + vendor_id VENDOR1 + removable 1 + device-type cd + lun 1 + </direct-store> + + <direct-store /dev/sda> + vendor_id VENDOR2 + lun 2 + </direct-store> + + <backing-store /dev/sdb1> + vendor_id back1 + scsi_sn SERIAL + write-cache on + # lun 3 # lun is commented out - will be allocated automatically + </backing-store> + + <backing-store /dev/sdd1> + vendor_id back2 + #mode_page 8:0:18:0x10:0:0xff.... + #mode_page 8:0:18:0x10:0:0xff.... + #bs-type aio + #params element_type=4,start_address=500,quantity=3,media_home=/root/tapes + #params element_type=4,address=500,tid=1,lun=1 + lun 15 + </backing-store> + + # Some more parameters which can be specified locally or globally: + #scsi_id ... + #scsi_sn ... + #vendor_id ... + #product_id ... + #product_rev ... + #sense_format ... + #removable ... + #online ... + #path ... + #mode_page 8:0:18:0x10:0:0xff.... + #mode_page 8:0:18:0x10:0:0xff.... + #device-type ... + #bs-type ... # backing store type - default rdwr, can be aio, mmap, etc... + #params element_type=4,start_address=500,quantity=3,media_home=/root/tapes + #params element_type=4,address=500,tid=1,lun=1 + #allow-in-use yes # if specified globally, can't be overwritten locally + + write-cache off + scsi_sn multipath-10 + + # Parameters below are only global. They can't be configured per LUN. + # Only allow connections from 192.168.100.1 and 192.168.200.5 + initiator-address 192.168.100.1 + initiator-address 192.168.200.5 + + # Tuning parameters (global, per target) + #MaxRecvDataSegmentLength 8192 + #MaxXmitDataSegmentLength 8192 + #HeaderDigest None + #DataDigest None + #InitialR2T Yes + #MaxOutstandingR2T 1 + #ImmediateData Yes + #FirstBurstLength 65536 + #MaxBurstLength 262144 + #DataPDUInOrder Yes + #DataSequenceInOrder Yes + #ErrorRecoveryLevel 0 + #IFMarker No + #OFMarker No + #DefaultTime2Wait 2 + #DefaultTime2Retain 20 + #OFMarkInt Reject + #IFMarkInt Reject + #MaxConnections 1 + + # Allowed incoming users + incominguser user1 secretpass12 + incominguser user2 secretpass23 + + # Outgoing user + outgoinguser userA secretpassA + +</target> + + +# The device will have lun 1 unless you specify something else +<target iqn.2008-09.com.example:server.target6> + backing-store /dev/LVM/somedevice + lun 10 +</target> + + +# Devices which are in use (by system: mounted, for swap, part of RAID, or by +# userspace: dd, by tgtd for another target etc.) can't be used, unless you use +# --force flag or add 'allow-in-use yes' option +<target iqn.2008-09.com.example:server.target7> + backing-store /dev/LVM/somedevice + allow-in-use yes +</target> + +<target iqn.2008-09.com.example:server.target8> + <backing-store /dev/LVM/somedevice> + scsi_sn serial1 + </backing-store> + + <backing-store /dev/LVM/somedevice2> + scsi_sn serial2 + </backing-store> + + allow-in-use yes +</target> + + + + + +# Not supported configurations, and therefore, commented out: + +#<target iqn.2008-09.com.example:server.target9> +# backing-store /dev/LVM/somedevice1 +# backing-store /dev/LVM/somedevice2 +# lun 10 +# lun 11 +#</target> + +#<target iqn.2008-09.com.example:server.target10> +# <direct-store /dev/sdd> +# vendor_id VENDOR1 +# </direct-store> +# +# direct-store /dev/sdc +#</target> + +# This one will break the parser: + +#<target iqn.2008-09.com.example:server.target11> +# <direct-store /dev/sdd> +# vendor_id VENDOR1 +# </direct-store> +# +# direct-store /dev/sdc +# +# <direct-store /dev/sdd> +# vendor_id VENDOR1 +# </direct-store> +#</target>
--- doc/targets.conf.example 2009-12-13 08:17:16.000000000 +0100 +++ /dev/null 2009-12-14 11:04:22.000000000 +0100 @@ -1,239 +0,0 @@ -# This is a sample config file for tgt-admin. -# By default, tgt-admin looks for its config file in /etc/tgt/targets.conf - -# This one includes other config files: - -include /etc/tgt/temp/*.conf - - -# Set the driver. If not specified, defaults to "iscsi". - -default-driver iscsi - - -# Continue if tgtadm exits with non-zero code (equivalent of -# --ignore-errors command line option) -#ignore-errors yes - - -# Sample target with one LUN only. Defaults to allow access for all initiators: - -<target iqn.2008-09.com.example:server.target1> - backing-store /dev/LVM/somedevice -</target> - - -# Similar, but we use "direct-store" instead of "backing-store". -# "direct-store" reads drive parameters with sg_inq command and sets them to -# the target. -# Parameters fatched with sg_inq are: -# - Vendor identification -# - Product identification -# - Product revision level -# - Unit serial number (if present) -# We also specify "incominguser". - -<target iqn.2008-09.com.example:server.target2> - direct-store /dev/sdd - incominguser someuser secretpass12 -</target> - - -# An example with multiple LUNs, disabled write-cache (tgtd enables write-cache -# by default) and vendor identification set to "MyVendor" - -<target iqn.2008-09.com.example:server.target3> - backing-store /dev/LVM/somedevice1 # Becomes LUN 1 - backing-store /dev/LVM/somedevice2 # Becomes LUN 2 - backing-store /dev/LVM/somedevice3 # Becomes LUN 3 - write-cache off - vendor_id MyCompany Inc. -</target> - - -# Similar to the one above, but we fetch vendor_id, product_id, product_rev and -# scsi_sn from the disks. -# Vendor identification (vendor_id) is replaced in all disks by "MyVendor" - -<target iqn.2008-09.com.example:server.target4> - direct-store /dev/sdb # Becomes LUN 1 - direct-store /dev/sdc # Becomes LUN 2 - direct-store /dev/sdd # Becomes LUN 3 - write-cache off - vendor_id MyCompany Inc. -</target> - - -# Note that "first-device-first-lun numbering" will work only for simple -# scenarios above, where _only_ direct-store _or_ backing-store is used. -# If you mix backing-store and direct-store, then all backing-store entries -# are processed before direct-store-entries. - -<target iqn.2008-09.com.example:server.target4> - direct-store /dev/sdb # Becomes LUN 3 - backing-store /dev/sdc # Becomes LUN 1 - direct-store /dev/sdd # Becomes LUN 4 - backing-store /dev/sde # Becomes LUN 2 -</target> - - -# Even more complicated example - each device has different parameters. -# You can use indentation to make the config file more readable. -# Note that LUNs will be assigned more or less randomly here (and still -# backing-store get LUNs assigned before drect-store). -# You can specify multiple mode_page parameters (they are commented out -# in this example). -# Note that some parameters (write-cache, scsi_sn) were specified "globally". -# "Global" parameters will be applied to all LUNs; they can be overwritten -# "locally", per LUN. -# If lun is not specified, it will be allocated automatically (first available). - -<target iqn.2008-09.com.example:server.target5> - - <direct-store /dev/sdd> - vendor_id VENDOR1 - removable 1 - device-type cd - lun 1 - </direct-store> - - <direct-store /dev/sda> - vendor_id VENDOR2 - lun 2 - </direct-store> - - <backing-store /dev/sdb1> - vendor_id back1 - scsi_sn SERIAL - write-cache on - # lun 3 # lun is commented out - will be allocated automatically - </backing-store> - - <backing-store /dev/sdd1> - vendor_id back2 - #mode_page 8:0:18:0x10:0:0xff.... - #mode_page 8:0:18:0x10:0:0xff.... - #bs-type aio - #params element_type=4,start_address=500,quantity=3,media_home=/root/tapes - #params element_type=4,address=500,tid=1,lun=1 - lun 15 - </backing-store> - - # Some more parameters which can be specified locally or globally: - #scsi_id ... - #scsi_sn ... - #vendor_id ... - #product_id ... - #product_rev ... - #sense_format ... - #removable ... - #online ... - #path ... - #mode_page 8:0:18:0x10:0:0xff.... - #mode_page 8:0:18:0x10:0:0xff.... - #device-type ... - #bs-type ... # backing store type - default rdwr, can be aio, mmap, etc... - #params element_type=4,start_address=500,quantity=3,media_home=/root/tapes - #params element_type=4,address=500,tid=1,lun=1 - #allow-in-use yes # if specified globally, can't be overwritten locally - - write-cache off - scsi_sn multipath-10 - - # Parameters below are only global. They can't be configured per LUN. - # Only allow connections from 192.168.100.1 and 192.168.200.5 - initiator-address 192.168.100.1 - initiator-address 192.168.200.5 - - # Tuning parameters (global, per target) - #MaxRecvDataSegmentLength 8192 - #MaxXmitDataSegmentLength 8192 - #HeaderDigest None - #DataDigest None - #InitialR2T Yes - #MaxOutstandingR2T 1 - #ImmediateData Yes - #FirstBurstLength 65536 - #MaxBurstLength 262144 - #DataPDUInOrder Yes - #DataSequenceInOrder Yes - #ErrorRecoveryLevel 0 - #IFMarker No - #OFMarker No - #DefaultTime2Wait 2 - #DefaultTime2Retain 20 - #OFMarkInt Reject - #IFMarkInt Reject - #MaxConnections 1 - - # Allowed incoming users - incominguser user1 secretpass12 - incominguser user2 secretpass23 - - # Outgoing user - outgoinguser userA secretpassA - -</target> - - -# The device will have lun 1 unless you specify something else -<target iqn.2008-09.com.example:server.target6> - backing-store /dev/LVM/somedevice - lun 10 -</target> - - -# Devices which are in use (by system: mounted, for swap, part of RAID, or by -# userspace: dd, by tgtd for another target etc.) can't be used, unless you use -# --force flag or add 'allow-in-use yes' option -<target iqn.2008-09.com.example:server.target7> - backing-store /dev/LVM/somedevice - allow-in-use yes -</target> - -<target iqn.2008-09.com.example:server.target8> - <backing-store /dev/LVM/somedevice> - scsi_sn serial1 - </backing-store> - - <backing-store /dev/LVM/somedevice2> - scsi_sn serial2 - </backing-store> - - allow-in-use yes -</target> - - - - - -# Not supported configurations, and therefore, commented out: - -#<target iqn.2008-09.com.example:server.target9> -# backing-store /dev/LVM/somedevice1 -# backing-store /dev/LVM/somedevice2 -# lun 10 -# lun 11 -#</target> - -#<target iqn.2008-09.com.example:server.target10> -# <direct-store /dev/sdd> -# vendor_id VENDOR1 -# </direct-store> -# -# direct-store /dev/sdc -#</target> - -# This one will break the parser: - -#<target iqn.2008-09.com.example:server.target11> -# <direct-store /dev/sdd> -# vendor_id VENDOR1 -# </direct-store> -# -# direct-store /dev/sdc -# -# <direct-store /dev/sdd> -# vendor_id VENDOR1 -# </direct-store> -#</target>
--- conf/examples/targets.conf.vtl.L700 2009-12-12 09:01:55.336831887 +0100 +++ conf/examples/targets.conf.vtl.L700.me 2009-12-12 09:00:22.000000000 +0100 @@ -0,0 +1,92 @@ +# Virtual tape library example for a STK L700 tape library +# +# In this case, tapes are stored in the directory /root/tapes +# size is in MB (1 GB in this case) +# using the command "tgtimg --op=new --device-type=tape --barcode="A00000001" --size=10240 --type=data --file=A00000001" +# +# The tapes can be added after startup with +# "tgtadm --lld iscsi --mode logicalunit --op update --tid 1 --lun 4 --params element_type=2,address=1000,barcode=A0000001,sides=1" +# for slot 0 (is nr 1000) +# + +include /etc/tgt/temp/*.conf + +default-driver iscsi + +<target iqn.2008-09.com.example:server.tape> + allow-in-use yes +# +# For every drive We need a backing store, although the tape drive will be empty, +# so we create a dummy tape "notape" in directory /root/tapes +# with the command "tgtimg --op=new --device-type=tape --barcode="" --size=1 --type=clean --file=notape" +# and create symbolic links for every drive (limitation of tgt) +# link -s /root/tapes/notape /root/tapes/notape1 +# link -s /root/tapes/notape /root/tapes/notape2 +# link -s /root/tapes/notape /root/tapes/notape2 +# + <backing-store /root/tapes/notape1> + lun 1 + device-type tape + removable 1 + vendor_id "HP" + product_id "LTO3 ULTRIUM" + product_rev "0001" + scsi_sn "HUM1A00001" + scsi_id "HP LTO3 ULTRIUM" + </backing-store> + <backing-store /root/tapes/notape2> + lun 2 + device-type tape + removable 1 + vendor_id "HP" + product_id "LTO3 ULTRIUM" + product_rev "0001" + scsi_sn "HUM1A00002" + scsi_id "HP LTO3 ULTRIUM" + </backing-store> + <backing-store /root/tapes/notape3> + lun 3 + device-type tape + removable 1 + vendor_id "HP" + product_id "LTO3 ULTRIUM" + product_rev "0001" + scsi_sn "HUM1A00003" + scsi_id "HP LTO3 ULTRIUM" + </backing-store> + <backing-store /root/smc> + lun 4 + device-type changer + removable 1 + vendor_id "STK" + product_id "L700" + product_rev "0001" + scsi_sn "123:456:789:000" + # Dummy 'page 0' + mode_page "0:0:0" + # Page 0x02: Disconnect/Reconnect SPC-3 + mode_page "0x02:0:14:0x80:0x80:0:0xa:0:0:0:0:0:0:0:0:0:0" + # Page 0x1a: Power Condition SPC-3 + mode_page "0x1a:0:18:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0" + # Page 0x1c: Informational Exceptions Control SPC-3 + mode_page "0x1c:0:10:8:0:0:0:0:0:0:0:0:0" + # Page 0x1d: Element Address Assignment SMC-3 7.3.4 + mode_page "0x1d:0:0x12:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0" + # Page 0x1e: Transport Geometry Parameters SMC-3 7.3.5 + mode_page "0x1e:0:2:0:0" + # Page 0x1f: Device Capabilities SMC-3 7.3.2 + # Page 0x1f/Subpage 0x41: Extended Device Capabilities SMC-3 7.3.3 + mode_page "0x1f:0:0x12:0x0f:7:0x0f:0x0f:0x0f:0x0f:0:0:0:0:0x0f:0x0f:0x0f:0x0f:0:0:0:0" + # Type 1: Medium Transport Elements (robot arm/picker) + params element_type=1,start_address=1,quantity=1,media_home=/root/tapes + # Type 2: Storage Elements (tape slots) + params element_type=2,start_address=1000,quantity=216,media_home=/root/tapes + # Type 3: Import/Export Elements (CAP) + params element_type=3,start_address=10,quantity=20,media_home=/root/tapes + # Type 4: Add Data Transfer devices (drives) + params element_type=4,start_address=500,quantity=3,media_home=/root/tapes + params element_type=4,address=500,tid=1,lun=1 + params element_type=4,address=500,tid=1,lun=2 + params element_type=4,address=500,tid=1,lun=3 + </backing-store> +</target>
--- conf/examples/targets.conf.vtl.MSL2024 2009-12-12 09:01:55.336831887 +0100 +++ conf/examples/targets.conf.vtl.MSL2024.me 2009-12-11 19:17:15.000000000 +0100 @@ -0,0 +1,69 @@ +# Virtual tape library example for an HP MSL-2024 tape library +# +# In this case, tapes are stored in the directory /root/tapes +# size is in MB (1 GB in this case) +# using the command "tgtimg --op=new --device-type=tape --barcode="A00000001" --size=10240 --type=data --file=A00000001" +# +# The tapes can be added after startup with +# "tgtadm --lld iscsi --mode logicalunit --op update --tid 1 --lun 4 --params element_type=2,address=1000,barcode=A0000001,sides=1" +# for slot 0 (is nr 1000) +# +# Please note that an MSL-2024 has no IMPORT/EXPORT elements (type 3) + +include /etc/tgt/temp/*.conf + +default-driver iscsi + +<target iqn.2008-09.com.example:server.tape> + allow-in-use yes +# +# We need a backing store, although the tape drive will be empty, +# so we create a dummy tape "notape" in directory /root/tapes +# with the command "tgtimg --op=new --device-type=tape --barcode="" --size=1 --type=clean --file=notape" +# + <backing-store /root/tapes/notape> + lun 1 + device-type tape + removable 1 + vendor_id "HP " + product_id "Ultrium 3-SCSI" + product_rev "D21W" + scsi_sn "HU012345AB" + scsi_id "HP LTO3 ULTRIUM" + </backing-store> +# +# For the tape changer we need also a backing store, this can be a file containing zeros, like this: +# "dd if=/dev/zero of=$HOME/smc bs=1k count=1" +# + <backing-store /root/smc> + lun 4 + device-type changer + removable 1 + vendor_id "HP " + product_id "MSL G3 Series " + product_rev "3.00" + scsi_sn "ABC01234G3" + # Dummy 'page 0' + mode_page "0:0:0" + # Page 0x02: Disconnect/Reconnect SPC-3 + mode_page "0x02:0:14:0x80:0x80:0:0xa:0:0:0:0:0:0:0:0:0:0" + # Page 0x1a: Power Condition SPC-3 + mode_page "0x1a:0:18:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0" + # Page 0x1c: Informational Exceptions Control SPC-3 + mode_page "0x1c:0:10:8:0:0:0:0:0:0:0:0:0" + # Page 0x1d: Element Address Assignment SMC-3 7.3.4 + mode_page "0x1d:0:0x12:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0" + # Page 0x1e: Transport Geometry Parameters SMC-3 7.3.5 + mode_page "0x1e:0:2:0:0" + # Page 0x1f: Device Capabilities SMC-3 7.3.2 + # Page 0x1f/Subpage 0x41: Extended Device Capabilities SMC-3 7.3.3 + mode_page "0x1f:0:0x12:0x0f:7:0x0f:0x0f:0x0f:0x0f:0:0:0:0:0x0f:0x0f:0x0f:0x0f:0:0:0:0" + # Type 1: Medium Transport Elements (robot arm/picker) + params element_type=1,start_address=1,quantity=1,media_home=/root/tapes + # Type 2: Storage Elements (tape slots) + params element_type=2,start_address=1000,quantity=24,media_home=/root/tapes + # Type 4: Add Data Transfer devices (drives) + params element_type=4,start_address=2,quantity=1,media_home=/root/tapes + params element_type=4,address=2,tid=1,lun=1 + </backing-store> +</target>