some common errors in tar

by gowtham 2010-02-03 12:57:09

Lets take a look at some common error examples. As described previously, specifying incorrect filter type, f.e. using the following commands

tar xjf dir.tar # ©2007 linux.dsplabs.com.au
tar xzf dir.tar.bz2 # ©2007 linux.dsplabs.com.au

results in the respective errors messages shown below.

bzip2: (stdin) is not a bzip2 file.
tar: Child returned status 2
tar: Error exit delayed from previous errors

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error exit delayed from previous errors

Also, if a file becomes damaged, say truncated, then obviously an error will occur. Lets simulate such a corruption. Lets keep only the initial 100 bytes of the dir.tar.bz2 archive by using the following command.

head -c100 dir.tar.bz2 > corrup.tar.bz2 # ©2007 linux.dsplabs.com.au

If we now try to extract this archive,

tar xjf corrupt.tar.bz2 # ©2007 linux.dsplabs.com.au

then the following error message will be produced.

bzip2: Compressed file ends unexpectedly;
perhaps it is corrupted? *Possible* reason follows.
bzip2: Inappropriate ioctl for device
Input file = (stdin), output file = (stdout)

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

tar: Child returned status 2
tar: Error exit delayed from previous errors

Interestingly, we are told to check archives integrity, so lets do that.

bzip2 -tvv corrupt.tar.bz2 # ©2007 linux.dsplabs.com.au

The bzip2 utility tells us what we already know⦠we are missing part of the file.

corrupt.tar.bz2: [1: huff+mtf file ends unexpectedly

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

Lets try the second suggestion, the bzip2recover utility.

bzip2recover corrupt.tar.bz2 # ©2007 linux.dsplabs.com.au

Unfortunately, with only 100 bytes it is not possible to recover anything from the corrupted archive.

bzip2recover 1.0.3: extracts blocks from damaged .bz2 files.
bzip2recover: searching for block boundaries ...
block 1 runs from 80 to 800 (incomplete)
bzip2recover: sorry, I couldn't find any block boundaries.

Similarly, if we truncate the gzip archvie, then gzip will inform us of unexpected end of file.

gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error exit delayed from previous errors

On the other hand, truncating a tar archive does not cause error messages during extraction process. Obviously, only the files still fully contained (an not truncated/corrupted) in such an archive will be extracted. Such tuncation/corruption errors often occur when extracting archives downloaded from the Internet.

Tagged in:

3525
like
0
dislike
0
mail
flag

You must LOGIN to add comments