Much easier way to encode LTO barcode into the tape cartridge memory

In a previous blog post, I used ITDT on Windows to write a barcode to an LTO6 tape’s 0x0806 attribute. I had to resort to that method because most Linux distros came with the sg_read_attr utility, but no way to write attributes.

But in sg3_utils 1.48 (released 20230801), a sg_write_attr utility was added!

  • sg_write_attr: new utility, Write Attribute is a SPC command that is used mainly by tape drives (ssc)

Now it is trivial to both read and write to the MAM attributes on the command line on a Linux machine connected to the tape drive. Use with caution!

Example of reading an attribute:

[frederick@tornado ~]$ sudo sg_read_attr -f 0x806 /dev/nst0
  Barcode: FJK663L6

Example of writing a barcode:

sudo sg_write_attr /dev/nst0 0x806=FJK683L6

Some other MAM attributes that can be accessed via sg_read_attr and sg_write_attr:

0x0002TapeAlert flagsBinary
0x0003Load countBinary
0x0005Assigning organizationASCII
0x0006Initialization countBinary
0x0008Volume identifierASCII
0x0009Volume change referenceBinary
0x0224Logical position of first encrypted blockBinary
0x0225Logical position of first unecrypted block after first encrypted blockBinary
0x0400Medium manufacturerASCII
0x0401Medium serial numberASCII
0x0404Assigning OrganisationASCII
0x0406Medium manufacurer dateASCII
0x0408Medium typeBinary
0x0800Application vendorASCII
0x0801Application nameASCII
0x0802Application versionASCII
0x0803User medium text labelText
0x0804Date and time last writtenASCII
0x0805Text localization identiferBinary
0x0808Media poolText
0x0809Partition user text labelASCII
0x080BApplication format versionASCII
0x080CVolume coherency informationBinary
0x0820Medium globally unique identifierBinary
0x0821Media pool globally unique identifierBinary
0x1623Volume lockedBinary

And here is another open source project for reading useful LTO MAM attributes all at once:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.