Skip to content
Magnetic tape control tools for Linux SCSI tapes
Branch: master
Clone or download
iustin Remove left-shifting of negative values
Left-shifting of negative values is undefined behaviour according to
the C standard, because it depends on the exact representation. This
code, copied from the Linux kernel, is intended for 2's complement and
can be replaced by well-defined behaviour: ~(-1<<N) is equivalent
to (1<<N)-1.

Signed-off-by: Iustin Pop <>
Latest commit 1345189 Feb 23, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.clang-format LARGE CHURN: reindent source code May 6, 2016
.gitignore Rework the dist target and drop LSM file Feb 7, 2016
.travis.yml Update travis config to run distcheck May 1, 2016 Bump version to 1.3 and update changelog May 1, 2016
COPYING Update the licence file from current kernel sources May 1, 2016
Makefile LARGE CHURN: reindent source code May 6, 2016 Add build status badge to README May 2, 2016
mt.1 Fix small typo in man page May 3, 2016
mt.c Remove left-shifting of negative values Feb 23, 2019
mtio.h Recode all ISO8859-1 files in UTF-8 Feb 4, 2016
stinit.8 Correct stinit man page regarding database list May 3, 2016
stinit.c More formatting fixes Feb 16, 2019
stinit.def.examples Fix a few small typos in stinit.def.examples May 1, 2016

mt-st tools

This directory contains two programs; mt and stinit, used for dealing with Linux-specific tape-drive handling.

The project was authored and is copyright by Kai Mäkisara (, and since version 1.2 is maintained by Iustin Pop ( For copyright information, see the COPYING file.

For more information, bug reports and the source code repository, please see the project homepage at

Build status: Build Status


mt is basically a "standard" mt with additional commands to send the ioctls specific to the Linux SCSI tape driver. The source supports all SCSI tape ioctls up to kernel version 2.6.0 but it can also be compiled in kernels >= 2.0.x (and hopefully with 1.2.x). Although this mt program is tailored for SCSI tapes, it can also be used with other Linux tape drivers using the same ioctls (some of the commands may not work with all drivers).


The program stinit is meant for initializing of SCSI tape drive modes at system startup, when the tape driver module is loaded, or when new tape drivers are initialized using:

echo "scsi add-single-device x y z v" >/proc/scsi/scsi

or (with 2.6 kernels):

echo "y z v" > /sys/class/scsi_host/hostx/scan

where x=host y=channel z=id v=lun (- is wild card for 2.6).

The parameters used in initialization of a tape drive are fetched from a text file. The parameter file is indexed by the inquiry data returned by the drive, i.e., the parameters are defined by the drive manufacturer, model, etc. This means that the initialization for a drive does not depend on its hardware address. A similar method is used by most Unices either within the kernel or outside the kernel.

The contents of the configuration file and the command line parameters are defined in the man page stinit.8. A sample configuration file stinit.def.examples is included in this distribution. It can be used as example when writing descriptions for the tape drives in a system. NOTE that the examples by no means specify what are the "correct" parameters for different types of devices.

The program is configured for maximum of 32 tapes and 4 modes (the default Linux configuration). If the kernel is configured for different number of tape modes, the definitions MAX_TAPES and NBR_MODES in stinit.c should be configured accordingly. (With 8 bit minor numbers NBR_MODES * MAX_TAPES == 128.)


The files:

  • This file.
  • Changes between versions.
  • COPYING: The GNU Public License
  • Makefile: Makefile for programs
  • mt.c: The mt source
  • mt.1: The man page for mt
  • mtio.h: The tape command definitions
  • stinit.c: The stinit source
  • stinit.8: The man page for stinit
  • stinit.def.examples: example configurations for different devices


Really simple:

  • review the makefile
  • make
  • make install
You can’t perform that action at this time.