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:
ID | Attribute | Format |
---|---|---|
0x0002 | TapeAlert flags | Binary |
0x0003 | Load count | Binary |
0x0005 | Assigning organization | ASCII |
0x0006 | Initialization count | Binary |
0x0008 | Volume identifier | ASCII |
0x0009 | Volume change reference | Binary |
0x0224 | Logical position of first encrypted block | Binary |
0x0225 | Logical position of first unecrypted block after first encrypted block | Binary |
0x0400 | Medium manufacturer | ASCII |
0x0401 | Medium serial number | ASCII |
0x0404 | Assigning Organisation | ASCII |
0x0406 | Medium manufacurer date | ASCII |
0x0408 | Medium type | Binary |
0x0800 | Application vendor | ASCII |
0x0801 | Application name | ASCII |
0x0802 | Application version | ASCII |
0x0803 | User medium text label | Text |
0x0804 | Date and time last written | ASCII |
0x0805 | Text localization identifer | Binary |
0x0806 | Barcode | ASCII |
0x0808 | Media pool | Text |
0x0809 | Partition user text label | ASCII |
0x080B | Application format version | ASCII |
0x080C | Volume coherency information | Binary |
0x0820 | Medium globally unique identifier | Binary |
0x0821 | Media pool globally unique identifier | Binary |
0x1623 | Volume locked | Binary |
And here is another open source project for reading useful LTO MAM attributes all at once: https://github.com/speed47/lto-info