Each variant of UNIX has its own names for the tape drives. In this document I will cover Digital UNIX (aka Tru64 UNIX aka OSF/1) and Linux.
Linux
Tape devices under linux have different
names depending on the type of tape involved. The most common sort of tape
(SCSI Tape) will have a device name of 'st'.
So for example the first scsi tape will have the following device special
files
/dev/st0 - normal
rewinding scsi device
/dev/nst0 - non-rewinding
scsi tape device
Floppy tape drives (e.g. iomega ditto, Travan tapes and other QIC Format tape drives) will be called ;
/dev/rft0 - normal rewinding
floppy tape device.
/dev/nrft0 - non-rewinding floppy
tape device.
One major difference between Linux and Digital UNIX devices is that the density code is not used on linux. If you want to write a tape with a density other than the default (usually highest) density then you may need to use the mt command with the densities or setdensities arguments to set the density of the device. Read operations usually do not need the density setting explicitly, as this will be automatically picked up.
Digital UNIX
Device names on Digital UNIX are more complex, As an example let us take the DAT tape on msslae. (mt0)
msslae~> file /dev/rmt0h /dev/rmt0h: character special (9/21506) SCSI #1 TLZ06 tape #104 (SCSI ID #5) errors = 0/900 offline msslae~> ls /dev/*mt0? /dev/nrmt0a /dev/nrmt0l /dev/rmt0a /dev/rmt0l /dev/nrmt0h /dev/nrmt0m /dev/rmt0h /dev/rmt0m msslae~>In the listing there are eight special files which correspond to this tape drive. Each name specifies a different way of treating the tape to be used. From the example above, for magnetic tape 0 (mt0), there are four different densities.
In fact the density designation depends very much on the drive hardware.
For the case of mssly1's DAT drive, which is a TLZ06, "man tz"
gives the following snippet of information
TLZ06: Single-density drive, compaction support. rmt?a 61000 BPI rmt?l 61000 BPI rmt?m 61000 BPI,compaction turned on. rmt?h 61000 BPI, compaction turned on.So, in fact, the only difference is that rmt0h and rmt0m have hardware compression turned on, and rmt0a and rmt0l have it turned off. This means that for this device there are only two effective densities.
Going back to the list of files, there are two further divisions to be made. Those files starting "r" and those starting with "nr". These two sorts refer to the tape handling after all the operations are complete, and the drive is closed. Drives accessed using the "r" filename like /dev/rmt0h will rewind the tape on being closed. Those files starting "nr" will not rewind the tape on closing.
This may seem, on first sight, a funny way of going about things, but it is logical, when you consider the differences between a tape and an ordinary file. If you open and close a file, then open it again you are placed (by default) at the start of the file. For a tape drive this corresponds to the start of the tape, so the normal behaviour is to be like a standard file, and rewind the tape on closure, so that the next time the tape drive is opened, it is positioned at the start of the tape.
This may not be the ideal in many cases however, particularly if you want to append to a tape. In the case of a normal file, opening, and moving to the end of the file, ready to append, is an inexpensive, quick operation. For a tape drive, this sequence can take a significant amount of time however, and so the tape drive can be told (by using the nrmt0h device, rather than the default rmt0h device) to leave the tape where it is once the current operation has been completed.
A frequent problem occurs when
users migrating from VMS forget the difference between the
rmt0h
and nrmt0h devices, and wonder why they cannot position the drive
correctly. This is because the default behaviour is different between the
two systems. This typically occurs when positioning a tape using the "mt"
command. For example the command
mssly1~> mt -f /dev/rmt0h fsf 2to supposedly skip forward by 2 files will, in fact, achieve nothing at all, as the tape will be rewound to its start immediately following the completion of the "mt" command. The correct form of this command would be instead;
mssly1~> mt -f /dev/nrmt0h fsf 2
mt [-f tape_device] command [count]Where tape_device is one of the device special files discussed in the first section, normally a "no rewind" device like /dev/nrmt0h. The commands are detailed in the man page for "mt", but a few important ones will be listed here.
mssly1~> mt -f /dev/nrmt0h fsf 2Will skip forward two files on a DAT on mssly1.
The drive name is optional,
if you are accessing the first tape drive (mt0). For all other drives
the drive name must be explicitly specified on the command line. This is
good practice even if you are using the default drive.
.
tar is the tape archiver program, and provides a quick and easy way of transporting data between UNIX systems, and making user backups. It is stressed that tar is not in the UNIX equivalent of the VMS BACKUP command, as it was not designed to do the same job. VMS BACKUP was designed as a tool for system managers to manage system backups with. In this respect the UNIX analogue is the dump command. The dump and restore commands are used to backup entire disks to tape, normally as part of a system backup schedule. Both these commands provide high data integrity, an incremental facility, and a network protocol for backing up remote workstations. As a consequence dump and restore are quite tightly bound to a particular filesystem and operating system type. For these reasons the reader is referred to the man pages for dump(8) and restore(8) for further information.
The tar program is simpler, and provides a readily transportable
format for data interchange, and can be used whenever guaranteed data integrity
is not an absolute requiement. As the tar program can write to a tape or
a file (The two are essentially the same on UNIX) it also provides a handy
means of packaging files for distribution. It is normally invoked with
one major flag, and several optional flags. Each major flag defines the
purpose of the program. Under OSF/1 the following flags are supported.
Flag Meaning x Extract files from tape. c Create a new archive. t List the table of contents for an archive. u Updates an archive.
A selection of typical commands;
mssly1~> tar cvf /dev/rmt0h /ydb/evn/* mssly1~> tar xvf /dev/rmt0h mssly1~> tar cf /scratch/fred.tar /home/atp/idl /data0/atp/progs/*.pro mssly1~> tar tfv /dev/nrmt1h
The tar command can be made to
read from standard input, and write to standard output. This means that
it can be put in a pipeline of commands. One extremely useful example is
this command;
mssly1~/idl> tar cf - *.pro | (cd /data0/atp/progs ; tar xfv - )This may look horrendous, but works like this;
The first tar program (tar cf - *.pro) makes an archive of all the .pro files in the current directory, and writes the result into a pipe. Waiting at the other end of the pipe, there is the second tar program (tar xfv - ) which has changed its current directory to /data0/atp/progs and which expands the archive written by the first tar program into the new directory. This particular command comes in very handy when you want to move an entire directory tree from one place to another, but dont want to change any of the dates or attributes of the files.
e.g.
mssly1~> dd if=/dev/rmt1h of=/tmp/magtape 2+0 records in 2+0 records out mssly1~> ls -l /tmp/magtape -rw-r--r-- 1 atp 10 1024 Jan 20 17:37 /tmp/magtape mssly1~>
e.g. To list the contents of a tape.
mssly1~> ltf -tvf /dev/rmt0h ltf: Volume ID is: ATP_1 Volume is: ANSI Version 3 ltf: Owner ID is: ltf: Implementation ID is: DECVMSBACKUP t(1,1) --------- -/- Sep 23 199410514(8192)F fred1.bck t(2,1) --------- -/- Sep 23 199410514(8192)F fred2.bck mssly1~>
The program that is used to read VMS backup tapes is called vmsbackup. Again this follows the same pattern as the tar program, with major flags indicating the type of operation, and minor flags modifying some aspects of the selected process.
e.g. To list the contents of a VMS BACKUP tape:
mssly1~> vmsbackup -tvf /dev/rmt0h Volume: SOLAR_BACKUP Saveset name: FRED.BCK number: 1 [ATP]16.DIR;1 7680 16 [ATP.16]16DEC_BFT.DATA;1 33294 66 [ATP.16]2BCS_LC.EPS;1 12706 25 [ATP.16]6_CAXIX_PLOTS_LONG.EPS;1 115494 226 : : : : : : [ATP.X]XV_211_TVTWM.EXE;1 398336 779 [ATP.X]XV_MOTIF.EXE;1 683520 1336 [ATP.X]XWATER.EXE;28 10752 22 [ATP]XTERM.HLB;1 44544 88 End of saveset: FRED.BCK End of tape mssly1~>For more information please see the vmsbackup man page. Also please note that the VMS BACKUP format is proprietary to Digital Equipment Corp. The vmsbackup command is not supplied by DEC, but is public domain software, and therefore not a supported program. It can deal with almost all common types of BACKUP tape, but occasionally it will encounter a format that it cannot decipher, and will be unable to read the data on that tape.
e.g.
mssly1~> tcopy /dev/rmt1h file 0: block size 8192: record 0 file 0: block size 4291: record 1 file 0: eof after 2 records: 12483 bytes file 1: block size 8192: record 0 file 1: block size 4702: record 1 file 1: eof after 2 records: 12894 bytes file 2: block size 5120: 23781 records file 2: eof after 23781 records: 121758720 bytes file 3: block size 5120: 1813 records file 3: eof after 1813 records: 9282560 bytes file 4: block size 5120: : : mssly1~>This information about blocksizes allows me to recognise that this tape is a Yohkoh data tape. It would also allow me to write a program to read the tape, with the correct blocksizes.
mssly1~>tcopy /dev/rmt0h /dev/rmt1h mssly1~>
mssly1~> man -k tape vmsbackup (1) - read a VMS backup tape gentapes (1) - produce distribution magnetic tape media kitcap (4) - Kit descriptor database for gentapes and gendisk utilities. ltf (1) - labeled tape facility ltf (4) - labeled tape facility mt (1) - Magnetic tape manipulating program mtio (7) - magnetic tape interface restore, rrestore (8) - Restores files from tapes written with the dump or rdump command, respectively rmt (8) - Allows remote access to magnetic tape devices tapex (8) - Tape exerciser program tar (1) - Manipulates tape archives tar (4) - Tape archive file format tcopy (1) - Copies magnetic tapes tms (7) - TMSCP magnetic tape interface topen, tclose, tread, twrite, trewin, tskipf, tstate (3f) - FORTRAN tape I/O interface tz (7) - SCSI magnetic tape interfaceThis lists the names of the manual pages (and the sections in brackets) of all the pages which match the keyword "tapes". To read the manual page for the tcopy program mentioned above the command man tcopy would be used.