JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
System Administration Guide: Devices and File Systems     Oracle Solaris 10 1/13 Information Library
search filter icon
search icon

Document Information

Preface

1.  Managing Removable Media (Overview/Tasks)

2.  Writing CDs and DVDs (Tasks)

3.  Managing Devices (Tasks)

4.  Dynamically Configuring Devices (Tasks)

5.  Managing USB Devices (Tasks)

6.  Using InfiniBand Devices (Overview/Tasks)

7.  Managing Disks (Overview)

8.  Managing Disk Use (Tasks)

9.  Administering Disks (Tasks)

10.  SPARC: Setting Up Disks (Tasks)

11.  x86: Setting Up Disks (Tasks)

12.  Configuring Oracle Solaris iSCSI Targets (Tasks)

13.  The format Utility (Reference)

14.  Managing File Systems (Overview)

15.  Creating and Mounting File Systems (Tasks)

16.  Configuring Additional Swap Space (Tasks)

17.  Checking UFS File System Consistency (Tasks)

18.  UFS File System (Reference)

19.  Backing Up and Restoring UFS File Systems (Overview/Tasks)

20.  Using UFS Snapshots (Tasks)

21.  Copying Files and File Systems (Tasks)

Commands for Copying File Systems

Copying Directories Between File Systems (cpio Command)

How to Copy Directories Between File Systems (cpio)

Copying Files and File Systems to Tape

Copying Files to Tape (tar Command)

How to Copy Files to a Tape (tar)

How to List the Files on a Tape (tar)

How to Retrieve Files From a Tape (tar)

Copying Files to a Tape With the pax Command

How to Copy Files to a Tape (pax)

Copying Files to Tape With the cpio Command

How to Copy All Files in a Directory to a Tape (cpio)

How to List the Files on a Tape (cpio)

How to Retrieve All Files From a Tape (cpio)

How to Retrieve Specific Files From a Tape (cpio)

Copying Files to a Remote Tape Device

How to Copy Files to a Remote Tape Device (tar and dd)

How to Extract Files From a Remote Tape Device

22.  Managing Tape Drives (Tasks)

23.  UFS Backup and Restore Commands (Reference)

Index

Copying Files to Tape With the cpio Command

How to Copy All Files in a Directory to a Tape (cpio)

  1. Change to the directory that contains the files you want to copy.
  2. Insert a write-enabled tape into the tape drive.
  3. Copy the files to tape.
    $ ls | cpio -oc > /dev/rmt/n
    ls

    Provides the cpio command with a list of file names.

    cpio -oc

    Specifies that the cpio command should operate in copy-out mode (-o) and write header information in ASCII character format (-c). These options ensure portability to other vendors' systems.

    > /dev/rmt/n

    Specifies the output file.

    All files in the directory are copied to the tape in the drive you specify, overwriting any existing files on the tape. The total number of blocks that are copied is shown.

  4. Verify that the files have been copied to tape.
    $ cpio -civt < /dev/rmt/n
    -c

    Specifies that the cpio command should read files in ASCII character format.

    -i

    Specifies that the cpio command should operate in copy-in mode, even though the command is only listing files at this point.

    -v

    Displays the output in a format that is similar to the output from the ls -l command.

    -t

    Lists the table of contents for the files on the tape in the tape drive that you specify.

    < /dev/rmt/n

    Specifies the input file of an existing cpio archive.

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

Example 21-6 Copying All Files in a Directory to a Tape (cpio)

The following example shows how to copy all of the files in the /export/home/kryten directory to the tape in tape drive 0.

$ cd /export/home/kryten
$ ls | cpio -oc > /dev/rmt/0
1280 blocks
$ cpio -civt < /dev/rmt/0
-r--r--r--    1 kryten   staff      206663 Jul 14 13:52 2010, filea
-r--r--r--    1 kryten   staff      206663 Jul 14 13:52 2010, fileb
-r--r--r--    1 kryten   staff      206663 Jul 14 13:52 2010, filec
drwxr-xr-x    2 kryten   staff           0 Jul 14 13:52 2010, letters
drwxr-xr-x    2 kryten   staff           0 Jul 14 13:52 2010, reports
1280 blocks

How to List the Files on a Tape (cpio)


Note - Listing the table of contents on a tape takes a long time because the cpio command must process the entire archive.


  1. Insert an archive tape into the tape drive.
  2. List the files on the tape.
    $ cpio -civt < /dev/rmt/n

Example 21-7 Listing the Files on a Tape (cpio)

The following example shows how to list the files on the tape in drive 0.

$ cpio -civt < /dev/rmt/0
-r--r--r--    1 kryten   staff      206663 Jul 14 13:52 2010, filea
-r--r--r--    1 kryten   staff      206663 Jul 14 13:52 2010, fileb
-r--r--r--    1 kryten   staff      206663 Jul 14 13:52 2010, filec
drwxr-xr-x    2 kryten   staff           0 Jul 14 13:52 2010, letters
drwxr-xr-x    2 kryten   staff           0 Jul 14 13:52 2010, reports
1280 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

Caution - The use of 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. Extract all files from the tape.
    $ cpio -icvd < /dev/rmt/n
    -i

    Extracts files from standard input.

    -c

    Specifies that the cpio command should read files in ASCII character format.

    -v

    Displays the files as they are retrieved in a format that is similar to the output from the ls command.

    -d

    Creates directories as needed.

    < /dev/rmt/n

    Specifies the output file.

  4. Verify that the files were copied.
    $ ls -l

Example 21-8 Retrieving All Files From a Tape (cpio)

The following example shows how to retrieve 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 the tape.
    $ cpio -icv "*file" < /dev/rmt/n
    -i

    Extracts files from standard input.

    -c

    Specifies that the cpio command should read headers in ASCII character format.

    -v

    Displays the files as they are retrieved in a format that is similar to the output from the ls command.

    "*file"

    Specifies that all files that match the pattern are copied to the current directory. You can specify multiple patterns, but each pattern must be enclosed in double quotation marks.

    < /dev/rmt/n

    Specifies the input file.

    For more information, see cpio(1).

  4. Verify that the files were copied.
    $ ls -l

Example 21-9 Retrieving Specific Files From a Tape (cpio)

The following example shows how to retrieve all files with the chapter suffix 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