System Administration Guide, Volume 1

Chapter 46 Copying UFS Files and File Systems (Tasks)

This chapter describes how to copy UFS files and file systems to disk, tape, and diskettes using various backup commands.

Here is a list of the step-by-step instructions in this chapter:

Commands for Copying File Systems

When you need to back up and restore complete file systems, use the ufsdump and ufsrestore commands described in Chapter 45, The ufsdump and ufsrestore Commands (Reference). When you want to copy or move individual files, portions of file systems, or complete file systems, you can use the procedures described in this chapter as an alternative to ufsdump and ufsrestore.

The table below describes when to use the various backup commands.

Table 46-1 When to Use Various Backup Commands

If You Want To ... 

Then Use ... 

Reference 

Back up file systems to tape 

ufsdump(1M)

"How to Do Backups to Tape"

Restore file systems from tape 

ufsrestore(1M)

"How to Restore a Complete File System"

Transport files to other systems 

pax(1), tar(1), or cpio(1)

"Copying Files and File Systems to Tape"

Copy files or file systems between disks 

dd(1M)

"How to Clone a Disk (dd)"

Copy files to diskette 

tar(1)

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

The table below describe various backup and restore commands.

Table 46-2 Summary of Various Backup Commands

Command Name 

Aware of File System Boundaries? 

Support Multi-Volume Backups? 

Physical or Logical Copy? 

volcopy

Yes 

Yes 

Physical 

tar

No 

No 

Logical 

cpio

No 

Yes 

Logical 

pax

Yes 

Yes 

Logical 

dd

Yes 

No 

Physical 

ufsdump/ufsrestore

Yes 

Yes 

Logical 

The following sections describe the advantages and disadvantages of each method and provide examples of how to use the commands.

Copying File Systems Between Disks

Two commands are used to copy file systems between disks:

The next section describes how to use the dd command to copy file systems between disks.

Making a Literal File System Copy

The dd command makes a literal (block-level) copy of a complete UFS file system to another file system or to a tape. By default, the dd command copies its standard input to its standard output.


Note -

Do not use the dd command with variable-length tape drives without first specifying an appropriate block size.


You can specify a device name in place of the standard input or the standard output or both. In this example, contents of the diskette are copied to a file in the /tmp directory:


$ dd < /floppy/floppy0 > /tmp/output.file
2400+0 records in
2400+0 records out

The dd command reports on the number of blocks it reads and writes. The number after the + is a count of the partial blocks that were copied. The default block size is 512 bytes.

The dd command syntax is different from most other commands. Options are specified as keyword=value pairs, where keyword is the option you want to set and value is the argument for that option. For example, you can replace the standard input and output with this syntax:


$ dd if=input-file of=output-file

To use the keyword=value pairs instead of the redirect symbols in the previous example, you would type:


$ dd if=/floppy/floppy0 of=/tmp/output.file

How to Clone a Disk (dd)

  1. Make sure the source and destination disks have the same disk geometry.

  2. Become superuser.

  3. Create the /reconfigure file on the system so the system will recognize the clone disk to be added when it reboots.


    # touch /reconfigure
    
  4. Shut down the system.


    # init 0
    
  5. Attach the clone disk to the system.

  6. Boot the system.


    ok boot
    
  7. Use the dd command to copy the master disk to the clone disk.


    # dd if=/dev/rdsk/device-name of=/dev/rdsk/device-name bs=blocksize
    

    if=/dev/rdsk/device-name

    Represents the overlap slice of the master disk device, usually slice 2. 

    of=/dev/rdsk/device-name

    Represents the overlap slice of the clone disk device, usually slice 2. 

    bs=blocksize

    Block size, such as 128 Kbytes or 256 Kbytes. A large block size value decreases the time it takes to copy. 

  8. Check the new file system.


    # fsck /dev/rdsk/device-name
    
  9. Mount the clone disk's root (/) file system.


    # mount /dev/dsk/device-name /mnt
    
  10. Edit the clone disk's /etc/vfstab to reference the correct device names.

    For example, changing all instances of c0t3d0 with c0t1d0.

  11. Unmount the clone disk's root (/) file system.


    # umount /mnt
    
  12. Shut down the system.


    # init 0
    
  13. Boot from the clone disk to single-user mode.


    # boot diskn -s
    

    Note -

    The installboot command is not needed for the clone disk because the boot blocks are copied as part of the overlap slice.


  14. Unconfigure the clone disk.


    # sys-unconfig
    

    The system is shut down after it is unconfigured.

  15. Boot from the clone disk again and provide its system information, such as host name, time zone, and so forth.


    # boot diskn
    
  16. Log in as superuser to verify the system information after the system is booted.


    hostname console login:

Example--Cloning a Disk (dd)


