I have a tar file that I have recreated from two files - xaa, xab (the results of using the split command). The tar file is the size I expect it to be but when I extract it the folder I get is a fraction of the size of the tar file. See the terminal output below for the sequence of my commands. Unfortunately I don't have the orignal tar file or folder - so this is my only chance to recover this data. When I open the archive in the 'File Roller' I see the same folders as I do on the command line after extraction and these are only a subset of the files I'd expect to see. Can anyone suggest why this might be?

~> cat xa* > archive
~> file archive
archive: POSIX tar archive (GNU)
~> ls -la archive
-rw-r--r-- 1 hugo users 24471439360 Jun  1 18:50 archive
~> tar xf archive
~> cd repos
~/repos> du --max-depth 0 -h
83M .
~/repos> cd ../
~> tar cf newarchive repos
~> ls -la newarchive
-rw-r--r-- 1 hugo users 53288960 Jun  1 19:57 newarchive
  • 3
    What about tar tvvf archive | awk '{s+=$3}; END{print s}'? Are you sure everything is in repos. No dot file or dot dir like .git or .svn? tar tvvf archive | less to see where the space is. – Stéphane Chazelas Jun 1 '13 at 20:12
  • There are no other folders other than repos. The awk command gives: ~> tar tvvf archive | awk '{s+=$3}; END{print s}' 29084601 – user1753106 Jun 2 '13 at 13:10

The tar file is extracted until it finds the marker indicating the end of tar file: Physically, an archive consists of a series of file entries terminated by an end-of-archive entry, which consists of two 512 blocks of zero bytes from the tar file format description here.

So your archive file probably has material after the marker that does not get extracted.

  • 1
    Aha, yes it looks like that tar was seeing an end-of-archive that wasn't the real end-of-archive. Using the i flag to tar seems to be the solution - it ignores end-of-archive delimiters and processes the whole file. – user1753106 Jun 2 '13 at 13:30

It sounds like the disk to which you are extracting doesn't have enough free space for all of the files and directories in the tar archive. Check with df -k . in the directory in which you extracted the files.

Sometimes if you tar up files with "holes" in them, you will get a tar archive file much bigger than the original file(s). Also, a tar archive file carries metadata, file name, permissions, ownership, etc, as well as the file(s) data. So a tar archive is invariably at least a little bigger than the original files.

  • 1
    If the disk were full, you would get an error saying so. – psusi Jun 2 '13 at 3:43

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.