[ Team LiB ] Previous Section Next Section

Using Tapes

This section describes tape device-naming conventions, useful commands for streaming tape cartridges, and ways to use the tar, cpio, and pax commands to archive and retrieve files from tapes.

You can use the tar, cpio, and pax commands to copy files and file systems to tape. The command you choose depends on how much flexibility and precision you require for the copy.

Use tar to copy files and directory subtrees to a single tape. Note that the Solaris tar command can archive special files (block and character devices, fifos), but the SunOS 4.x tar command cannot extract them. The cpio command provides better portability between different versions of the UNIX operating system.

Use cpio to copy arbitrary sets of files, special files, or file systems that require multiple tape volumes, or to copy files from Solaris systems to SunOS 4.x systems. The cpio command packs data onto tape more efficiently than does tar and skips over any bad spots in a tape when restoring. The cpio command also provides options for writing files with different header formats (tar, ustar, crc, odc, bar) for portability between systems of different types.

Use pax to copy files, special files, or file systems that require multiple tape volumes or when you want to copy files to and from POSIX-compliant systems.

Because tar, cpio, and pax use the raw tape device, you do not need to format or make a file system on tapes before you use them. The tape drive and device name you use depend on the hardware and configuration for each system.

Tape Device–Naming Conventions

Tape device-naming conventions use a logical—not a physical—device name. Logical tape device files are located in the /dev/rmt subdirectory as symbolic links to the /devices directory. In general, you specify a tape drive device as shown in Figure 2.

Figure 2. Tape Drive Device Names

graphics/08fig01.gif

Device 0 is the first tape device connected to the system (/dev/rmt/0). The tape device could be a QIC-11, QIC-24, QIC-150, 4mm, 8mm, AIT, DTL, or DAT drive.

Specifying the Drive Number by the Default Density

Normally, you specify a tape drive by its logical device name, which is a number from 0 to n. If you do not specify a density, the drive writes at its "preferred" density, which is usually the highest density the tape supports.

graphics/new.gif

You can attach a maximum of seven SCSI tape drives to a narrow SCSI controller. You can attach a maximum of 15 drives to a wide SCSI controller.

To specify the first drive, use the following device name.


/dev/rmt/0

To specify the second drive, use the following device name.


/dev/rmt/1

NOTE. Most device names start their numbering sequence with zero (0). Consequently, when you talk about the first disk or target, its number is 0, not 1.


Specifying Different Densities for a Tape Drive

You may want to transport a tape to a system whose tape drive supports only a certain density. In that case, specify a device name that writes at the desired density. Use the following naming convention.


/dev/rmt/XA

To determine the different densities that are supported for a drive, look at the /dev/rmt subdirectory, which includes the set of tape device files that support different output densities for each tape.

The unit and density characters are shown in Table 61. For example, to specify a raw magnetic tape device on the first (0) drive with medium density, use the following device name.


/dev/rmt/0m

Table 61. Unit and Density Characters in Tape Device Names

Device Name

= /dev/rmt/ XA

X

Tape drive number (digit) from 0 to n, regardless of controller type.

A

Density (character), depending on controller and drive type.

null

Default, preferred (highest) density.

l

Low.

m

Medium.

h

High.

u

Ultra.

c

Compressed.

Specifying the No-Rewind Option

After the command is executed, the tape is automatically rewound unless you specify the no-rewind option as part of the device name. You would specify no-rewind when you intend to continue writing to the tape at the place just after you completed writing the last time.

To specify no rewinding, type n at the end of the device name.

For example, to specify a raw magnetic tape device on the first (0) drive with medium density and no rewind, use the following device name.


/dev/rmt/0mn



Understanding Device Abbreviations for Different Tape Controllers and Media

graphics/new.gif

You can have both SCSI and non-SCSI tape drives on the same system. A narrow SCSI controller can have a maximum of seven SCSI tape drives, and a wide SCSI controller can have a maximum of 15 tape drives. For each drive number (X), the density character depends on the controller and drive type, as described in the following paragraphs.

For 1/2-inch, rack-mounted tape drives with either a Tapemaster or Xylogics 472 controller, substitute the density from Table 62 for the A variable in the device name (/dev/rmt/ XA).

Table 62. Designating Density for Rack-Mounted, 1/2-Inch Tape Drives

Character

Density

null

Default "preferred" (highest) density (usually 6250 bpi uncompressed).

