Tar error: Unexpected EOF in archive

Cyrille picture Cyrille · Aug 25, 2009 · Viewed 101.4k times · Source

I tar a directory full of JPEG images:

tar cvfz myarchive.tar.gz mydirectory

When I untar the archive:

tar xvfz myarchive.tar.gz

I get an error:

tar: Unexpected EOF in archive

Looking at the output, it fails in the middle of one particular JPEG image.

What am I doing wrong?

Answer

paxdiablo picture paxdiablo · Aug 25, 2009

Interesting. I have a few questions which may point out the problem.

1/ Are you untarring on the same platform as you're tarring on? They may be different versions of tar (e.g., GNU and old-unix)? If they're different, can you untar on the same box you tarred on?

2/ What happens when you simply gunzip myarchive.tar.gz? Does that work? Maybe your file is being corrupted/truncated. I'm assuming you would notice if the compression generated errors, yes?

Based on the GNU tar source, it will only print that message if find_next_block() returns 0 prematurely which is usually caused by truncated archive.