Magnetic tape is a non-volatile storage medium consisting of a magnetic coating on a thin plastic strip. Nearly all recording tape is of this type, whether used for video, audio storage or general purpose digital data storage using a computer.

Linux (and other Unixish system) use mt command to control magnetic tape drive operation. You need to use mt command while working with tape drive. It allows you to reading and writing to tape.

The default tape drive under Linux is /dev/st0 (first SCSI tape device name). You can read more about tape drives naming convention used under Linux here.

Linux supports SCSI, IDE and old floppy based tape devices. Each device has unique name just like hard disk drives. Digital Data Storage (DDS), Digital Audio Tape (DAT) and Digital Linear Tape (DLT) all are supported by Linux and widely used in industry for backup purpose.

SCSI tape device names
The st driver provides the interface to a variety of SCSI tape devices under Linux.

  • First (auto rewind) SCSI tape device name: /dev/st0
  • Second (auto rewind) SCSI tape device name: /dev/st1
  • First the non-rewind SCSI tape devices: /dev/nst0
  • Second the non-rewind SCSI tape devices: /dev/nst1

IDE tape device names
The ht driver provides the interface to a variety of IDE tape devices under Linux.

  • First (auto rewind) IDE tape device name: /dev/ht0
  • Second (auto rewind) IDE tape device name: /dev/ht1
  • First the non-rewind IDE tape devices: /dev/nht0
  • Second the non-rewind IDE tape devices: /dev/nht1

You need to use above devices to backup data to magnetic tape.

Following paragraph summaries command you need to use control tape drive for backup/restore purpose.


Rewind tape drive:

# mt -f /dev/st0 rewind


Backup directory /www and /home with tar command (z - compressed):

# tar -czf /dev/st0 /etc /home


Find out what block you are at with mt command:

# mt -f /dev/st0 tell


Display list of files on tape drive:

# tar -tzf /dev/st0


Restore /etc directory from tape drive into /tmp:

# cd /tmp
# mt -f /dev/st0 rewind
# tar -xzf /dev/st0 etc


Unload the tape:

# mt -f /dev/st0 offline


Display status information about the tape unit:

# mt -f /dev/st0 status


Erase the tape:

# mt -f /dev/st0 erase

You can go BACKWARD or FORWARD on tape with mt command itself:


(a) Go to end of data:

# mt -f /dev/nst0 eod


(b) Goto previous record:

# mt -f /dev/nst0 bsfm 1


(c) Forward record:

# mt -f /dev/nst0 fsf 1



Server is hosted by Alanstudio
Linux Operating System

Recommend screen resolution 1024 x 768 / IE / FireFox
Alan Studio © 2007 by Alan Cheung Hin Lun. All rights reserved.