Go to the previous, next section.

Using Multiple Tapes

(This message will disappear, once this node revised.)

Often you might want to write a large archive, one larger than will fit on the actual tape you are using. In such a case, you can run multiple tar commands, but this can be inconvenient, particularly if you are using options like `--exclude=pattern' or dumping entire filesystems. Therefore, tar supports multiple tapes automatically.

Use `--multi-volume' (`-M') on the command line, and then tar will, when it reaches the end of the tape, prompt for another tape, and continue the archive. Each tape will have an independent archive, and can be read without needing the other. (As an exception to this, the file that tar was archiving when it ran out of tape will usually be split between the two archives; in this case you need to extract from the first archive, using `--multi-volume' (`-M'), and then put in the second tape when prompted, so tar can restore both halves of the file.)

When prompting for a new tape, tar accepts any of the following responses:

`?'
Request tar to explain possible responses
`q'
Request tar to exit immediately.
`n file name'
Request tar to write the next volume on the file file name.
`!'
Request tar to run a subshell.
`y'
Request tar to begin writing the next volume.

(You should only type `y' after you have changed the tape; otherwise tar will write over the volume it just finished.)

If you want more elaborate behavior than this, give tar the `--info-script=script-name' (`-F script-name') option. The file script-name is expected to be a program (or shell script) to be run instead of the normal prompting procedure. When the program finishes, tar will immediately begin writing the next volume. The behavior of the `n' response to the normal tape-change prompt is not available if you use `--info-script=script-name' (`-F script-name').

The method tar uses to detect end of tape is not perfect, and fails on some operating systems or on some devices. You can use the `--tape-length=1024-size' (`-L 1024-size') option if tar can't detect the end of the tape itself. The size argument should be the size of the tape.

The volume number used by tar in its tape-change prompt can be changed; if you give the `--volno-file=file-of-number' option, then file-of-number should contain a decimal number. That number will be used as the volume number of the first volume written. When tar is finished, it will rewrite the file with the now-current volume number. (This does not change the volume number written on a tape label (

FIXME: pxref Special Options for Archiving
; it only affects the number used in the prompt.)

If you want tar to cycle through a series of tape drives, then you can use the `n' response to the tape-change prompt. This is error prone, however, and doesn't work at all with `--info-script=script-name' (`-F script-name'). Therefore, if you give tar multiple `--file=archive-name' (`-f archive-name') options, then the specified files will be used, in sequence, as the successive volumes of the archive. Only when the first one in the sequence needs to be used again will tar prompt for a tape change (or run the info script).

Multi-volume archives

With `--multi-volume' (`-M'), tar will not abort when it cannot read or write any more data. Instead, it will ask you to prepare a new volume. If the archive is on a magnetic tape, you should change tapes now; if the archive is on a floppy disk, you should change disks, etc.

Each volume of a multi-volume archive is an independent tar archive, complete in itself. For example, you can list or extract any volume alone; just don't specify `--multi-volume' (`-M'). However, if one file in the archive is split across volumes, the only way to extract it successfully is with a multi-volume extract command `--extract --multi-volume' (`-xM') starting on or before the volume where the file begins.

Go to the previous, next section.