1

After writing two tar archives to a tape:

$ mt -f /dev/st0 rewind
$ tar cvf /dev/nst0 first
$ tar cvf /dev/nst0 second

Why do I need to read from the tape three times to read the two archives?

$ mt -f /dev/st0 rewind

$ mt -f /dev/nst0 status
SCSI 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=0
General status bits on (41010000):
 BOT ONLINE IM_REP_EN

$ tar tvf /dev/nst0
drwxrwxr-x oskar/oskar       0 2017-03-23 11:35 first/

$ mt -f /dev/nst0 status
SCSI 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=0
General status bits on (1010000):
 ONLINE IM_REP_EN

$ tar tvf /dev/nst0
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors

$ mt -f /dev/nst0 status
SCSI 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=0
General status bits on (81010000):
 EOF ONLINE IM_REP_EN

$ tar tvf /dev/nst0
drwxrwxr-x oskar/oskar       0 2017-03-23 11:37 second/

$ mt -f /dev/nst0 status
SCSI 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=0
General status bits on (1010000):
 ONLINE IM_REP_EN
  • I only have a work-around not a solution: After first read then manually skip to next 'file' mt -f /dev/nst0 fsf 1 – hschou Mar 24 '17 at 9:16
  • At the 2nd mt -f /dev/nst0 status it is still at the end of the first file. – MikeD Mar 24 '17 at 9:30
  • @MikeD I don't have a tape drive right here and can not test it. But as I remember I have done exactly as Oskar did: just wrte several times to a drive and the read several times without the use mt fsf 1. – hschou Mar 24 '17 at 10:06
3

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 rewind
tar tvf /dev/nst0
mt -f /dev/nst0 fsf 1
tar tvf /dev/nst0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.