How do I write sequentially several tar's to a tape?

The behavior is related to the EOF handling of the tape driver.

This handling differs between operating systems and it may help to read the related Solaris man page:

http://schillix.sourceforge.net/man/man7i/mtio.7i.html

that explains a difference between the Solaris handling and the old BSD behavior.

From this explanation, I would expect the old BSD behavior to cause a read after an EOF situation to skip the file mark and to return the first record from the next file on tape. This seems to be what you expect.

It seems that the observed behavior on BSD is between the documented SVr4 behavior and the old BSD behavior, but I guess that there is a way to make things work on both Solaris and current BSD:

  • call tar to read the first tape file

  • after that, the tape is positioned at the end of the first tape file, which is just before the file mark...

  • call mt fsf to skip the file mark

  • call tar to read the next file on tape.

From the rest of the discussion, it seems that FreeBSD writes an additional filemark, when mt rewind is called after a write operation has been applied.

The command mt eom will position the tape after the final double filemark and when another write operation takes place, this happens after the double filemark resultng in an empty tape file before that final write.

A tape with three files looks this way:

data1 FILEMARK data2 FILEMARK data3 FILEMARK FILEMARK

If you like to append a fourth tape file, you need to call:

mt fsf 3

to position the tape after the thirf filemark. If you then start writing, this overwrites the fourth filemark and if you then rewind again, you have this tape layout:

data1 FILEMARK data2 FILEMARK data3 FILEMARK data4 FILEMARK FILEMARK