How to use the DAT-tape with Linux

This document describes how to use the DAT-tape standing besides
Gettysburg
with the Linux machine cs-zz12. It asumes some familiarity with Linux
or other UNIX-systems. It is itentionaly kept short, so that you can
find the important information quickly. If you are in a hurry, check
the typical sessions section.

Tape organisation

The tape is structured in multiple files which are in a sequential
order. The individual files are usually tar-archives. You can always
append new files (tar-archives) to the tape (if there is enough space
left).

Handling the tape

Insert the tape softly with the arrow on the upper side, pointing in
the direction of the drive.

It will then be sucked in
automatically. Ejecting the tape is done with the mt-command (see
below).

Important: Before the first “mt” or “tar” command, you must
switch the SCSI Switch to “1”. Otherwise the system will fail to
recognize the SCSI devices (including the tape drive).

Tape operation

You can operate the tape with the command “mt” (magnetic tape). You
use it like this: “mt -f /dev/nst0 command”. For more detailed
information, see the man page. Examples are given
below. The most important commands are:

  • stat: prints the current status of the tape such as
    • file number: The number of the file where the tape currently is
      (where 0 is the first file, -1 is the last).
    • block number: The block number in the current file (here too, 0 is
      the first block and -1 is the last one).
  • rewind: rewind the tape to its beginning.
  • fsf <count>: Forward space <count> files. This is
    also useful to get from the last block of one file to the first block
    of the next file.
  • bsf <count>: Backward space <count> files.
  • eom: Wind to end of media. Useful to append new files to the end
    of the tape.
  • offline: Rewind the tape and eject it.

Examples for the mt-command

  • To get the status of the tape: mt -f /dev/nst0 stat
  • Rewind the tape to the start: mt -f /dev/nst0 rewind
  • Wind to the next file on tape: mt -f /dev/nst0 fsf 1

Transfering data to and from the tape

You usually do this with the “tar” command. “Tar” always needs the
parameter “-f” with the corresponding device, in this case
“/dev/nst0”. The parameter “-v” (verbose) is also suggested. The other
parameters you usually need are:

  • -c: Create (overwrite) tar-archive. If you overwrite a tar-file
    which is not the last one on the tape, all files after the overwritten
    one are lost!
  • -x: Extract from tar-archive at current position on tape.
  • -t: List contents of tar-archive at current position on tape.

Examples for tar-command

  • List the contents of the next tar-file on the tape: tar -tvf /dev/nst0
  • Put the directory (or files and directories) <stuff> (with all
    its sub-directories) at the current position on tape: tar -cvf
    /dev/nst0 <stuff>
  • Extract everything from the next tar-file on the tape into the
    current directory: tar -xvf /dev/nst0
  • Extract (only) <stuff> from the next tar-file on the tape into the
    current directory: tar -xvf /dev/nst0 <stuff>

Typical sessions

Backup / Store

  1. Insert tape in tape drive and probably switch SCSI Switch to one.
  2. Check status of tape: mt -f /dev/nst0 stat
  3. Probably go to end of tape: mt -f /dev/nst0 eom
  4. Store <stuff> on tape: tar -cvf /dev/nst0 <stuff>
  5. Rewind and eject tape: mt -f /dev/nst0 offline

Restore

  1. Insert tape in tape drive and probably switch SCSI Switch to one.
  2. Check status of tape: mt -f /dev/nst0 stat
  3. Go to the directory where you want to restore your file(s).
  4. Go to the right file on the tape with the following commands:
    • Check file number and position in file: mt -f /dev/nst0 stat
    • Advance one file: mt -f /dev/nst0 fsf 1
    • View contents of tar-file: tar -tvf /dev/nst0
    • Go back one file: mt -f /dev/nst0 bsf 1
    • If you are in the last block of a file and you should be at the
      beginning of the file, do the following:

      1. mt -f /dev/nst0 bsf 1
      2. mt -f /dev/nst0 fsf 1

      And check with: mt -f /dev/nst0 stat

  5. Extract your file(s): tar -xvf /dev/nst0 [<files>]
  6. Rewind and eject tape: mt -f /dev/nst0 offline

Remote operation

If your tape drive is in another machine than the machine you want to
backup from, you can use the same tar-commands as described above with
one little change: Login to the machine where the data is and instead
of the tar-archive filename /dev/nst0, you specify hostname:/dev/nst0
(where hostname is the name of the machine where the tape-drive
is). If you need to be another user on the machine with the drive to
access the tape, you can even use the filename
user@hostname:/dev/nst0.

The mt command must still be executed on the machine where the tape
drive is. There is no remot-mt as far as I know.


source:
http://www.cs.inf.ethz.ch/stricker/lab/linux_tape.html

Powered by ScribeFire.

2 thoughts on “How to use the DAT-tape with Linux

  1. The mt command can be provided with ssh:
    haumic@haumic:~$ ssh michael@tapetown mt -f /dev/nst0 asf 0
    mt: /dev/nst0: Device or resource busy

  2. Pingback: Fwolf’s Blog » Blog Archive 磁带机的简单使用 - Fwolf's Blog

Leave a comment