[2258] in linux-scsi channel archive
Re: How to skip over tape eof mark
daemon@ATHENA.MIT.EDU (Christopher Friedman)
Thu Aug 7 00:38:05 1997
Date: Wed, 6 Aug 1997 18:33:05 -0500 (EST)
From: Christopher Friedman <friedman@kryten.iusb.edu>
To: linux-scsi@vger.rutgers.edu
On Wed, 6 Aug 1997, <andy@realbig.com> wrote:
>On Wed, 6 Aug 1997, Louis Mandelstam wrote:
>> I have a tape here (Exabyte 8mm) which had 'mt eof' (write eof
>> marker) executed on it while the tape was wound to the beginning, when the
>> user meant 'mt eod' (seek to end of data). Easy typo that turned out to
>> be surprisingly lethal.
>>
>> I presume the first file will be lost (the first few bytes of it at least)
>> but can anyone tell me how I can manage to get the st driver to skip over
>> this boo-boo so that the rest of the tape can still be accessed?
>
> Sorry, but I think you're SOL. It's the tape drive itself that won't ignore
> the eof marker (which is really a filemark - FM). Or, more correctly, it
> probably can't deal with the (now) corrupted block after the FM. Remember,
> a tape drive is a linear access device. It really has no concept of random
> access. Your linearity was lost when you (this is the "royal you" - i.e.
> they) wrote that FM record over top of your data...
>
> Also, most unix-like tape drivers automatically write two FM's and then
> overwrite the second one when you add another tape file to the tape. Two
> FM's means EOM to a tape drive. According to the st(4) manpage, under
> Linux this depends upon the MT_ST_TWO_FM option setting.
>
I basically agree with Andy except in certain cases where you have multiple
datasets stored on a tape. The data immediately following the double FM will
in all likelihood be irretrievable. However, if multiple datasets have been
stored on the tape, one should be able to skip over the double FM to position
the tape to read other datasets further down the tape. A double FM is the
universal standard to denote end-of-data or, conceptually, "end of useful data
on the tape", as opposed to end-of-media, ie., physical end of tape. Whereas
a single FM is essentially a separator between consecutive datasets.
Here is a crude diagram using three datasets to illustrate what I mean...
Let's say this is the original structure of the tape, where BOT and EOT
denote the beginning and end of the usable storage area of the tape.
BOT ....dataset1.... FM ....dataset2.... FM ....dataset3... FM FM ....... EOT
Now let us say a double FM was inadvertantly written in the middle of
dataset2. The tape may now look something like this:
BOT ....dataset1.... FM ..da FM FM et2.. FM ....dataset3... FM FM ....... EOT
dataset1 has no problems. dataset2 is readable up to the point where it
gets clobbered by the double FM, but the remainder of dataset2 is
non-recoverable. dataset3 is still intact and is readable.
In this scenario (as illustrated) one should be able to position tape at
the beginning of dataset3 and read it. Let's us assume that the tape
device name is /dev/st0 . Then, after loading the tape,
$ mt -f /dev/nst0 fsf 4
should do the trick. Note that it is critical to specify the device name
as "nst0" rather than "st0", thus signifying a "norewind" operation.
Now that the tape is positioned, dataset3 can be read. But again, you
must specify the device name with the "n" or the tape may be rewound
before the read operation is performed and you will read dataset1 rather
than what you want.
I have done this sort of thing in SunOS, AIX and Ultrix environments, but
not yet in Linux. However I see no reason it wouldn't work here as well.
I hope this helps...
Chris Friedman
Indiana University - South Bend
South Bend, Indiana