A star archive has no index and no count of members, so its end is marked in the stream itself: two blocks of zeros where the next header would be. Everything in the archive is a whole number of 512-byte blocks.
Padding file data
A member’s data starts in the block after its header, or after its pax records’
blocks or sparse extension blocks, and fills as many blocks as it needs. The last block
is padded with zeros, so a member of n bytes takes n rounded up to
the next multiple of 512. A reader finds the next header by rounding up
t_size: the next header is at the header’s offset + 512 +
((n + 511) & ~511).
The two zero blocks
After the last member come two blocks of 512 zero bytes, as POSIX asks. A reader stops at the first block that is all zeros, since a real header never is: its checksum would fail. A lone zero block, or one followed by a block that is not zero, is a sign of damage; GNU tar warns about it, and the explorer reports it.
Records and the blocking factor
Tape drives work best with large writes, so tar writes its blocks in groups called records, and the number of blocks in a record is the blocking factor. libarchive’s tar(5) says early implementations wrote 10,240 bytes, 20 blocks, at a time, and that this is “still the default for most implementations”. POSIX says “the last physical block is always full size”, so a writer that keeps to it fills the last record after the two zero blocks; the bytes there “may contain undefined data”. Which blocking factor star uses by default has not been confirmed for this page.
The explorer shows zeros after the end blocks as record padding, and says when the file is a whole number of 10,240-byte records.
Appending and joining
To add members to an archive, tar overwrites the two zero blocks with the new headers
and writes new zero blocks after them. Joining two archives with a plain file copy
leaves the first archive’s zero blocks in the middle, so most readers stop there; GNU
tar’s --ignore-zeros reads past them. The explorer shows a tar header found
after the end of the archive as a further archive.
A compressed tar file such as .tar.gz compresses the whole stream,
padding and end blocks included. Runs of zeros compress to almost nothing, so the
padding costs very little.