# init 0
ok boot
# dd if=/dev/rdsk/c0t0d0s2 of=/dev/rdsk/c0t2d0s2 bs=128k
# fsck /dev/rdsk/c0t2d0s2
# mount /dev/dsk/c0t2d0s2 /mnt 
# cd /mnt/etc
# vi vfstab
(Modify entries for the new disk)
# cd /
# umount /mnt
# init 0
# boot disk2 -s
# sys-unconfig
# boot disk2

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. It 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 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 cpio, you frequently use commands like ls and find to list and select the files you want to copy, piping the output to the cpio command.

How to Copy Directories Between File Systems (cpio)

  1. Become superuser.

  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 on the way back up. 

    -p

    Creates a list of files. 

    -d

    Creates directories as needed. 

    -m

    Sets the correct modification times on directories. 

    The files from the directory name you specify are copied and 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 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 the copy was successful by displaying the destination directory contents.


    # cd filesystem2
    # ls
    
  5. If appropriate, remove the source directory.


    # rm -rf filesystem1
    

Example--Copying Directories Between File Systems (cpio)


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

See cpio(1) for more information.

Copying Files and File Systems to Tape

The pax, tar, and cpio commands can be used to copy files and file systems to tape. The command you choose depends on how much flexibility and precision you require for the copy. Because all three commands use the raw device, you do not need to format or make a file system on tapes before you use them.

Table 46-3 Advantages and Disadvantages of cpio, pax, and tar Commands

Command 

Function 

Advantages 

Disadvantages 

pax

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 

  • Better portability than the tar or cpio commands for POSIX-compliant systems

  • Multi-vendor support

See disadvantages for tar command, except that pax can create multi-tape volumes

tar

Copy files and directory subtrees to a single tape 

  • Available on most UNIX operating systems

  • Public domain versions are readily available

  • Is not aware of file system boundaries

  • Full pathname length cannot exceed 255 characters

  • Does not copy empty directories or special files such as device files

  • Cannot be used to create multi-tape volumes

cpio

Copy files, special files, or file systems that require multiple tape volumes or when you want to copy files from SunOS 5.8 systems to SunOS 4.0/4.1 systems 

  • Packs data onto tape more efficiently than tar

  • Skips over any bad spots in a tape when restoring.

  • Provides options for writing files with different header formats (tar, ustar, crc, odc, bar) for portability between different system types

  • Creates multi-tape volumes

 

The tape drive and device name you use depend on the hardware and configuration for each system. See "Choosing Which Media to Use" for more information about tape drives and device names.

Copying Files to Tape (tar Command)

Things you should know before copying files to tape with the tar command:

How to Copy Files to a Tape (tar)

  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 with the tar command.


    $ tar cvf /dev/rmt/n filename  ...

    c

    Indicates you want to create an archive. 

    v

    Displays the name of each file as it is archived. 

    f /dev/rmt/n

    Indicates that the archive should be written to the specified device or file. 

    filename ...

    Indicates the files and directories you want to copy. 

    The file names you specify are copied to the tape, overwriting any existing files on the tape.

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

  5. Verify that the files copied are on the tape using the tar command with the t option, which displays the tape's contents. See "How to List the Files on a Tape (tar)" for more information on listing files on a tar tape.


    $ tar tvf /dev/rmt/n
    

Example--Copying Files to a Tape (tar)

The following example copies three files to the tape in tape drive 0.


$ cd /export/home/kryten
$ ls reports
reportA reportB reportC
$ tar cvf /dev/rmt/0 reports
a reports/ 0 tape blocks
a reports/reportA 59 tape blocks
a reports/reportB 61 tape blocks
a reports/reportC 63 tape blocks
$ tar tvf /dev/rmt/n 

How to List the Files on a Tape (tar)

  1. Insert a tape into the tape drive.

  2. Display the tape contents with the tar command.


    $ tar tvf /dev/rmt/n
    

    t

    Lists the table of contents for the files on the tape. 

    v

    Used with the t option, and provides detailed information about the files on the tape.

    f /dev/rmt/n

    Indicates the tape device. 

    filename ...

    Indicates the files and directories you want to retrieve. 

Example--Listing the Files on a Tape (tar)

The following example lists the files on the tape in drive 0.


$ tar tvf /dev/rmt/0
drwx--x--x   0/1        0 Jul 14 09:24 1999 reports/
-rw------t   0/1    30000 Jul 14 09:23 1999 reports/reportA
-rw------t   0/1    31000 Jul 14 09:24 1999 reports/reportB
-rw------t   0/1    32000 Jul 14 09:24 1999 reports/reportC

How to Retrieve Files From a Tape (tar)

  1. Change to the directory where you want to put the files.

  2. Insert the tape into the tape drive.

  3. Retrieve files from the tape using the tar command.


    $ tar xvf /dev/rmt/n [filename ...]

    x

    Indicates that files should be extracted from the specified archive file. All of the files on the tape in the specified drive are copied to the current directory. 

    v

    Displays the name of each file as it is archived. 

    f /dev/rmt/n

    Indicates the tape device containing the archive. 

    filename

    Specifies a file to retrieve. 

  4. Verify the files are copied by listing the contents of the current directory.


    $ ls -l 
    

