Sun Microsystems System Administration Guide, Volume 1 (2000) - page 20

 

  Index      Manuals     Sun Microsystems System Administration Guide, Volume 1 (2000)

 

Search            copyright infringement  

 

 

 

 

 

 

 

 

 

 

 

Content      ..     18      19      20     

 

 

 

 

Sun Microsystems System Administration Guide, Volume 1 (2000) - page 20

 

 

Example—Listing the Files on a Tape (cpio)
The following example lists the files on the tape in drive 0.
$ cpio -civt < /dev/rmt/0
drwx--x--x
2 kryten
users
0 Jul 14 09:34 1999, answers
-rw------t
1 kryten
users
800 Jul 14 09:36 1999, b
drwx--x--x
2 kryten
users
0 Jul 14 09:32 1999, sc.directives
-rw------t
1 kryten
users
200000 Jul 14 09:35 1999, direct241
drwx--x--x
2 kryten
users
0 Jul 14 09:32 1999, tests
-rw------t
1 kryten
users
800 Jul 14 09:36 1999, test13times
396 blocks
How to Retrieve All Files From a Tape (cpio)
If the archive was created using relative path names, the input files are built as a
directory within the current directory when you retrieve the files. If, however, the
archive was created with absolute path names, the same absolute paths are used to
recreate the file on your system.
Caution - Using absolute path names can be dangerous because you might
overwrite existing files on your system.
1. Change to the directory where you want to put the files.
2. Insert the tape into the tape drive.
3. Copy all files from the tape to the current directory using the cpio command.
$ cpio -icvd < /dev/rmt/n
Reads in the contents of the tape.
i
Specifies that cpio should read files in ASCII character format.
c
Displays the files being retrieved in a format similar to the
v
output from the ls command.
Create directories as needed.
d
< /dev/rmt/n
Specifies the output file.
Copying UFS Files and File Systems (Tasks)
629
4. Verify the files are copied by listing the contents of the current directory.
$ ls -l
Example—Retrieving All Files From a Tape (cpio)
The following example retrieves all files from the tape in drive 0.
$ cd /var/tmp
cpio -icvd < /dev/rmt/0
answers
sc.directives
tests
8 blocks
$ ls -l
How to Retrieve Specific Files From a Tape (cpio)
1. Change to the directory where you want to put the files.
2. Insert the tape into the tape drive.
3. Retrieve a subset of files from a tape using the cpio command.
$ cpio -icv "*file" < /dev/rmt/n
Reads in the contents of the tape.
i
Specifies that cpio should read headers in ASCII
c
character format.
Displays the files as they are retrieved in a format similar
v
to the output from the ls command.
Specifies that all of the files that match the pattern are
"*file"
copied to the current directory. You can specify multiple
patterns, but each must be enclosed in double quotation
marks.
< /dev/rmt/n
Specifies the input file.
630
4. Verify the files are copied by listing the contents of the current directory.
$ ls -l
Example—Retrieving Specified Files From a Tape (cpio)
The following example retrieves all files with the suffix chapter from the tape in
drive 0.
$ cd /home/smith/Book
$ cpio -icv "*chapter" < /dev/rmt/0
Boot.chapter
Directory.chapter
Install.chapter
Intro.chapter
31 blocks
$ ls -l
See cpio(1) for more information.
How to Copy Files to a Remote Tape Drive (tar
and dd)
1. The following prerequisites must be met to use a remote tape drive:
The local hostname (and optionally the username of the user doing the copy)
must appear in the remote system’s /etc/hosts.equiv file, or the user
doing the copy must have his or her home directory accessible on the remote
machine, and have the local machine name in $HOME/.rhosts. See
hosts.equiv(4) for more information.
An entry for the remote system must be in the local system’s
/etc/inet/hosts file or in the name service hosts file.
2. To test whether or not you have the appropriate permission to execute a remote
command, try the following:
$ rsh remotehost echo test
If "test" is echoed back to you, you have permission to execute remote commands.
If "Permission denied" is echoed, check your setup as described in step 1 above.
3. To copy files to a remote tape drive, use the tar and dd commands.
$ tar cf - files | rsh remotehost dd of=/dev/rmt/n obs=blocksize
Copying UFS Files and File Systems (Tasks)
631
tar cf
Creates a tape archive and specifies the tape device.
- (Hyphen)
Represents a place holder for the tape device.
files
Identifies files to be copied.
Pipes the tar command’s output to a remote shell to
| rsh remotehost
copy the files.
Represents the output device.
dd of=/dev/rmt/n
Represents the blocking factor.
obs=blocksize
4. Remove the tape from the drive and write the names of the files on the tape
label.
Example—Copying Files to a Remote Tape Drive (tar and dd)
# tar cvf - * | rsh mercury dd of=/dev/rmt/0 obs=126b
a answers/ 0 tape blocks
a answers/test129 1 tape blocks
a sc.directives/ 0 tape blocks
a sc.directives/sc.190089 1 tape blocks
a tests/ 0 tape blocks
a tests/test131 1 tape blocks
6+9 records in
0+1 records out
How to Extract Files From a Remote Tape Drive
1. Change to a temporary directory.
$ cd /var/tmp
2. To extract files to a remote tape drive, use the tar and dd commands.
$ rsh remotehost dd if=/dev/rmt/n | tar xvBpf -
632
rsh remotehost
Indicates a remote shell that is started to extract the
files from the tape device using the dd command.
dd if=/dev/rmt/n
Indicates the input device.
| tar xvBpf -
Pipes the output of the dd command to the tar
command used to restored the files.
3. Verify that the files have been extracted.
$ ls -l /var/tmp
Example—Extracting Files From a Remote Tape Drive
$ rsh mercury dd if=/dev/rmt/0 | tar xvBpf -
x answers/, 0 bytes, 0 tape blocks
x answers/test129, 48 bytes, 1 tape blocks
20+0 records in
20+0 records out
x sc.directives/, 0 bytes, 0 tape blocks
x sc.directives/sc.190089, 77 bytes, 1 tape blocks
x tests/, 0 bytes, 0 tape blocks
x tests/test131, 84 bytes, 1 tape blocks
$ ls -l /var/tmp
Copying Files and File Systems to
Diskette
Before you can copy files or file systems to diskette, you must format the diskette.
See Chapter 16 for information on how to format a diskette.
Use the tar command to copy UFS files to a single formatted diskette.
Use the cpio command if you need to copy UFS files to multiple formatted
diskettes. cpio recognizes end-of-media and prompts you to insert the next volume.
Copying UFS Files and File Systems (Tasks)
633
Note - Using the cpio command to copy UFS files to multiple formatted diskettes is
not a straightforward procedure because of Volume Management.
Use double-sided high-density 3.5-inch diskettes (diskettes are marked “DS, HD”).
Things You Should Know When Copying Files to
Diskettes
Copying files to a formatted diskette using thec option of tar destroys any files
already on the diskette.
A diskette that already contains a tar image is not mountable.
How to Copy Files to a Single Formatted Diskette
(tar)
1. Change to the directory that contains the files you want to copy.
2. Insert a formatted diskette that is not write-protected into the drive.
3. Make the diskette available using the volcheck command.
$ volcheck
4. Unmount any file system on the diskette and reformat it.
$ fdformat -U /vol/dev/aliases/floppy0
5. Copy the files to diskette using the tar command.
$ tar cvf /vol/dev/rdiskette0/unlabeled filename ...
The file names you specify are copied to the diskette, overwriting any existing
files on the diskette.
6. Verify that the files copied are on the diskette using the tar command with the
t option, which displays the diskette’s contents. See “How to List the Files on
a Diskette (tar)” on page 635 for more information on listing files.
$ tar tvf /vol/dev/rdiskette0/unlabeled
634
7. Remove the diskette from the drive.
8. Write the names of the files on the diskette label.
Example—Copying Files to a Single Formatted Diskette (tar)
The following example copies two files to a diskette.
$ cd /home/smith
$ ls evaluation*
evaluation.doc
evaluation.doc.backup
$ tar cvf /vol/dev/rdiskette0/unlabeled evaluation*
a evaluation.doc 86 blocks
a evaluation.doc.backup 84 blocks
$ tar tvf /vol/dev/rdiskette0/unlabeled
How to List the Files on a Diskette (tar)
1. Insert a diskette into the drive.
2. Run volcheck to make the diskette available.
$ volcheck
3. Use the tar command to list the files on a diskette.
$ tar tvf /vol/dev/rdiskette0/unlabeled
Example—Listing the Files on a Diskette (tar)
The following example lists the files on a diskette.
$ tar tvf /vol/dev/rdiskette0/unlabeled
rw-rw-rw-6693/10
44032 Jun
9 15:45 evaluation.doc
rw-rw-rw-6693/10
43008 Jun
9 15:55 evaluation.doc.backup
$
See tar(1) for more information.
If you need a multiple-volume interchange utility, use the cpio command. The tar
command is only a single-volume utility.
Copying UFS Files and File Systems (Tasks)
635
How to Retrieve Files From a Diskette (tar)
1. Change to the directory where you want to put the files.
2. Insert the diskette into the drive.
3. Run volcheck to make the diskette available.
$ volcheck
4. Use the tar command to retrieve files from a diskette.
$ tar xvf /vol/dev/rdiskette0/unlabeled
All of the files on the diskette are copied to the current directory.
5. Verify the files have been retrieved by listing the contents of the current
directory.
$ ls -l
6. Remove the diskette from the drive.
Examples—Retrieving Files From a Diskette (tar)
The following example retrieves all the files from a diskette.
$
/home/smith/Evaluations
$ tar xvf /vol/dev/rdiskette0/unlabeled
x evaluation.doc, 44032 bytes, 86 tape blocks
x evaluation.doc.backup, 43008 bytes, 84 tape blocks
$ ls -l
The following example retrieves an individual file from a diskette.
$ tar xvf /vol/dev/rdiskette0/unlabeled evalutation.doc
x evaluation.doc, 44032 bytes, 86 tape blocks
$ ls -l
636
The file names you specify are extracted from the diskette and placed in the current
working directory.
How to Archive Files to Multiple Diskettes
If you are copying large files or file systems onto diskettes, you want to be prompted
to replace a full diskette with another formatted diskette. The cpio command
provides this capability. The cpio commands you use are the same as you would
use to copy files to tape, except you would specify /vol/dev/aliases/floppy0
as the device instead of the tape device name. See “How to Copy All Files in a
Directory to a Tape (cpio)” on page 627 for information on how to use cpio.
Copying Files With a Different Header
Format
Archives created with the SunOS 5.8 cpio command might not be compatible with
older SunOS releases. The cpio command allows you to create archives that can be
read with several other formats. You specify these formats using theH option and
one of these arguments:
crc or CRC - ASCII header with checksum
ustar or USTAR - IEEE/P1003 Data Interchange
tar or TAR - tar header and format
odc - ASCII header with small device numbers
bar - bar header and format
The syntax for using the header options is:
cpio -o -H header-option < file-list
> output-archive
How to Create an Archive for Older SunOS
Releases
Use the cpio command to create the archive.
$ cpio -oH odc < file-list > /dev/rmt/n
TheH values have the same meaning for input as they do for output. If the archive
was created using theH option, you must use the same option when the archive is
read back in or the cpio command will fail, as shown below.
Copying UFS Files and File Systems (Tasks)
637
Example—Creating an Archive for Older SunOS Releases
$ find . -print | cpio -oH tar > /tmp/test
113 blocks
$ cpio -iH bar < /tmp/test
cpio: Invalid header "bar" specified
USAGE:
cpio -i[bcdfkmrstuvBSV6] [-C size] [-E file] [-H hdr]
[-I file [-M msg]] [-R id] [patterns]
cpio -o[acvABLV] [-C size] [-H hdr] [-O file [-M msg]]
cpio -p[adlmuvLV] [-R id] directory
When you create an archive using different options, always write the command
syntax on the media label along with the names of the files or file system on the
archive.
If you do not know which cpio options were used when an archive was created, all
you can do is experiment with different combinations of the options to see which
ones allow the archive to be read.
See cpio(1) for a complete list of options.
Retrieving Files Created With the bar Command
To retrieve files from diskettes that were archived using the SunOS 4.0/4.1 bar
command, use theH bar option to cpio.
Note - You can use only theH bar option withi to retrieve files. You cannot
create files with the bar header option.
How to Retrieve bar Files From a Diskette
1. Change to the directory where you want to put the files.
2. Insert the diskette into the drive.
3. Run volcheck to make the diskette available.
$ volcheck
4. Use the cpio command to retrieve bar files from a diskette.
All the files on the diskette are copied to the current directory.
$ cpio -ivH bar < /vol/dev/rdiskette/unlabeled
638
CHAPTER
47
Managing Tape Drives (Tasks)
This chapter describes how to manage tape drives.
Here is a list of the step-by-step instructions in this chapter:
“How to Display Tape Drive Status” on page 642
“How to Retension a Magnetic Tape Cartridge” on page 643
“How to Rewind a Magnetic Tape Cartridge” on page 644
Choosing Which Media to Use
You typically back up Solaris systems using:
1/2-inch reel tape
1/4-inch streaming cartridge tape
8-mm cartridge tape
4-mm cartridge tape (DAT)
You can perform backups using diskettes, but this is time-consuming and
cumbersome.
The media you choose depends on the availability of the equipment that supports it
and of the media (usually tape) that you use to store the files. Although you must do
the backup from a local system, you can write the files to a remote device.
The table below shows typical media used for backing up file systems and shows the
storage capacity for each. Capacity depends on the type of drive and the data being
written to the tape.
639
TABLE 47-1
Media Storage Capacities
Media
Capacity
1/2-inch reel tape
140 Mbytes (6250 bpi)
2.5-Gbyte 1/4 inch cartridge (QIC) tape
2.5 Gbytes
DDS3 4-mm cartridge tape (DAT)
12 - 24 Gbytes
14-Gbyte 8-mm cartridge tape
14 Gbytes
DLTTM 7000 1/2-inch cartridge tape
35 - 70 Gbytes
Backup Device Names
You specify a tape or diskette drive to use for backup by supplying a logical device
name. This name points to the subdirectory containing the “raw” device file and
includes the logical unit number of the drive. Tape drive naming conventions use a
logical, not a physical, device name. The table below shows this naming scheme.
TABLE 47-2
Basic Device Names for Backup Devices
Device Type
Name
Tape
/dev/rmt/n
Diskette
/vol/dev/rdiskette0/unlabeled
In general, you specify a tape drive device as shown in the figure below.
640
Berkeley (SunOS 4.x) Compatibility
/dev/rmt/XAbn
Optional
Optional
No-rewind
Density
n no-rewind
l
low
omit for rewind
Drive
m
medium
0
h
high
1
u
ultra
2
c
compressed
3
4
n
Figure 47-1
Tape Drive Device Names
If you don’t specify the density, a tape drive typicallys write at its “preferred”
density, which usually means the highest density it supports. Most SCSI drives can
automatically sense the density or format on the tape and read it accordingly. 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.
Also, a SCSI controller can have a maximum of seven SCSI tape drives.
Specifying the Default Density for a Tape Drive
Normally, you specify a tape drive by its logical unit number, which can run from 0
to n. The table below describes how to specify tape device names using default
density settings.
TABLE 47-3
Specifying Default Densities for a Tape Drive
To Specify The ...
Use ...
First drive, rewinding
/dev/rmt/0
First drive, nonrewinding
/dev/rmt/0n
Second drive, rewinding
/dev/rmt/1
Second drive, nonrewinding
/dev/rmt/1n
Managing Tape Drives (Tasks)
641
By default, the drive writes at its “preferred” density, which is usually the highest
density it supports. If you do not specify a tape device, the command writes to drive
number 0 at the default density the device supports.
Specifying Different Densities for a Tape Drive
To transport a tape to a system whose tape drive supports only a certain density,
specify a device name that writes at the desired density. The table below describes
how to specify different densities for a tape drive.
TABLE 47-4
Specifying Different Densities for a Tape Drive
To Specify The ...
Use ...
First drive, low density, rewinding
/dev/rmt/0l
First drive, low density, nonrewinding
/dev/rmt/0ln
Second drive, medium density, rewinding
/dev/rmt/1m
Second drive, nonrewinding, medium density
/dev/rmt/1mn
The unit and density characters are shown in Figure 47-1.
Displaying Tape Drive Status
You can use the status option with the mt command to get status information
about tape drives. The mt command reports information about any tape drives
described in the /kernel/drv/st.conf file.
How to Display Tape Drive Status
1. Load a tape into the drive you want information about.
2. Display tape drive status with the mt command.
# mt -f /dev/rmt/n status
642
3. Repeat steps 1-2, substituting tape drive numbers 1, 2, 3, and so on to display
information about all available tape drives.
Example— Displaying Tape Drive Status
The following example shows status for a QIC-150 tape drive (/dev/rmt/0) and an
Exabyte tape drive (/dev/rmt/1).
$ mt -f /dev/rmt/0 status
Archive QIC-150 tape drive:
sense key(0x0)= No Additional Sense
residual= 0
retries= 0
file no= 0
block no= 0
$ mt -f /dev/rmt/1 status
Exabyte EXB-8200 8mm tape drive:
sense key(0x0)= NO Additional Sense residual= 0
retries= 0
file no= 0
block no= 0
The following example shows a quick way to poll a system and locate all of its tape
drives.
$ for drive in 0 1 2 3 4 5 6 7
> do
> mt -f /dev/rmt/$drive status
> done
Archive QIC-150 tape drive:
sense key(0x0)= No Additional Sense
residual= 0
retries= 0
file no= 0
block no= 0
/dev/rmt/1: No such file or directory
/dev/rmt/2: No such file or directory
/dev/rmt/3: No such file or directory
/dev/rmt/4: No such file or directory
/dev/rmt/5: No such file or directory
/dev/rmt/6: No such file or directory
/dev/rmt/7: No such file or directory
$
Handling Magnetic Tape Cartridges
If errors occur when reading a tape, retension the tape, clean the tape drive, and then
try again.
How to Retension a Magnetic Tape Cartridge
Retension a magnetic tape cartridge with the mt command.
Managing Tape Drives (Tasks)
643
$ mt -f /dev/rmt/n retension
Example—How to Retension a Magnetic Tape Drive
The following example retensions the tape in drive /dev/rmt/1.
$ mt -f /dev/rmt/1 retension
$
Note - Do not retension non-QIC tape drives.
How to Rewind a Magnetic Tape Cartridge
To rewind a magnetic tape cartridge, use the mt command.
$ mt -f /dev/rmt/n rewind
Example—Rewinding a Magnetic Tape Cartridge
The following example rewinds the tape in drive /dev/rmt/1.
$ mt -f /dev/rmt/1 rewind
$
Guidelines for Drive Maintenance and
Media Handling
A backup tape that cannot be read is useless. It is a good idea to clean and check
your tape drives periodically to ensure correct operation. See your hardware manuals
for instructions on procedures for cleaning a tape drive. You can check your tape
hardware by:
Copying some files to the tape, reading them back, and then comparing the
original with the copy.
Or, you could use thev option of the ufsdump command to verify the contents
of the media with the source file system. The file system must be unmounted or
completely idle for thev option to be effective.
Be aware that hardware can fail in ways that the system does not report.
644
Always label your tapes after a backup. If you have planned a backup strategy
similar to those suggested in Chapter 42, you should indicate on the label “Tape A,”
“Tape B,” and so forth. This label should never change. Every time you do a backup,
make another tape label containing the backup date, the name of the machine and
file system backed up, backup level, the tape number (1 of n, if it spans multiple
volumes), plus any information specific to your site. Store your tapes in a dust-free
safe location, away from magnetic equipment. Some sites store archived tapes in
fireproof cabinets at remote locations.
You should create and maintain a log that tracks which media (tape volume) stores
each job (backup) and the location of each backed-up file.
Managing Tape Drives (Tasks)
645

 

 

 

 

 

 

 

Content      ..     18      19      20