Saving to and restoring from a tape device

Use these procedures to save and restore Linux files between a Linux logical partition that uses IBM® i resources and a shared tape drive.

Ensure that your Linux data is in the file server.

Linux typically treats tape as a character device that it can quickly read from or write to in long streams of data, but cannot quickly access to find specific data. By contrast, Linux treats a disk or CD as a block device that it can read from or write to quickly at any point on the device, making it suitable for the mount command.

Complete the following steps to save and restore Linux files between a logical partition that uses IBM i resources and a shared tape drive:
  1. Type the following command: tar -b 40 -c -f /dev/st0 files Use the following descriptions to help you understand the arguments of this command:
    • tar is the command name (the contraction of "tape archive").
    • -b 40 is the block size in sectors. This argument specifies that Linux is to write the archive stream in blocks of 40 sectors (20 KB). If you do not specify a value for this argument, the default value is 20 sectors (10 KB), which does not perform as well over virtual tape as does a value of 40.
    • -c is the command action to create. This argument specifies that the tar command creates a new archive or overwrites an old one (as opposed to restoring files from an archive or adding individual files to an existing archive).
    • -f /dev/st0 is the virtual tape device and number. This argument specifies that the command uses virtual tape 0 on the server. After the tar command runs, the tape device is closed and the tape is rewound. To save more than one archive on the tape, you must keep the tape from rewinding after each use, and you must position the tape to the next file marker. To do this, specify the nst0 (nonrewinding virtual tape) device instead of st0.
    • files are the names of the files and directories that you plan to save.
    You have now saved Linux data from a logical partition that uses IBM i resources to the shared tape drive.
  2. Type the following command: tar -b 40 -x -f /dev/st0 files The -x (extract) argument replaces the -c (create) argument in the tar command used in step 1. You have now restored Linux data from the shared tape drive to a logical partition that is sharing resources.



Last updated: Fri, July 05, 2019