l

800 bpi.

m

1600 bpi.

h

6250 bpi.

u

6250 bpi compressed.

If you omit the density character, the tape is usually written at its highest density, not compressed.

graphics/new.gif

Each SCSI tape drive vendor encodes the vendor and tape drive model into their drives. When the OpenBoot PROM or Solaris Operating Environment probes the SCSI bus, each SCSI device returns its SCSI information that contains the vendor and drive model data. Solaris matches the returned value against each entry in the /kernel/drv/st.conf file and turns on the proper SCSI transport and tape drive features such as compression and data density.

Using SCSI 1/4-Inch Cartridge and 1/2-Inch Front-Loaded Reel Drives

For SCSI 1/4-inch cartridge and 1/2-inch front-loaded reel drives—a set of legacy drives—substitute the density from Table 63 for the A variable in the device name (/dev/rmt/ XA).

Table 63. Designating Format or Density for SCSI Tape Drives

Character

Density, 1/4-Inch Cartridge

Density, 1/2-Inch Front-Loaded Reel-to-Reel

null

Default, preferred (highest) density.

Default, preferred (highest) density.

l

QIC-11 format.

800 bpi.

m

QIC-24 format.

1600 bpi.

h

QIC-150.

6250 bpi.

u

Reserved.

Reserved.

For 1/4-inch cartridges, density is specified by the format in which the data is written: the QIC format. The QIC-11 and QIC-24 formats write approximately 1000 bpi on each track. The density for QIC-150 is somewhat higher. The preferred density for a 60-Mbyte 1/4-inch cartridge drive is QIC-24 and for a 150-Mbyte 1/4-inch cartridge drive, it is QIC-150.

A 150-Mbyte drive can write only QIC-150; it cannot be switched to write QIC-24 or QIC-11. Format selection is useful only for drives that can write both QIC-24 and QIC-11.

Specifying Helical Scan Drives

Helical scan drives (for example, Exabyte 8mm or Wang/DAT 4mm) are a special case of SCSI drives. They write only at the preferred density. Consequently, you always specify them by using only the drive number, for example, /dev/rmt/0. You can also specify the no-rewind option.

Using DLT and AIT Tape Drives
graphics/new.gif

DLT (Digital Linear Tape) 1/2-inch cartridge tapes have a 35- to 70-Gbyte capacity and a standard SCSI-2 interface that can connect to a wide range of host adapters, including Fast-Wide SCSI. The DLT7000 supports most data management software packages, including Solstice Backup and VERITAS NetBackup.

AIT (Advanced Intelligent Tape) is another standard SCSI tape device with an intelligent chip inside each tape cartridge.

When you add a DLT or AIT drive to a Solaris system, check for an appropriate entry in the /kernel/drv/st.conf file. It is likely that no relevant entry exists for a new tape drive. Contact the vendor of the drive for the syntax of the line to insert into the /kernel/drv/st.conf file. Once you insert the line in the file and reboot the system, Solaris can take full advantage of all features of the new tape drive.

Useful Commands for Streaming Tapes

The following sections contain a few commands for use with streaming tapes.

Rewinding a Magnetic Tape

To rewind a magnetic tape, type mt -f /dev/rmt/n rewind and press Return. The tape in the tape drive you specify by the device number n is rewound.

The following example rewinds the tape in drive /dev/rmt/1.


oak% mt -f /dev/rmt/1 rewind
oak%



Showing the Status of a Magnetic Tape Drive

To show the status of a magnetic tape drive, type mt -f /dev/rmt/ n status and press Return. Status for the tape drive you specify is displayed.

The following example shows that no tape is in drive /dev/rmt/1.


oak% mt -f /dev/rmt/1 status
/dev/rmt/1: no tape loaded or drive offline
oak%

The following example shows the status for the tape in drive /dev/rmt/1.


oak% mt -f /dev/rmt/1 status
Archive QIC-150 tape drive:
   sense key(0x6)= unit attention   residual= 0   retries= 0
   file no= 0 block no= 0
oak%




The tar Command

Use the tar command to copy files and directory subtrees to a single tape. The advantages of the tar command are that it is available on most UNIX operating systems and that public domain versions are readily available. The disadvantages of the tar command are that tar is not aware of file system boundaries, full path-name length cannot exceed 255 characters, tar does not copy empty directories or special files such as device files, and it cannot be used to create multiple tape volumes.

