Click on any of the 687 commands below to get a description and list of available options. All links in the command summaries point to the online version of the book on Safari Bookshelf.
Control a magnetic tape drive used to back up or restore system data. The version of the mt command documented here is mt-st, which includes support for the st driver for SCSI tape devices. The operation argument determines what action will be taken, and, unless the -f or -t option is used, the action is applied to the default tape drive named in the TAPE environment variable. The count argument determines how many times the operation is to be repeated. If not specified, it defaults to 1. Some operations take one or more arguments other than a count, as noted in the descriptions below.
Options
-fdevice, -tdevice
Name the tape device to use. This may be a local device, a character special file (see mknod), or a remote device, named in the format host:/path/to/drive or user@host:path/to/drive.
-h, --help
Print usage message and exit. -h prints a simple usage message, while --help also prints a list of commands.
-V, --version
Print version number and exit. Also tells you if you are running mt-st or the GNU version of mt.
Operations
mt can perform the following operations on tape drives. Operations applicable only to SCSI tape drives are marked as such.
asfn
Move to file number n on the tape. This is the same as rewinding the tape and moving forward n files with fsf.
bsfn
Move backward n files, positioning the tape at the last block of the previous file.
bsfmn
Move backward n file marks, to a position on the side of the file mark closer to the beginning of the tape.
bsrn
Move backward n records.
bssn
SCSI drives only. Move backward n set marks.
compression
SCSI drives only. Allow the internal drive compression to be turned on and off with the MTCOMPRESSION ioctl. Overrides the default value for the current tape. Not supported by all drives.
defblksizen
SCSI drives only. Set the default block size to n, overriding the default for this tape. Setting n to -1 disables the default block size. Requires superuser privileges.
defcompressionn
SCSI drives only. Set the default compression state. Set n to -1 to disable the default compression. Use compression to override the default for the current tape. Requires superuser privileges.
defdensityn
SCSI drives only. Set the default density code. Set n to -1 to disable the default density. Use setdensity to override the default for the current tape. Requires superuser privileges.
defdrvbuffern
SCSI drives only. Set the default drive buffer code. Set n to -1 to disable the default drive buffer code. Use drvbuffer to override the default for the current tape. Requires superuser privileges.
densities
SCSI drives only. Display information about data densities to standard output.
drvbuffern
SCSI drives only. Set the buffer value. For no buffering, choose 0, and for normal buffering, choose 1. Other values may have different effects depending on the drive. Use to override the default buffer value for the current tape.
eod, seod
Move to the end of valid data on the tape. Used with streamer tapes to append data to the end of the tape.
eof, weofn
Write n end-of-file (EOF) notations at the current location on the tape.
erase
Erase the tape.
fsfn
Move forward n files, positioning the tape at the first block of the next file.
fsfmn
Move forward n file marks, to a position on the side of the file mark closer to the beginning of the tape.
fsrn
Move forward n records.
fssn
SCSI drives only. Move forward n set marks.
load[n]
SCSI drives only. Load the tape, usually used when a new cartridge is inserted. The count, n, can usually be omitted.
lock
SCSI drives only. Lock the tape drive door.
mkpartitionn
SCSI drives only. Format the tape. If n is 0, format with one partition. Otherwise, format with two partitions, using n as the size of the second partition. Partition support must be enabled for the drive, and the drive must be able to format partitioned tapes with the user specifying the partition size.
offline, rewoffl, eject
Rewind and unload the tape (if drive supports unload).
partseekn [partition]
SCSI drives only. Set the tape position to block n in the specified partition. The default partition is 0.
retension
Used when the tape has become loosely wound, usually because it has been dropped, shaken, or transported. Rewinds the tape, moves forward to the end of the tape, then rewinds again.
rewind
Return to the beginning of the tape.
seekn
SCSI drives only. Seek to block n on the tape. Use tell to first find the block number.
setblkn
SCSI drives only. Set the block size to n bytes per record.
setdensityn
SCSI drives only. Set the data density for your tape drive to n. The appropriate value should be in the tape or tape drive documentation. For more information, see the densities operation. Use to override the default density for the current tape.
setpartition [n]
SCSI drives only. Switch to the partition specified by n. The default partition is 0.
status
Display the status of the tape drive.
stclearoptionsbits
SCSI drives only. Clear the selected driver option bits, specified as described for stoptions. Requires superuser privileges.
stlongtimeoutsecs
Set the long timeout for the drive, in seconds. Requires superuser privileges.
stoptionsn
SCSI drives only. Set the driver option bits for the device. Requires superuser privileges. Set by ORing the option bits from /usr/include/linux/mtio.h to n, or with the following keywords. Multiple keywords can be specified, and unambiguous abbreviations are allowed.
async-writes
Enable asynchronous writes.
auto-lock
Automatically lock and unlock the drive door.
buffer-writes
Enable buffered writes.
can-bsr
Drive can space backwards.
can-partitions
Drive supports partitioned tapes.
debug
Turn on debugging (must have been compiled into the driver).
def-writes
Block size and density are for writes.
fast-eod
Space directly to the end of the valid data; file number is lost.
no-blklimits
Drive does not support read block limits.
no-wait
Don't wait for operations, such as rewind, to complete.
read-ahead
Enable read-ahead for fixed block size.
scsi2logical
seek and tell operations use SCSI-2 logical block addresses instead of device-dependent addresses.
sysv
Enable the use of System V semantics.
two-fms
Write two file marks when a file is closed.
stsetclnn
Set the cleaning-request interpretation parameters.
stsetoptions
SCSI drives only. Set the selected driver option bits, specified as described for stoptions. Requires superuser privileges.
sttimeout secs
Set the normal timeout for the drive, in seconds. Requires superuser privileges.
stwrthresholdn
SCSI drives only. Set the write threshold for the tape drive to n kilobytes. This value may not be higher than the driver buffer value. Requires superuser privileges.
tell
SCSI drives only. Report the number of the current block on the tape.
unlock
SCSI drives only. Unlock the tape drive door.
wsetn
SCSI drives only. Write n set marks at current position.