[ Team LiB ] |
Using TapesThis 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 ConventionsTape 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
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 DensityNormally, 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.
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 DriveYou 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
Specifying the No-Rewind OptionAfter 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
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).
If you omit the density character, the tape is usually written at its highest density, not compressed.
Using SCSI 1/4-Inch Cartridge and 1/2-Inch Front-Loaded Reel DrivesFor 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).
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 DrivesHelical 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 DrivesDLT (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 TapesThe following sections contain a few commands for use with streaming tapes. Rewinding a Magnetic TapeTo 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 DriveTo 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 CommandUse 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.
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.
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.
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.
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.
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.
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 CommandThe 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.
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.
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.
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.
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 CommandStarting 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.
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.
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 ] |