graphics/new.gif

NOTE. The /usr/sfw/bin/gtar GNU tar command now ships with the Solaris 9 Operating Environment and has none of the limitations of the tar command.


The following sections describe how to use the tar command to copy files to a tape, list the files, append the files, and retrieve the files.

Copying Files to a Tape (tar)

Use the following steps to copy files to a tape.

  1. Change to the directory that contains the file you want to copy.

  2. Insert a write-enabled tape into the tape drive.

    CAUTION. Copying files to a tape with the c option to tar destroys any files already on the tape. If you want to preserve the files already on the tape, use the r option described in "Appending Files to a Tape (tar)" on page 248.

    Using absolute path names can be dangerous because you can overwrite the original files, and you cannot choose to restore files to a different location.


  3. Type tar cvf /dev/rmt/n filename filename filename... and press Return.

    The c (create) option copies the files you specify, the v (verbose) option displays information about the files as they are copied, and the f (files) option followed by the tape device name specifies where the tar files are to be written. The file names you specify are copied to the tape, overwriting any existing files on the tape.

    NOTE. You can use metacharacters (? and *) as part of the file names you specify. For example, to copy all documents with a .doc suffix, type *.doc as the file-name argument. If you specify a directory name as the file name, the directory and all its subdirectories are recursively copied to the tape.


  4. Remove the tape from the drive and write the names of the files on the tape label.

The following example copies two files to a tape in tape drive 0.


oak% cd /home/winsor
oak% ls evaluation*
evaluation.doc   evaluation.doc.backup
oak% tar cvf /dev/rmt/0 evaluation*
a evaluation.doc 86 blocks
a evaluation.doc.backup 84 blocks
oak%



Listing the Files on a Tape (tar)

Use the following steps to list the files on a tape.

  1. Insert a tape into the tape drive.

  2. Type tar tvf /dev/rmt /n and press Return.

    The t (table) option lists the files you specify, the v (verbose) option displays complete information about the files as they are listed in a form similar to the ls -l command, and the f (files) option followed by the tape device name specifies the device where the tar files are located.

In the following example, the table of contents for the tape in drive 0 contains two files.


oak% tar tvf /dev/rmt/0
rw-rw-rw-6693/10  44032 Apr 23 14:54 2000 evaluation.doc
rw-rw-rw-6693/10  43008 Apr 23 14:47 2000 evaluation.doc.backup
oak%

Reading from left to right, the first column shows the permissions for the file; the second column shows the UID and GID file ownership; the third column shows the number of characters (bytes) in the file; the fourth, fifth, sixth, and seventh columns contain the month, day, time, and year the file was last modified, and the final column contains the name of the file.

Appending Files to a Tape (tar)

Use the following steps to append files without overwriting files already on the tape.

  1. Change to the directory that contains the file you want to copy.

  2. Insert a tape that is not write-protected into the tape drive.

  3. Type tar rvf /dev/rmt/ n filename filename filename ... and press Return.

    The file names you specify are appended to the files already on the tape in the drive you specify.

    NOTE. You can use metacharacters (? and *) as part of the file names you specify. For example, to copy all documents with a .doc suffix, type *.doc as the file-name argument.


  4. Remove the tape from the drive and write the names of the files on the tape label.

The following example appends one file to the files already on the tape in drive 0.


oak% cd /home/winsor
oak% tar cvf /dev/rmt/0 junk
a junk 1 blocks
oak% tar rvf /dev/rmt/0 evaluation.doc
rw-rw-rw-6693/10  44032 Apr 23 14:54 2000 evaluation.doc
rw-rw-rw-6693/10     18 Dec 10 11:36 2000 junk
oak%

You can put more than one tar archive on a tape if you use the n (no-rewind) option as part of the tape device name. For example, type tar cvf /dev/rmt/ nn filename. The tape is not rewound after the files are copied, and the next time you use the tape, the files are written after the end of the previous set of files. See "Specifying the No-Rewind Option" on page 243 for more information.

Retrieving Files and Directories from a Tape (tar)

Use the following steps to retrieve files from a tape.

  1. Change to the directory into which you want to put the files.

  2. Insert the tape into the tape drive.

  3. Type tar xvf /dev/rmt/ n and press Return.

    All the files on the tape in the drive you specify are copied to the current directory.

The following example copies all files from the tape in drive 0.


