After writing two tar archives to a tape:$ mt -f /dev/st0 rewind$ tar cvf /dev/nst0 first$ tar cvf /dev/nst0 secondWhy do I need to read from the tape three times to read the two archives?$ mt -f /dev/st0 rewind$ mt -f /dev/nst0 statusSCSI 2 tape drive:File number=0, block number=0, partition=0.Tape block size 0 bytes. Density code 0x44 (LTO-3).Soft error count since last status=0General status bits on (41010000): BOT ONLINE IM_REP_EN$ tar tvf /dev/nst0drwxrwxr-x oskar/oskar       0 2017-03-23 11:35 first/$ mt -f /dev/nst0 statusSCSI 2 tape drive:File number=0, block number=10, partition=0.Tape block size 0 bytes. Density code 0x44 (LTO-3).Soft error count since last status=0General status bits on (1010000): ONLINE IM_REP_EN$ tar tvf /dev/nst0tar: This does not look like a tar archivetar: Exiting with failure status due to previous errors$ mt -f /dev/nst0 statusSCSI 2 tape drive:File number=1, block number=0, partition=0.Tape block size 0 bytes. Density code 0x44 (LTO-3).Soft error count since last status=0General status bits on (81010000): EOF ONLINE IM_REP_EN$ tar tvf /dev/nst0drwxrwxr-x oskar/oskar       0 2017-03-23 11:37 second/$ mt -f /dev/nst0 statusSCSI 2 tape drive:File number=1, block number=3, partition=0.Tape block size 0 bytes. Density code 0x44 (LTO-3).Soft error count since last status=0General status bits on (1010000): ONLINE IM_REP_EN
Why do I need to read from a tape 3 times to read 2 archives?
tar;io;storage;archive;tape
At the end of the first tar tvf, the tape is left on the last block of the first file. The second tar tvf reads that again, and complains, but doing that leaves the tape on the first block of the second file so the third tar tvf works.When working with multiple files on tape you should really use mt to move between the files before running tar:mt -f /dev/st0 rewindtar tvf /dev/nst0mt -f /dev/nst0 fsf 1tar tvf /dev/nst0