3

I have tar files where I archive about 250 files, each about 80 Mb, without compression. In a few cases tar is only returning some of the files. For example, when doing an extract of the file using:

tar -xvf 356.tar

I got only 103 files, when it should return 255 files, but tar does not give me an error. Furthermore, the tar archive is 15.8 Gb while the extracted folder is just 6.4 Gb. The tar files were created using

tar -cvf 356.tar 356

where 356 is the name of the folder.

All the steps where done in the same machines, under Ubuntu 6 and newer. Any ideas if there is a way to recover the files that are not being extracted?

6
  • 2
    A few questions that come to mind: are you extracting on a native linux filesystem (i.e. not FAT or NTFS)? Do the file names have anything special (very long, contain non-ASCII characters, etc.)? How many files does tar -tvf 356.tar list? Aug 3, 2010 at 18:20
  • Always linux native, ext3, and the filenames are normal characters, just alphanumeric and underscores. tar -tvf 356.tar lists 103 files. Aug 3, 2010 at 21:46
  • 1
    Do you get the same results with a different implementation of tar? There's at least pax (pax -v <356.tar to list files, pax -r -pp <356.tar to extract). Aug 3, 2010 at 22:00
  • 2
    I forgot the obvious... Do you have some way (e.g. checksums) to make sure the archive wasn't corrupted between the time it was created and the time you tried to extract it? Aug 3, 2010 at 22:48
  • 1
    Ah, pax on Linux doesn't properly support >2GB archives. Supposedly tar does; what version of tar do you have (tar --version), and on what architecture (x86, amd64, ...)? Aug 4, 2010 at 17:31

3 Answers 3

1

I know this is a bit obvious, but could any of the extracted files be hidden?

Have you tried just listing the contents of the tar prior to extraction?

1
  • 1
    Nop, regular ls and ls -a gives the same number of files. Listing gives me the same number of files as the ones extracted. What is weird is the size discrepancy. Aug 3, 2010 at 21:43
1

Which platform are you taring and where you are extracting. If you are taring in Linux and untaring in windows then you might find unusual behavior due to long filename. did you do a tar -tvf 365.tar against the ls -lR 365 and see if that matches.

tar -tvf 354.tar > 1.log
ls -lR 365 > 2.log
diff 1.log 2.log

does the above helpful.

0

Note that it is perfectly possible to ask tar (here: GNU tar 1.34 on Fedora 34) to add the same file several times:

$ tar cf xxx.tar np.txt np.txt np.txt np.txt
$ ls -l xxx.tar np.txt 
-rw-rw-r--. 1 vonbrand vonbrand     0 Aug 10 11:00 np.txt
-rw-rw-r--. 1 vonbrand vonbrand 10240 Aug 21 13:35 xxx.tar
$ tar tvf xxx.tar
-rw-rw-r-- vonbrand/vonbrand 0 2021-08-10 11:00 np.txt
hrw-rw-r-- vonbrand/vonbrand 0 2021-08-10 11:00 np.txt link to np.txt
hrw-rw-r-- vonbrand/vonbrand 0 2021-08-10 11:00 np.txt link to np.txt
hrw-rw-r-- vonbrand/vonbrand 0 2021-08-10 11:00 np.txt link to np.txt

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.