Previous Next Contents

8. Tapes

This section gives information that is specific to scsi tape drives.

8.1 Supported and Unsupported Hardware

Drives using both fixed and variable length blocks smaller than the the driver buffer length (set to 32K in the distribution sources) are supported.

Parameters (block size, buffering, density) are set with ioctls (usually with the mt program), and remain in effect after the device is closed and reopened.

Virtually all drives should work, including :

8.2 Common Problems

Tape drive not recognized at boot time

Try booting with a tape in the drive.

Tapes with multiple files cannot be read properly

When reading a tape with multiple files, the first tar is successful, a second tar fails silently, and retrying the second tar is successful.

User level programs, such as tar, don't understand file marks. The first tar reads up until the end of the file. The second tar attempts to read at the file mark, gets nothing, but the tape spaces over the file mark. The third tar is successful since the tape is at the start of the next file.

Use mt on the no-rewind device to space forward to the next file.

Decompression fails

Decompressing programs cannot handle the zeros padding the last block of the file.

To prevent warnings and errors, wrap your compressed files in a .tar file - ie, rather than doing

tar cfvz /dev/nrst0 file.1 file.2 ...

do

tar cfvz tmp.tar.z file.1 file.2 ...

tar cf /dev/nrst0 tmp.tar.z

Problems taking tapes to/from other systems

You can't read a tape made with another operating system or another operating system can't read a tape written in Linux.

Different systems often use different block sizes. On a tape device using a fixed blocksize, you will get errors when reading blocks written using a different block size.

To read these tapes, you must set the blocksize of the tape driver to match the blocksize used when the tape was written, or to variable.

NOTE : this is the hardware block size, not the blocking factor used with tar, dump, etc.

You can do this with the mt command -

mt setblk <size>

or

mt setblk 0

to get variable block length support.

Note that these mt flags are NOT supported under the GNU version of mt which is included with some Linux distributions. Instead, you must use the BSD derived Linux SCSI mt command. Source should be available from

tsx-11.mit.edu:/pub/linux/ALPHA/scsi

Also note that by default, ST_BUFFER_BLOCKS (defined in /usr/src/linux/drivers/scsi/st_options.h in newer kernels, st.c in older kernels) is set to allow for a 32K maximum buffer size; you'll need to edit the source to use larger blocks.

"No such device" error message

All attempts to access the tape result in a

"No such device"

or similar error message. Check the type of your tape device - it MUST be a character device with major and minor numbers matching those specified in Device Files.

Tape reads at a given density work, writes fail

Many tape drives support reading at lower densities for compatibility with older hardware, but will not write at those same densities.

This is especially the case with QIC drives, which will read old 60M tapes but only write new 120, 150, 250, and 525M formats.

Repositioning the tape locks out access to all SCSI devices

This is most common with SCSI drivers which only support one outstanding command at a time (see Multiple devices for an explanation, and Driver feature comparison to see which drivers suffer from this limitation), although there may be a few tape drives out there which refuse to disconnect.

In either case, you can work around the problem by editing drivers/scsi/st.c and adding a

#define ST_NOWAIT

at the top and rebuilding the kernel.

Note that this will defer error condition reporting until the next SCSI command is executed. For this reason, you may want to do something like a

mt status

after a mt file positioning command so you don't overwrite tape files if the positioning command failed.

You may also wish to consider changing to a better-supported SCSI board or newer tape drive if you need to use this workaround and are writing multiple files to tapes.

8.3 Device Files

SCSI tapes use character device major 9.

Due to constraints imposed by Linux's use of a sixteen bit dev_t with only eight bits allocated to the minor number, the SCSI tape minor numbers are assigned dynamically starting with the lowest SCSI HOST/ID/LUN.

Rewinding devices are numbered from 0 - with the first SCSI tape, /dev/rst0 being c 9 0, the second /dev/rst1 c 9 1, etc. Non-rewinding devices have the high bit set in the minor number, ie /dev/nrst0 is c 9 128.

The standard naming convention is

/dev/nst{digit}         for non-rewinding devices
/dev/st{digit}          for rewinding devices


Previous Next Contents