JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
System Administration Guide: Devices and File Systems
search filter icon
search icon

Document Information

Preface

1.  Managing Removable Media (Overview)

2.  Managing Removable Media (Tasks)

3.  Accessing Removable Media (Tasks)

4.  Writing CDs and DVDs (Tasks)

5.  Managing Devices (Overview/Tasks)

6.  Dynamically Configuring Devices (Tasks)

7.  Using USB Devices (Overview)

8.  Using USB Devices (Tasks)

9.  Using InfiniBand Devices (Overview/Tasks)

10.  Managing Disks (Overview)

11.  Administering Disks (Tasks)

12.  SPARC: Adding a Disk (Tasks)

13.  x86: Adding a Disk (Tasks)

14.  Configuring Oracle Solaris iSCSI Targets and Initiators (Tasks)

15.  The format Utility (Reference)

16.  Managing File Systems (Overview)

17.  Creating ZFS, UFS, TMPFS, and LOFS File Systems (Tasks)

18.  Mounting and Unmounting File Systems (Tasks)

19.  Using The CacheFS File System (Tasks)

20.  Configuring Additional Swap Space (Tasks)

21.  Checking UFS File System Consistency (Tasks)

22.  UFS File System (Reference)

23.  Backing Up and Restoring UFS File Systems (Overview)

24.  Backing Up UFS Files and File Systems (Tasks)

25.  Using UFS Snapshots (Tasks)

26.  Restoring UFS Files and File Systems (Tasks)

27.  UFS Backup and Restore Commands (Reference)

28.  Copying UFS Files and File Systems (Tasks)

Commands for Copying File Systems

Copying File Systems Between Disks

Making a Literal File System Copy

How to Copy a Disk (dd)

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

Copying Files and File Systems to Diskette

What You Should Know When Copying Files to Diskettes

How to Copy Files to a Single Formatted Diskette (tar)

How to List the Files on a Diskette (tar)

How to Retrieve Files From a Diskette (tar)

Archiving Files to Multiple Diskettes

29.  Managing Tape Drives (Tasks)

Index

Copying Directories Between File Systems (cpio Command)

You can use the cpio (copy in and out) command to copy individual files, groups of files, or complete file systems. This section describes how to use the cpio command to copy complete file systems.

The cpio command is an archiving program that copies a list of files into a single, large output file. This command inserts headers between the individual files to facilitate recovery. You can use the cpio command to copy complete file systems to another slice, another system, or to a media device, such as a tape or diskette.

Because the cpio command recognizes end-of-media and prompts you to insert another volume, it is the most effective command, other than ufsdump, to use to create archives that require multiple tapes or diskettes.

With the cpio command, you frequently use the ls and find commands to list and select the files you want to copy, and then to pipe the output to the cpio command.

How to Copy Directories Between File Systems (cpio)

  1. Become superuser or assume an equivalent role.
  2. Change to the appropriate directory.
    # cd filesystem1
  3. Copy the directory tree from filesystem1 to filesystem2 by using a combination of the find and cpio commands.
    # find . -print -depth | cpio -pdm filesystem2
    .

    Starts in the current working directory.

    -print

    Prints the file names.

    -depth

    Descends the directory hierarchy and prints file names from the bottom up.

    -p

    Creates a list of files.

    -d

    Creates directories as needed.

    -m

    Sets the correct modification times on directories.

    For more information, see cpio(1).

    The files from the directory name you specify are copied. The symbolic links are preserved.

    You might also specify the -u option. This option forces an unconditional copy. Otherwise, older files do not replace newer files. This option might be useful if you want an exact copy of a directory, and some of the files being copied might already exist in the target directory.

  4. Verify that the copy was successful by displaying the contents of the destination directory.
    # cd filesystem2
    # ls
  5. If appropriate, remove the source directory.
    # rm -rf filesystem1

Example 28-3 Copying Directories Between File Systems (cpio)

# cd /data1
# find . -print -depth | cpio -pdm /data2
19013 blocks
# cd /data2
# ls
# rm -rf /data1