oak% cd /home/winsor/Evaluations
oak% tar xvf /dev/rmt/0
x evaluation.doc, 44032 bytes, 86 tape blocks
x evaluation.doc.backup, 43008 bytes, 84 tape blocks
oak%

To retrieve individual files from a tape, type tar xvf /dev/rmt/ n filename filename filename... and press Return. The file names you specify are extracted from the tape and placed in the current working directory. The following example copies the evaluation.doc file from the tape in drive 0.


oak% cd /home/winsor/Evaluations
oak% tar xvf /dev/rmt/0 evaluation.doc
x evaluation.doc, 44032 bytes, 86 tape blocks
oak%

Use the following steps to retrieve directories and subdirectories recursively from a tape.

  1. Change to the parent directory into which you want to copy the files. If the directory already exists, be sure you are in the parent directory and that it is okay to overwrite the contents of the directory before you copy the files from the tape. For example, to restore the contents of a directory named Book that is in /home/winsor/Book, you would change to /home/winsor and type tar xvf /dev/rmt/ n Book and press Return. If you are in the directory /home/winsor/Book, the files are restored as /home/winsor/Book/Book.

  2. Type tar xvf /dev/rmt/ n directory-name and press Return.

    The directory and all its subdirectories are recursively copied from the tape.

NOTE. The names of the files extracted from the tape exactly match the names of the files stored on the archive. If you have any doubts about the names or paths of the files, first list the files on the tape. See "Listing the Files on a Tape (tar)" on page 248 for instructions and the tar(1) manual page for more information.


The cpio Command

The cpio command copies files, special files (files used to represent peripheral devices attached to a system), and file systems that require multiple tape volumes, and provides compatibility for copying files from Solaris systems to SunOS 4.x systems. Advantages of using the cpio command are that it packs data onto tape more efficiently than does the tar command, skips over any bad spots in a tape when restoring files, provides options for writing files with different header formats (tar, ustar, crc, odc, bar) for portability between different system types, and creates multiple tape volumes.

When you use the cpio command to create an archive, the command takes a list of files or path names from standard input and writes to standard output. You redirect the output to a file, a directory, or a device. The following sections describe how to use the cpio command to copy files to a cartridge tape, list the files, retrieve all files, and retrieve a subset of the files from a cartridge tape.

Copying All Files in a Directory to a Tape (cpio)

Use the following steps to copy all files in a directory to a tape.

  1. Insert a write-enabled tape into the tape drive.

  2. Type ls | cpio -oc > /dev/rmt/ n and press Return.

    The o option copies the files. The c option writes header information in ASCII character form for portability. All the files in the directory are copied to the tape in the drive you specify, overwriting any existing files on the tape, and the total number of blocks copied is displayed.

  3. Remove the tape from the drive and write the names of the files on the tape label.

In the following example, all the files in the directory /home/winsor/TOI are copied to the tape in tape drive 0.


oak% cd /home/winsor/TOI
oak% ls | cpio -oc > /dev/rmt/0
31 blocks
oak%



Listing the Files on a Tape (cpio)

Use the following steps to list files on a tape.

  1. Insert a tape into the tape drive.

  2. Type cpio -civt < /dev/rmt/ n and press Return. The -c option reads header information in ASCII character format for portability. The i option reads in the contents of the tape. The v option displays the output in a format similar to the output from the ls -l command. The t option lists the table of contents for the files on the tape in the tape drive you specify.

    NOTE. Listing the table of contents takes as long as it does to read the archive file because the cpio command must process the entire archive.


    In the following example, the table of contents for the tape in drive 0 contains four files.


oak% cpio -civt < /dev/rmt/0
100666 winsor    3895  Feb 24 15:13:02 2000  Boot.chapter
100666 winsor    3895  Feb 24 15:13:23 2000  Directory.chapter
100666 winsor    6491  Feb 24 15:13:52 2000  Install.chapter
100666 winsor    1299  Feb 24 15:14:00 2000  Intro.chapter
31 blocks
oak%

The first column shows permissions in octal format; the second column shows the owner of the file; the third column displays the number of characters (bytes) in the file; the fourth, fifth, sixth, and seventh columns show the month, date, time, and year the file was last modified; and the final column shows the name of the file.

Retrieving All Files from a Tape (cpio)

