How to Fix ‘tar: Error is not recoverable: exiting now’ in Linux

Extracting, creating, or inspecting tarball archives on Linux using the standard tar command only to see the fatal error message: “tar: Error is not recoverable: exiting now” halts backup workflows, software builds, and server migrations. Often preceded by secondary warnings such as tar: Child returned status 2, tar: Unexpected EOF in archive, or gzip: stdin: not in gzip format, this error indicates that the archive stream cannot be processed. In Linux, tar (Tape Archive) bundles files into a sequential byte stream, commonly combined with compression filters like gzip (-z), bzip2 (-j), or xz (-J). When compression flags do not match the underlying file format, downloads terminate prematurely leaving truncated archives, or block sizes mismatch, tar terminates with an unrecoverable error. This guide explains how to identify the true archive type and recover your files.

What Causes the Unrecoverable Error in tar?

Archive extraction requires matching decompression algorithms and intact byte sequences. Primary causes include:

  • Compression Flag Mismatch: Passing the wrong flag (e.g. using -z for a file compressed with xz or bzip2, or attempting to decompress a plain uncompressed tarball).
  • Truncated or Incomplete Downloads: Network interruptions during curl, wget, or scp transfers resulting in missing end-of-file (EOF) blocks.
  • Leading Dash in Filenames: Filenames beginning with a hyphen (-) causing tar to interpret the filename as a command-line argument.
  • Full Target Disk or Filesystem Quota: Running out of free space on the destination drive while extraction is in progress.
  • Corrupted Magic Bytes or Headers: File corruption overwriting the standard ustar archive header or gzip magic numbers (0x1f 0x8b).

Step 1: Identify the True Archive Compression Format Using file

Relying solely on file extensions (like .tar.gz or .tgz) can be misleading, as misnamed files cause decompression filters to crash.

  1. Open your terminal and run the file command on your archive:
    file archive_name.tar.gz
  2. Inspect the reported MIME output:
    • gzip compressed data: Requires the -z flag (or tar -xzf).
    • bzip2 compressed data: Requires the -j flag (or tar -xjf).
    • XZ compressed data: Requires the -J flag (or tar -xJf).
    • POSIX tar archive: The file is completely uncompressed! Passing -z will cause not in gzip format. Use tar -xf without compression flags.
    • HTML document or ASCII text: Indicates a failed download where a web server returned a 404 error page instead of the actual archive file.

Step 2: Use the Universal Auto-Detection Flag in Modern GNU tar

Modern versions of GNU tar can automatically detect and decompress gzip, bzip2, xz, and zstd formats without specifying manual filter flags.

  1. Omit specific compression flags (do not include z, j, or J):
    tar -xvf archive_name.tar.gz
  2. The -x flag instructs tar to extract, -v enables verbose output, and -f specifies the file. GNU tar reads the header magic bytes and automatically invokes the appropriate decompression tool.

Step 3: Extract Corrupted or Truncated Archives with –ignore-zeros

If an archive was partially corrupted by an unexpected shutdown or network drop, tar normally exits upon encountering premature null blocks.

  1. If extracting an uncompressed tar archive with null blocks:
    tar -xvf archive_name.tar -i

    (The -i or --ignore-zeros flag instructs tar to ignore blocks of zeros and continue extracting subsequent valid files).

  2. If the archive is compressed with gzip and corrupted near the end:
    gzip -dc archive_name.tar.gz | tar -xvf - -i
  3. This pipeline decompresses the available stream and extracts all undamaged files up to the point of corruption.

Step 4: Handle Filenames Beginning with a Hyphen (-)

If a filename starts with a dash (e.g. -backup.tar.gz), tar interprets the filename as an option, producing unexpected argument errors.

  1. Use the double hyphen (--) delimiter to signal the end of command-line flags:
    tar -xvf -- -backup.tar.gz
  2. Alternatively, specify the explicit relative directory path:
    tar -xvf ./-backup.tar.gz

Step 5: Verify Destination Disk Space and Inode Availability

Extraction terminates immediately with an unrecoverable exit code if the target filesystem runs out of blocks or inodes.

  1. Check free disk capacity across mounted filesystems:
    df -h .
  2. Check inode capacity (extracting millions of small files can exhaust inodes before disk storage is full):
    df -i .
  3. If capacity is near 100%, delete unnecessary files or extract the archive to an alternative mount point using the -C flag:
    tar -xvf archive_name.tar.gz -C /mnt/storage/extracted_files/

tar Unrecoverable Error Troubleshooting Summary

Reported Warning Primary Root Cause Corrective Command
gzip: stdin: not in gzip format Plain uncompressed tarball or wrong format Run file <archive> & extract with tar -xvf
Unexpected EOF in archive Truncated or incomplete download Re-download file or use --ignore-zeros
Child returned status 2 Decompressor helper tool failed Install missing tool (e.g. sudo apt install xz-utils)
No space left on device Storage blocks or inodes exhausted Check df -h and extract to larger mount point

Identifying the true compression encoding and using fault-tolerant extraction flags ensures maximum file recovery from problematic tar archives.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.