This article assumes that you have mt installed on your system.
For RHEL/CentOS this can be installed using the following command
# yum install mt-st
For FreeBSD mt can be installed using the following command
# pkg_add -r mt
For other distributions refer their respective documentation
In the examples below we have used both the rewind and no-rewind tape devices. For understanding the difference between the two see http://www.sprillion.com/rewind-vs-norewind-st0-vs-st1.html
mt -f <tape device> status For example: # mt -f /dev/st0 status SCSI 2 tape drive: File number=-1, block number=-1, partition=0. Tape block size 262144 bytes. Density code 0x4a (no translation). Soft error count since last status=0 General status bits on (1010000): ONLINE IM_REP_EN
Setting a block of zero indicates a variable block size. Any other positive value indicates a fixed block size. Block size should be within the minimum and maximum block size for the tape drive
mt -f <tape device> setblk <block size> (On Linux) mt -f <tape device> blocksize <block size> (On FreeBSD) For example mt -f /dev/st0 setblk 65536 (Fixed block size of 64K) mt -f /dev/st0 setblk 0 (Variable block size
mt -f <tape device> compression 0 (Disable Compression) mt -f <tape device> compression 1 (Enable Compression) For example: To disable compression for /dev/st0 #mt -f /dev/st0 compression 0
mt -f <tape device> rewind
mt -f <tape device> erase For example: # mt -f /dev/st0 rewind (Position at the beginning of the tape) # mt -f /dev/st0 erase (Erase the entire tape)
Most tape drives can erase from the current position of the tape. However some tape drives will refuse to erase from any position other than the beginning of the tape.
Forward spacing is accomplished by the fsr option and backward spacing is accomplished by using the bsr option
For example the following command spaces forward over one record # mt -f /dev/nst0 status SCSI 2 tape drive: File number=0, block number=0, partition=0. Tape block size 262144 bytes. Density code 0x4a (no translation). Soft error count since last status=0 General status bits on (41010000): # mt -f /dev/nst0 fsr 1 # mt -f /dev/nst0 status SCSI 2 tape drive: File number=0, block number=1, partition=0. Tape block size 262144 bytes. Density code 0x4a (no translation). Soft error count since last status=0 General status bits on (1010000): ONLINE IM_REP_EN
Similarly fsf is used to forward space over filemarks, bsf is used to backward space over filemarks.
Refer the man page of mt