KB Logo

TOLIS Group Knowledge Base

Browse KB by category:
Go to KB #:
Email   Bookmark

How do I use the 'taperead' command?

Views: 14098
Votes: 3
Posted: 15 Oct, 2007

Reading a tape with taperead

The taperead utility reads the raw data from a tape and provides it as standard output to be used by whatever utility that you wish to pipe it to. For example, to read a tar tape written on a Sun Solaris system and restore its data onto your OS X system, the following command can be executed in the Terminal :

taperead –f ntape0 | tar –xvf –

The result is that taperead will read the raw data off of the tape in the ntape0 device and send the data stream to the input of the tar command. The tar command will then process this stream as if it were reading the tape directly and restore the data to your OS X system.

If you execute taperead without piping its output to another application, you will see the output written to your Terminal session. There is no damage in this, but your Terminal session can become unreadable. To repair this, simply exit the Terminal and start a fresh session.

The taperead command has 3 options, none of which are required unless the defaults are not correct:

-b size (in bytes) - default is 10240
-f device - default is ntape0

By default, it will use ntape0 as the device with a buffer size of 10k (10240 bytes). This default buffer size was selected because it is the default buffer size used by tar on all systems. Be aware that if this default was changed when the tape was originally written (using tar’s –b option), you will need to specify the appropriate size when reading the tape with taperead and in the tar command.

taperead Examples with TAR

A tar tape is written under Linux using a 64K (65536 bytes) buffer size:

tar –cvb 128 –f /dev/nst0 /home/tjones

To restore this tape to your OS X system using taperead and tar, you would use:

taperead –b 65536 | tar –xvb 128 –f –

Note that tar measures its buffer size in 512 byte blocks indifferences to bytes or Kbytes. Therefore, the 128 passed to the original tar command is the equivalent of 128 * 512, or 65536 bytes (64k). Also, tar’s –f argument is the ‘-‘, our stdin.

Important TAR Notes

TAR does not monitor the permissions of the user restoring the data, so any user may restore the data from the other system, not just the superuser ‘root’ or the system administrator account.

TAR automatically strips any leading ‘/’ off of its archives, so if you want to restore the data to its original location and the archive was created from the root of the original system, you must cd to ‘/’ (root) on your OS X system and either use sudo or su to the root account to ensure all is restored as closely to the original state as possible. If you restore to your current path, you will recreate the original directory structure under your current working directory.

taperead Examples with CPIO

The cpio tool is slightly different in the manner in which it is used. The examples below are not designed to be a cpio tutorial, but simply to provide examples of how to use cpio in conjunction with taperead. Please refer to the many sources of information on cpio for more specific command descriptions (‘man cpio’ to get started).
To read a tape in drive ntape1 created under IBM’s AIX using the cpio defaults:

taperead –f ntape1 –b 5120 | cpio –vicdumB

This will read the data in 5120 (5K) chunks and pass it through to cpio for restore. For information on the cpio options used, refer to the cpio man page.

Others in this Category
document OS X Standard I/O Streams
document How do I use the 'tapecopy' command to copy a tape?
document How do I write to a tape with the 'tapewrite' command?
document How do I control my tape library with the libctl (tm) command on Mac OS X?
document How can I test to see if my tape drive/library is operating properly under Mac OS X?
» More Articles

Powered by KnowledgebasePublisher
Page Load Time: 0.027909 seconds / 27.909 milliseconds.
Page File Size: 23851 bytes.