Example--Retrieving the Files on a Tape (tar)

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


$ cd /var/tmp
$ tar xvf /dev/rmt/0
x reports/, 0 bytes, 0 tape blocks
x reports/reportA, 0 bytes, 0 tape blocks
x reports/reportB, 0 bytes, 0 tape blocks
x reports/reportC, 0 bytes, 0 tape blocks
x reports/reportD, 0 bytes, 0 tape blocks
$ ls -l

Note -

The names of the files extracted from the tape must 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 "How to List the Files on a Tape (tar)" for instructions.


See tar(1) for more information.

Copying Files to a Tape With pax

This section describes how to copy files with the pax command.

How to Copy Files to a Tape (pax)

  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 with the pax command.


    $ pax -w -f /dev/rmt/0 filename ...

    -w

    Enables the write mode. 

    -f /dev/rmt/0

    Identifies the tape drive. 

    filename ...

    Indicates the files and directories you want to copy. 

  4. Verify the files are copied to tape.


    $ pax -f /dev/rmt/0
    
  5. Remove the tape from the drive and write the names of the files on the tape label.

Example--Copying Files to a Tape (pax)


$ pax -w -f /dev/rmt/0 .
$ pax -f /dev/rmt/0
filea fileb filec

See pax(1) for more information.

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

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

  2. Copy files to a tape using the ls and cpio commands.


    $ ls | cpio -oc > /dev/rmt/n
    

    ls

    Provides the cpio command with a list of file names.

    cpio -oc

    Specifies that cpio should operate in copy-out mode (-o) and write header information in ASCII character format (-c). This ensures portability to other vendor's 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 copied is shown.

  3. Verify the files are copied to tape by using the following cpio command.


    $ cpio -civt < /dev/rmt/0
    
  4. Remove the tape from the drive and write the names of the files on the tape label.

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

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


$ cd /export/home/kryten
$ ls | cpio -oc > /dev/rmt/0
92 blocks
$ cpio -civt < /dev/rmt/0
-rw------t    1 kryten     users        400 Jul 14 09:28 1999, b
drwx--x--x    2 kryten     users          0 Jul 14 09:26 1999, letters
-rw------t    1 kryten     users      10000 Jul 14 09:26 1999, letter1
-rw------t    1 kryten     users      10100 Jul 14 09:26 1999, letter2
-rw------t    1 kryten     users      11100 Jul 14 09:27 1999, letter3
-rw------t    1 kryten     users      12300 Jul 14 09:27 1999, letter4
drwx--x--x    2 kryten     users          0 Jul 14 09:27 1999, memos
-rw------t    1 kryten     users        400 Jul 14 09:28 1999, memosmemoU
-rw------t    1 kryten     users        500 Jul 14 09:28 1999, memosmemoW
-rw------t    1 kryten     users        100 Jul 14 09:27 1999, memosmemoX
-rw------t    1 kryten     users        200 Jul 14 09:28 1999, memosmemoY
-rw------t    1 kryten     users        150 Jul 14 09:28 1999, memosmemoZ
drwx--x--x    2 kryten     users          0 Jul 14 09:24 1999, reports
92 blocks
$

How to List the Files on a Tape (cpio)


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.


  1. Insert an archive tape into the tape drive.

  2. List the files on the tape using the cpio command.


    $ cpio -civt < /dev/rmt/n
    

    -c

    Specifies that cpio should read files in ASCII character format.

    -i

    Specifies that cpio should operate in copy-in mode (even though it's only listing files at this point).

    -v

    Displays the output in a format 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 you specify. 

    < /dev/rmt/n

    Specifies the input file of an existing cpio archive.

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 - 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
    

    -i

    Reads in the contents of the tape. 

    -c

    Specifies that cpio should read files in ASCII character format.

    -v

    Displays the files being retrieved in a format similar to the output from the ls command.

    -d

    Create directories as needed. 

    < /dev/rmt/n

    Specifies the output file. 

  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
    

    -i

    Reads in the contents of the tape. 

    -c

    Specifies that cpio should read headers in ASCII character format.

    -v

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

    "*file"

    Specifies that all of the files that match the pattern are 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. 

  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
    

    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. 

    | rsh remotehost

    Pipes the tar command's output to a remote shell to copy the files.

    dd of=/dev/rmt/n

    Represents the output device. 

    obs=blocksize

    Represents the blocking factor. 

  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 -
    

    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, Formatting and Using Diskettes From the Command Line (Tasks) 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.


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

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)" for more information on listing files.


    $ tar tvf /vol/dev/rdiskette0/unlabeled 
    
  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.

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

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)" 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 the -H option and one of these arguments:

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

The -H values have the same meaning for input as they do for output. If the archive was created using the -H option, you must use the same option when the archive is read back in or the cpio command will fail, as shown below.

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 the -H bar option to cpio.


Note -

You can use only the -H bar option with -i 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