IBM Support

Reading tape labels using device driver tools

Troubleshooting


Problem

It may necessary to read a tape label using tools external to Tivoli Storage Manager

Resolving The Problem

Tivoli Storage Manager uses standard labels when it writes internal labels on tapes. This means that volume labels are written in EBCDIC characters using 80-byte blocks of VOL1, HDR1, HDR2, and optionally UHL1. How the labels are written on the tape depends on how long the label is.

Labels with 6 or fewer characters
For tapes with volume labels of 6 or fewer characters, Tivoli Storage Manager writes three blocks, each 80 bytes in length. Those blocks are:

    VOL1
    HDR1
    HDR2
In this format, the label is written in the VOL1 block.

For example, the first 10 bytes in the first 80-byte block on a tape are:
First block ---> e5 d6 d3 f1 e3 c1 d7 c5 f0 f9 40 40 40 40 ...(all 40's)
Translating those hexadecimal characters to EBCDIC characters gives:
---> V O L 1 T A P E 0 9
This shows that this is the VOL1 block, and that the volume label is TAPE09.

Labels with more than 6 characters
For tapes with volume labels of more than 6 characters, TSM writes a fourth 80-byte block. The blocks written are:
    VOL1
    HDR1
    HDR2
    UHL1
The VOL1 block now contains only the *UHL1* string, and the actual volume label is written in the UHL1 block.

For example, the leading bytes of the four blocks on a tape are:
First block --> e5 d6 d3 f1 5c e4 c8 d3 f1 5c 40 40 40 40 40 40 ...(all 40's)
Second block --> c8 c4 d9 f1 c1 c4 e2 d4 4b c4 c2 c2 4b e5 f0 f0 ...(all 40's)
Third block --> c8 c4 d9 f2 e4 f2 f6 f2 f1 f4 f0 f0 f0 f0 f0 40 ...(all 40's)
Fourth block --> e4 c8 d3 f1 e3 e2 d4 f0 f0 f1 d3 f1 00 40 40 40 ...(all 40's)

The first block contains e5 d6 d3 f1 5c e4 c8 d3 f1 5c
in hexadecimal characters, which translates in EBCDIC to ---> V O L 1 * U H L 1 *
The *UHL1* string in the first block indicates that the volume label is in the UHL1 block, which is the fourth block. The fourth block contains e4 c8 d3 f1 e3 e2 d4 f0 f0 f1 d3 f1
in hexadecimal characters, which translates in EBCDIC to --> U H L 1 T S M 0 0 1 L 1
This shows that the tape label is TSM001L1.

Several methods are available to read a tape label, either using native operating system commands or the device driver tools.

Reading label blocks using operating system commands on UNIX and Linux :
The "dd" command may be used to dump the contents of a tape label mounted in a tape drive.
For assuming the tape is mounted in the /dev/rmt2 tape drive, the following dd command would read the label and convert it to ascii.

# dd if=/dev/rmt2 conv=ascii
VOL1*UHL1*
HDR1ADSM.BFS.V0000973 00010001 006157 993650000000ADSM
HDR2U2621400000 0
UHL1TSM009L2
0+4 records in.
0+1 records out.

In order to view the content of the label in hexadecimal format, the output may be piped to the od command. For example :

# dd if=/dev/rmt2 | od -tx
0000000 e5d6d3f1 5ce4c8d3 f15c4040 40404040
0000020 40404040 40404040 40404040 40404040
*
0000120 c8c4d9f1 c1c4e2d4 4bc2c6e2 4be5f0f0
0000140 f0f0f9f7 f3404040 404040f0 f0f0f1f0
0000160 f0f0f140 40404040 40f0f0f6 f1f5f740
0000200 f9f9f3f6 f5f0f0f0 f0f0f0f0 c1c4e2d4
0000220 40404040 40404040 40404040 40404040
0000240 c8c4d9f2 e4f2f6f2 f1f4f0f0 f0f0f040
0000260 f0404040 40404040 40404040 40404040
0000300 40404040 40404040 40404040 40404040
*
0000360 e4c8d3f1 e3e2d4f0 f0f9d3f2 40404040
0000400 40404040 40404040 40404040 40404040
*
0+4 records in.
0+1 records out.
0000500


Reading label blocks using device driver tools
It is possible to read the label blocks from a tape by using the lbtest and mttest tools for tapes controlled by the Tivoli Storage Manager device driver, or by using the IBM Tape Diagnostic Tool (ITDT) for the IBM Magstar or Ultrium devices.

Note: The lbtest, mttest, and optest tools are provided "as-is" and are unsupported. They are to be used only under direction from Tivoli Storage Manager support.

Example of using lbtest and mttest :

1. Use lbtest, and use the following options:

1. manual test
1. set device special file name
6. open
8. return element count
9. return library inventory.
11. move medium

2. With the move medium command, move the tape to a desired drive.

3. Use mttest, and use the following options:

1. manual test
1. set device special file name
20.open

4. From the mttest menu, use options:

22. read
60. write block to "block.out"

Notes:
    1. You will get an error stating that only 80 bytes could be read out of 1024. This is normal and can be ignored.
    2. The block.out file will be written in the same directory as mttest was started from.
      For Windows, this is the c:\program files\tivoli\tsm\device directory.
      For AIX, this is /usr/tivoli/tsm/devices/bin directory
      For other UNIX and Linux, this is /opt/tivoli/tsm/devices/bin directory.

5. Rename block.out to block1.out

6. Repeat step 4, and rename block.out to block2.out

7. Repeat step 4, and rename block.out to block3.out

8. Repeat step 4, and rename block.out to block4.out

At this point, you have the 4 blocks. You then need to to translate the hexadecimal characters in the blocks of data to EBCDIC characters. Again, the example as before gives the following first block of data:

$ more block.out
block bytes 00000 - 00015: e5 d6 d3 f1 e3 c1 d7 c5 f0 f9 40 40 40 40 40 40 (..........@@@@@@)
block bytes 00016 - 00031: 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 (@@@@@@@@@@@@@@@@)
block bytes 00032 - 00047: 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 (@@@@@@@@@@@@@@@@)
block bytes 00048 - 00063: 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 (@@@@@@@@@@@@@@@@)
block bytes 00064 - 00079: 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 (@@@@@@@@@@@@@@@@)
analyze rc 0 err 0 (Successful,Error 0)
cc 0 (Successful) resid 0 data 0
block.out: END

In the above example, the first 10 bytes in the first 80-byte block are:
e5 d6 d3 f1 e3 c1 d7 c5 f0 f9
Translating those hexadecimal characters to EBCDIC characters gives:
V O L 1 T A P E 0 9
This shows that this is the VOL1 block and that the tape volume label is TAPE09.


Example of using ITDT :
The same thing can be achieved by using the ITDT tool on Windows, UNIX and Linux. This tool was previously known as ntutil on Windows, tapeutil on AIX and IBMtapeutil on Sun Solaris, HP-UX, or Linux.

In the case of ITDT on Windows, the following commands may be used.

1. Obtain the library inventory

itdt -f \\.\Changer0 inventory

For example :

C:\>itdt -f \\.\Changer0 inventory
Reading element status...
...
Drive Address 2
Drive State ................... Normal
ASC/ASCQ ...................... 0000
Media Present ................. No
Robot Access Allowed .......... Yes
Source Element Address Valid .. No
Accessor Preferred Zone........ A (TS3500 only)
Media Inverted ................ No
Same Bus as Medium Changer .... Yes
SCSI Bus Address Valid ........ No
Logical Unit Number Valid ..... No
Volume Tag ....................
...
Slot Address ................... 1026
Slot State .................... Normal
ASC/ASCQ ...................... 0000
Media Present ................. Yes
Robot Access Allowed .......... Yes
Source Element Address ........ 2
Media Inverted ................ No
Volume Tag .................... 000000L3


2. Using the inventory output from step 1, identify a slot address of the tape and the drive address and run the move command. For example :

C:\>itdt -f \\.\Changer0 move 1026 2
Moving medium: source 1026, destination 2...
Exit with code: 0


3. Use the read command to read the label. For example :

C:\>itdt -f \\.\tape0 read -d blocks.out -c 1
Initializing device...
Reading 4 records from tape...
Opening destination file C:\blocks.out...
Setting block size to variable...
Read complete, 4 records 320 total bytes read...
Transferrate 0.01 Mbytes/s...
Exit with code: 0

This command will output the label in the blocks.out file

4. Move the tape back to its original slot. For example :

C:\>itdt -f \\.\Changer0 move 2 1026
Moving medium: source 2, destination 1026...
Exit with code: 0


5. Use tools to convert the output file to ebcdic values. For example, the below Windows vbs script (ebcdic.vbs) reads from a file and outputs 4 lines of 20 characters converted to their corresponding hex value codes. The 20 characters of each line are the first 20 characters of each 80-bytes block from the label. The sample ebcdic.vbs script follows :

Dim args, fso
set args = WScript.Arguments
filein=args(0)
Set fso = CreateObject("Scripting.FileSystemObject")
Set filehandle = fso.OpenTextFile(filein, 1)
For i = 1 to 4
thestring=""
for j = 1 to 80
Onechar=filehandle.Read(1)
If j < 20 then thestring = thestring & Hex(Asc(Onechar)) & " " End If
next
WScript.Echo thestring
next

Run the script using the csript command. For example :

C:\>cscript ebcdic.vbs blocks.out
...
E5 D6 D3 F1 5C E4 C8 D3 F1 5C 40 40 40 40 40 40 40 40 40
C8 C4 D9 F1 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40
C8 C4 D9 F2 E4 F2 F6 F2 F1 F4 F0 F0 F0 F0 F0 40 F0 40 40
E4 C8 D3 F1 E3 E2 D4 F0 F0 F1 D3 F3 40 40 40 40 40 40 40

In the above example, the leading bytes of the four blocks are :
First block --> E5 D6 D3 F1 5C E4 C8 D3 F1 5C 40 40 40 40 40 40 40 40 40
Second block --> C8 C4 D9 F1 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40
Third block --> C8 C4 D9 F2 E4 F2 F6 F2 F1 F4 F0 F0 F0 F0 F0 40 F0 40 40
Fourth block --> E4 C8 D3 F1 E3 E2 D4 F0 F0 F1 D3 F3 40 40 40 40 40 40 40

This shows that the first block contains "E5 D6 D3 F1 5C E4 C8 D3 F1 5C" in hexadecimal values, which translates in EBCDIC to ---> V O L 1 * U H L 1 *.
The *UHL1* string in the first block indicates that the volume label is in the UHL1 block, which is the fourth block. The fourth block contains E4 C8 D3 F1 E3 E2 D4 F0 F0 F1 D3 F3 in hexadecimal values, which translates in EBCDIC to --> U H L 1 T S M 0 0 1 L 3
This shows that the tape label is TSM001L3.


How to translate hexadecimal to EBCDIC characters
There are several Web sites that offer hexadecimal to EBCDIC translation. You can also use the "Enterprise Systems Architecture/370 Reference Summary" manual, and look up the "Code Assignments" table which maps hexadecimal characters to ASCII and EBCDIC. The manual is available online at:
http://publibz.boulder.ibm.com/epubs/pdf/sa227209.pdf

[{"Product":{"code":"SSGSG7","label":"Tivoli Storage Manager"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Server","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Supported Versions","Edition":"","Line of Business":{"code":"LOB26","label":"Storage"}}]

Document Information

Modified date:
17 June 2018

UID

swg21193760