If the archive was created with relative path names, the input files are built as a directory within the current directory. If, however, the archive was created with absolute path names, the same absolute paths are used to re-create the file.

CAUTION. Using absolute path names can be dangerous because you can overwrite the original files and you cannot choose to restore files to a different location.


Use the following steps to retrieve all files from a tape.

  1. Change to the directory into which you want to put the files.

  2. Insert the tape into the tape drive.

  3. Type cpio -icv < /dev/rmt/ n and press Return.

    All the files on the tape in the drive you specify are copied to the current directory.

The following example copies all files from the tape in drive 0.


oak% cpio -icv < /dev/rmt/0
Boot.chapter
Directory.chapter
Install.chapter
Intro.chapter
31 blocks
oak%



Retrieving a Subset of Files from a Tape (cpio)

You can retrieve a subset of the files from the archive by specifying a pattern to match and using shell wildcard characters enclosed in quotation marks after the options.

  1. Change to the directory into which you want to put the files.

  2. Insert the tape into the tape drive.

  3. Type cpio -icv "* file" < /dev/rmt/n and press Return.

    All the files that match the pattern "* file" are copied to the current directory. You can specify multiple patterns, but each must be enclosed in quotation marks.

The following example copies all files that end in the suffix chapter from the tape in drive 0.


oak% cd /home/winsor/Book
oak% cpio -icv "*chapter" < /dev/rmt/0
Boot.chapter
Directory.chapter
Install.chapter
Intro.chapter
31 blocks
oak%

See the cpio(1) manual page for more information.

The pax Command

Starting with the Solaris 2.5 release, the pax command, which stands for portable archive interchange, is provided. The pax command provides better portability than do the tar or cpio commands for POSIX-compliant systems. Use the pax command to copy files, special files, or file systems that require multiple tape volumes or when you want to copy files to and from POSIX-compliant systems. Disadvantages of the pax command are that it is not aware of file system boundaries and that the full path-name length cannot exceed 255 characters.

Copying All Files in a Directory to a Tape (pax)

Use the following steps to use the pax command to copy all the files in the current directory to a tape.

  1. Change to the directory that contains the files you want to copy.

  2. Insert a write-enabled tape into the tape drive.

  3. Type pax -w -f /dev/rmt/ n . and press Return.

    The -w option writes the current directory contents to tape. The -f option identifies the tape drive. The dot (.) at the end of the command specifies the current directory. The pax command does not list the files as they are copied.

  4. Type pax -l -f /dev/rmt/ n and press Return.

    The -l option lists the files on the tape to verify that the files are copied.

  5. Remove the tape from the drive and write the names of the files on the tape label.

The following example copies all files from the tape in drive 0.


castle% pax -w -f /dev/rmt/0 .
castle% pax -l -f /dev/rmt/0
.
./addusr-1.rs
./addusr-2.rs
./at-addmn.rs
./at-base.rs
./at-menu.rs
castle%

See the pax(1) manual page for more information.

NOTE. When you use the pax command to copy files to a single-volume tape, you can also list and retrieve files from that tape with the tar command.


Retrieving All Files on a Tape (pax)

Use the following steps to use the pax command to copy all the files on a tape into the current directory.

  1. Change to the directory into which you want to copy the files.

  2. Insert a write-enabled tape into the tape drive.

  3. Type pax -r -f /dev/rmt/ n. and press Return.

    The -r option reads the contents of the tape to the current directory. The -f option identifies the tape drive. The dot (.) at the end of the command specifies the current directory. The pax command does not list the files as they are copied.

  4. Type ls -l and press Return.

    The ls -l command lists the files in the current directory and shows their permissions to verify that the files are copied.

  5. Remove the tape from the drive and write the names of the files on the tape label.

The following example copies all files from the tape in drive 0.


castle% pax -r -f /dev/rmt/0 .
castle% ls -l
-rw-rw-rw-   1 winsor  staff   245660 Sep 12 11:52 addusr-1.rs
-rw-rw-rw-   1 winsor  staff   245660 Sep 12 10:31 addusr-2.rs
-rw-rw-rw-   1 winsor  staff   181315 Sep 12 10:29 at-addmn.rs
-rw-rw-rw-   1 winsor  staff   181309 Sep 12 10:27 at-base.rs
-rw-rw-rw-   1 winsor  staff   181315 Sep 12 10:28 at-menu.rs
castle%




    [ Team LiB ] Previous Section Next Section