/usr/share/doc/tgt/README.vtl is in tgt 1:1.0.51-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | #!/bin/sh
# This is a simple script to aid in setting up a virtual tape library
# (VTL) using STGT
#
# You can tweak the settings for how many tape drives and how many
# and how big tapes the library should have using the variables below
# Connection number. You can use multiple concurrent TGTD instances as
# long as you give them unique CN numbers and they listen on different
# portals
CN=1
# Listen to port 3260 on wildcard for both ipv4 and ipv6
PORTAL=:3260
# iSCSI name for this target
TARGET=iqn.2012-08.ronnie.vtl
# Number of TAPE Drives for this virtual tape library
NUM_DRIVES=2
# Number of tapes
NUM_TAPES=8
# Tape size in MB
TAPE_SIZE=1024
# Directory where the tape library state and media will be stored
VTLDIR=$HOME/vtl
# Create the directory to store the tapes
if [ ! -d $VTLDIR ]; then
echo Creating directory for VTL : $VTLDIR
mkdir -p $VTLDIR
fi
# make sure we have a backing store for the media changer
if [ ! -f $VTLDIR/smc ]; then
echo Creating a backing store for the media changer : $VTLDIR/smc
dd if=/dev/zero of=$VTLDIR/smc bs=1k count=1 2>/dev/null
fi
# Create the tapes
seq 1 $NUM_TAPES | while read IDX; do
TAPE=`echo $IDX | awk '{printf "%08d", $1}'`
if [ ! -f $VTLDIR/$TAPE ]; then
echo Creating blank tape : $TAPE
tgtimg --op new --device-type tape --barcode $TAPE --size $TAPE_SIZE --type data --file $VTLDIR/$TAPE
fi
done
# Restart tgtd
echo Restart TGTD
tgt-admin -C $CN --update ALL -c /dev/null -f
tgtadm -C $CN --op delete --mode system
tgtd -C $CN --iscsi portal=$PORTAL
sleep 1
echo Create target
tgtadm -C $CN --lld iscsi --op new --mode target --tid 1 -T $TARGET
# Create the tape drives
echo Create tape drives
seq 1 $NUM_DRIVES | while read IDX; do
TAPE=`echo $IDX | awk '{printf "%08d", $1}'`
echo Create tape drive $IDX
tgtadm -C $CN --lld iscsi --mode logicalunit --op new --tid 1 --lun $IDX -b $VTLDIR/$TAPE --device-type=tape
tgtadm -C $CN --lld iscsi --mode logicalunit --op update --tid 1 --lun $IDX --params online=0
done
# Create the changer
echo Create media changer device
LUN=`expr "$NUM_DRIVES" "+" "1"`
tgtadm -C $CN --lld iscsi --mode logicalunit --op new --tid 1 --lun $LUN -b $VTLDIR/smc --device-type=changer
tgtadm -C $CN --lld iscsi --mode logicalunit --op update --tid 1 --lun $LUN --params media_home=$VTLDIR
# Add data transfer devices (one for each tape drive)
echo Adding data transfer devices
tgtadm -C $CN --lld iscsi --mode logicalunit --op update --tid 1 --lun $LUN --params element_type=4,start_address=1,quantity=$NUM_DRIVES
seq 1 $NUM_DRIVES | while read IDX; do
echo Adding data transfer device for drive $IDX
tgtadm -C $CN --lld iscsi --mode logicalunit --op update --tid 1 --lun $LUN --params element_type=4,address=$IDX,tid=1,lun=$IDX
done
# Add medium transport elements (robot arm / picker)
echo Adding medium transport elements
tgtadm -C $CN --lld iscsi --mode logicalunit --op update --tid 1 --lun $LUN --params element_type=1,start_address=$LUN,quantity=1
# Storage elements
echo Adding storage elements
STORAGE=`expr "$LUN" "+" "1"`
tgtadm -C $CN --lld iscsi --mode logicalunit --op update --tid 1 --lun $LUN --params element_type=2,start_address=$STORAGE,quantity=$NUM_TAPES
# Add media to the storage slots
seq 1 $NUM_TAPES | while read IDX; do
TAPE=`echo $IDX | awk '{printf "%08d", $1}'`
echo Loading $TAPE into storage slot $STORAGE
tgtadm -C $CN --lld iscsi --mode logicalunit --op update --tid 1 --lun $LUN --params element_type=2,address=$STORAGE,barcode=$TAPE,sides=1
STORAGE=`expr "$STORAGE" "+" "1"`
done
# Allow anyone to access this target and the VTL
tgtadm -C $CN --lld iscsi --op bind --mode target --tid 1 -I ALL
# show all our good work
tgtadm -C $CN --lld iscsi --op show --mode target
|