LinuxCommandLibrary

mt

controls magnetic tape drive operations, commonly used with LTO and other SCSI

TLDR

Check status of a tape drive

$ mt -f [/dev/nst0] status
copy
Rewind tape to beginning
$ mt -f [/dev/nst0] rewind
copy
Forward space a number of files
$ mt -f [/dev/nst0] fsf [count]
copy
Rewind and position at beginning of specified file
$ mt -f [/dev/nst0] asf [count]
copy
Position tape at end of data
$ mt -f [/dev/nst0] eod
copy
Rewind and eject tape
$ mt -f [/dev/nst0] eject
copy
Write EOF mark at current position
$ mt -f [/dev/nst0] eof
copy

SYNOPSIS

mt [-f device] operation [count]

DESCRIPTION

mt controls magnetic tape drive operations, commonly used with LTO (Linear Tape-Open) and other SCSI tape drives. It provides commands for positioning, rewinding, ejecting, and writing control marks on tape media.
The device is specified with -f option or via the TAPE environment variable. Use /dev/nstX for non-rewinding devices (preserves position after operations) or /dev/stX for auto-rewinding devices.

PARAMETERS

-f _device_, -t _device_

Specify tape device (e.g., /dev/nst0, /dev/st0)
-h
List available commands
-v, --version
Display version information

OPERATIONS

status

Print tape drive status and position
rewind
Rewind tape to beginning
fsf _count_
Forward space specified number of files
bsf _count_
Backward space specified number of files
fsr _count_
Forward space specified number of records
bsr _count_
Backward space specified number of records
asf _count_
Rewind and position at beginning of specified file
eod, seod
Space to end of valid data
weof _count_, eof
Write EOF (end-of-file) marks
eject, offline, rewoffl
Rewind and unload/eject tape
erase
Erase entire tape (long operation)
retension
Rewind, wind to end, rewind again (conditions tape)
seek _block_
Seek to specified block number (SCSI)
tell
Print current block number (SCSI)

CAVEATS

Tape operations can be slow, especially erase and retension. Using the wrong device (st vs nst) can cause unexpected tape rewinding. Some operations are SCSI-specific. Ensure correct device permissions for non-root access.

HISTORY

mt (magnetic tape) has been a standard Unix utility since early Unix systems for controlling tape drives. The Linux version supports additional SCSI tape features beyond traditional operations.

SEE ALSO

tar(1), dd(1), st(4)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community