Tapes

Tasks

Find HW

root@filer04:~# ll /dev/tape/by-id/
total 0
lrwxrwxrwx 1 root root  9 Jul  8 16:29 scsi-1QUANTUM_D0H0281913_LLA -> ../../sg5
lrwxrwxrwx 1 root root  9 Jul  8 16:29 scsi-3500308c38ce84000 -> ../../st1
lrwxrwxrwx 1 root root 10 Jul  8 16:29 scsi-3500308c38ce84000-nst -> ../../nst1
lrwxrwxrwx 1 root root  9 Jul  8 16:29 scsi-3500308c38ce84004 -> ../../st0
lrwxrwxrwx 1 root root 10 Jul  8 16:29 scsi-3500308c38ce84004-nst -> ../../nst0

root@filer04:~# find /dev/tape/by-id/*
/dev/tape/by-id/scsi-1QUANTUM_D0H0281913_LLA
/dev/tape/by-id/scsi-3500308c38ce84000
/dev/tape/by-id/scsi-3500308c38ce84000-nst
/dev/tape/by-id/scsi-3500308c38ce84004
/dev/tape/by-id/scsi-3500308c38ce84004-nst

Make sure that you use the non-rewind device name nst, in the above example scsi-350223344ab000900-nst, and not the auto rewind version st. If you specify auto rewind version st, a rewind command will be issued to the tape drive and the tape will be positioned at the beginning of the tape. When accessing a non-rewind tape device nst, a rewind command is not issued.

Wipe Tape labels

In Bareos: “3920 Cannot label Volume because it is already labeled”

for slot in {11..20}; \
do \
	mtx -f /dev/tape/by-id/scsi-1QUANTUM_D0H0281913_LLA load $slot 1 && \
	mt -f /dev/tape/by-id/scsi-3500308c38ce84004-nst rewind && \
	mt -f /dev/tape/by-id/scsi-3500308c38ce84004-nst weof && \
	mtx -f /dev/tape/by-id/scsi-1QUANTUM_D0H0281913_LLA unload $slot 1; \
done;

Wipe tape completely

dd if=/dev/urandom of=/dev/tape/by-id/scsi-3500110a00169f43e-nst bs=1M status=progress iflag=fullblock

Remove LTFS – EVIL

Wiping the tape won’t work if the tape is partitioned with this stupid system (and your system only sees the first 30GB partition on a 1,5TB tape).

You then have to download configure, configure and use this:

https://github.com/LinearTapeFileSystem/ltfs

mkltfs --device=/dev/tape/by-id/scsi-3500110a00169f43e-nst --wipe

Only then can you use the entirety of the tape >_<

sg_logs – access log pages with SCSI LOG SENSE command

Tape drive

mt – control magnetic tape drive operation

status

root@filer04:~# mt -f /dev/tape/by-id/scsi-3500308c38ce84004-nst status
SCSI 2 tape drive:
File number=0, block number=0, partition=0.
Tape block size 0 bytes. Density code 0x46 (LTO-4).
Soft error count since last status=0
General status bits on (41010000):
 BOT ONLINE IM_REP_EN

eject

mt -f /dev/tape/by-id/scsi-3500110a00169f43e-nst eject

setblk

Set the block size of the drive to count bytes per record, 0 is for variable mode

mt -f /dev/tape/by-id/scsi-3500110a0013c9df6-nst setblk 0

https://www.tandbergdata.com/knowledge-base/index.cfm/integrating-a-tape-drive-into-a-linux-system/

tapeinfo – report SCSI tape device info

root@filer04:~# tapeinfo -f /dev/tape/by-id/scsi-3500308c38ce84004-nst
Product Type: Tape Drive
Vendor ID: 'HP      '
Product ID: 'Ultrium 5-SCSI  '
Revision: 'Z6KZ'
Attached Changer API: No
SerialNumber: 'C38CE84004'
MinBlock: 1
MaxBlock: 16777215
SCSI ID: 0
SCSI LUN: 0
Ready: yes
BufferedMode: yes
Medium Type: Not Loaded
Density Code: 0x46
BlockSize: 0
DataCompEnabled: yes
DataCompCapable: yes
DataDeCompEnabled: yes
CompType: 0x1   
DeCompType: 0x1 
BOP: yes
Block Position: 0
Partition 0 Remaining Kbytes: 800226
Partition 0 Size in Kbytes: 800226
ActivePartition: 0
EarlyWarningSize: 0
NumPartitions: 0
MaxPartitions: 0

Autochanger

mtx – control SCSI media changer devices

mtx -f /dev/tape/by-id/scsi-1QUANTUM_D0H0281913_LLA inquiry
mtx -f /dev/tape/by-id/scsi-1QUANTUM_D0H0281913_LLA status

root@filer04:~# mtx -f /dev/tape/by-id/scsi-1QUANTUM_D0H0281913_LLA unload 12 1
Unloading drive 1 into Storage Element 12...done
root@filer04:~# mtx -f /dev/tape/by-id/scsi-1QUANTUM_D0H0281913_LLA load 5 1
Loading media from Storage Element 5 into drive 1...done