Trashed Tar tape

Ari Kahan 0004068145 at mcimail.com
Fri Sep 21 06:08:01 AEST 1990


In re:
>Can someone help?  A full tape was made unreadable.  The error probably
>was someone typing 'tar cv <filename>' instead of 'tar xv <filename>'.
>Since the file was not on the harddrive at that point, a 'file does
>not exist' came up and the data on the tape is now inaccesible.  Since
>the tape has not been advanced, it stands to reason that the data is
>still on it, but unix has placed some sort of maer  at the beginning of the t
>I have tried the mt comands to forward over EOF markers, but no luck.
>If anyone can help, please contact me directly, since I am not a
>regular subscriber to this list.  Vikram_varma at cc.sfu.ca
>Thanks.  Vik.


Here's a solution which, in theory, should allow you to
get back everything except the first file on the tar tape.
Since I don't know what flavor of UNIX you're using, it's
hard to know for sure whether it'll work on yours.

As you suspected, the only part of the tape that should be lost
is the very beginning.  Since each file on the tartape has
its own header, the idea is to skip over the first file and
its header to the second file.  So, the concept is to run the contents
of the tape through stdin to tar, but hide the first (mangled)
portion of the contents of the tape from tar.

Tar (unless it's some weird version) stores files in 512 byte
blocks.  So, the first file (with its header) will be sized at
a multiple of 512, regardless of the actual size of the file.  To eliminate
the mangled first file, you can use dd to
skip the first block on the tape, or the first two blocks, or
the first three blocks, until you get something that makes sense.

The command should look something like this:

dd if=/dev/fd1 skip=1 ibs=512 | tar tv
             ^(or however you identify your tape drive)

Try this, changing the value of the skip to skip=2, skip=3,
etc. (you may want to use a batchfile) until you get something
looking like normal output from tar.
(Obviously, this process will go a lot faster if you have some idea
of the size of the first file on the tape.)
Once you know how many blocks to skip, you can use tar as normal.
You just won't get that first file.

Ari Kahan
 



More information about the Comp.unix.questions mailing list