during restoration(恢复)of files from a tape with multiple archives, the need arises to position the tape to the archive that holds the necessary files. to accomplish this control, use the mt command,(the name comes from "magnetic(有磁性的,有吸收力的) tape"). the mt command uses a set of simple instructions that directs the tape drive to perform a particular action.
mt
mt [-h][-f device_file] operation [count]
description control a tape drive. the tape drive is intructed to perform the specified operation once, unless count is specified. -h print usage information, including iperation names,and exit. -f device_file specify the device file.if omitted, the default is used. as defined in the header file /usr/include/sys/mtio.h. the typical default is /dev/tape.
popular tape operations
fsf [count] forward space files. move forward the number of files specified by count(archives,in the case of tar). leaving the tape positioned at the first block of the next file.
rewind rewind to the beginning of the tape.
offline eject(驱逐,放逐) the tape.this is appropriate for 8 mm or similar drives. where the tape is handled automatically by the mechanism. ejecting the tape at the end of a backup may prevent at accidental subsequent backup to the same media.this operation is meaningless on devices that cannot eject the tape.
status display status information about the tape drive being used
tell for some SCSI tape drives. report the position of the tape in blocks
example:
move the tape in /dev/sto to the third archive on the tape by skipping forward over two archives:
mt -f /dev/nst0 fsf 2
rewind the tape in /dev/st0:
mt -f /dev/st0 rewind
eject the tape cartridge:
mt -f /dev/st0 offline
detemine what device is represented by the default /dev/tape:
ls -l /dev/tape