Data Loss Prevention   «Prev  Next»

Lesson 3Tape control commands
ObjectiveRecognize tape control commands.

Red Hat Linux Tape Control Commands and Data Loss Protection

The general-purpose command for manipulating tapes is mt. Some of the command options for mt include:
  1. rewind: Rewinds a tape
  2. offline: Prepares the currently loaded tape for ejection and, if applicable, ejects it
  3. fsf: Positions the currently loaded tape
  4. erase: Erases the currently loaded tape


The syntax of the mt command specifies a tape device and then issues a command such as rewind. To specify the device, use the -f option followed by the desired target:
  1. The standard SCSI tape devices are named st0, st1,..., nrst0, nrst1,...
  2. The standard IDE tape devices are named ht0, ht1,..., nrht0, nrht1,...
  3. The standard floppy tape devices are named ftape (rft0) and nftape (nrft0)

Device names beginning with nr refer to "no rewind" devices. Tape devices referenced with a "no rewind" name will not automatically rewind when the device is closed, for example, when a utility such as dump is finished writing.
The following is the general syntax for the mt command:

Database diagram of the pet store schema
  1. mt -f /dev/st0 rewind
  2. Specifies the target device
  3. Indicates the action to perform on the tape.

Linux mt-command
In many cases, mt is used in backup scripts, but may also be used from the command line.

Question: Enter the command used to erase the information stored on the tape in the first no-rewind standard IDE tape device.
[redhat@localhost redhat]$ mt -f /dev/nrht0 erase

Explanation:The command syntax acts as the following:
  1. The -f flag indicates the specific device or file on which to act; in this case, the first no-rewind standard IDE tape device, /dev/nrht0.
  2. erase is the action to perform.

Using ftape tools for magnetic tape

If your tape drive is attached to an IDE floppy controller cable, you will need to use the ftape driver to access it. Fortunately, the ftape loadable module is bundled with the Linux 2.6 kernel. When your Linux system boots, it should autodetect the tape drive and load the ftape driver. To verify that your system loaded the tape driver, type the following command shortly after you boot your computer:

dmesg | grep ftape

This searches the most recent kernel messages for lines containing the word ftape. If the ftape module was loaded, you should see something like this:
ftape v4.04 03/01/2020
[000] ftape-init.c (ftape_init) - installing QIC-117 floppy tape
hardware drive... .
[001] ftape-init.c (ftape_init) - ftape_init @ 0xd08b0060.
[002] ftape-buffer.c (add_one_buffer) - buffer nr #1 @ c1503914, dma
area @ c02c0000.
[003] ftape-buffer.c (add_one_buffer) - buffer nr #2 @ c1503c44, dma
area @ c0298000.
[004] ftape-buffer.c (add_one_buffer) - buffer nr #3 @ c50abaac, dma
area @ c0328000.
[005] ftape-calibr.c (time_inb) - inb() duration: 1109 nsec.
[006] ftape-calibr.c (ftape_calibrate) - TC for `ftape_udelay()' = 310
nsec (at 20479 counts).
[007] ftape-calibr.c (ftape_calibrate) - TC for `fdc_wait()' = 2208 nsec
(at 2559 counts).

If the module was not loaded, then you should check whether your kernel is compiled with support for the ftape module and your particular tape drive. It should be available and ready to include as a loadable module.
In most cases, an ftape device can be accessed just like a SCSI device. The primary difference is that an ftape device file contains the letters qft (for QIK Floppy Tape) where a SCSI tape contains st[1]. For example, the device file for the first SCSI tape on your system will probably be /dev/st0; the device file for the first floppy tape will likely be /dev/qft0.
All of the standard
  1. tape- and
  2. archiving-related programs
should work fine with both types of hardware. Nevertheless, there are a few extra programs that you might find useful when working with a floppy tape drive. These programs can be found in the mt-st package in Fedora. The mt command is used to control magnetic tape operation. The stinit command can initialize SCSI magnetic tape drives.
[1] st - SCSI tape device: The st driver provides the interface to a variety of SCSI tape devices. Currently, the driver takes control of all detected devices of type "sequential-access". The st driver uses major device number 9.