Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I used "Compress" from Nautilus to a 36MB folder. It created a tar called fs.tar.gz.

This fs.tar.gz has the size of 98MB.

How can this be possible?

I did read somewhere that symlinks or something similar can cause this - I do have symlinks in my folder.

share|improve this question
add comment

1 Answer

A tar file has overhead because it also includes information on how to recreate the files. If the content you added to the tar file itself is already compressed you can end up with a bigger file than all the Mibs of all the files together. But... we are talking about small amounts of overhead. Not like 2 times the size of all the files. This indeed smells like symlinks.

You can use tar -tvf fs.tar.gz | more to have a look for files that got included but where not 'suppose' to be there. If both symlink and file are in the directories you use to create the tar file you will end up with both files included.

  • Tar has an option for not archiving symlinks; from the man page:

    -h, --dereference
    don't archive symlinks; archive the files they point to
    

    Do be careful when messing with symlinks: you might up ending with broken ones that you need to fix yourself.

  • Tar allows for excluding files either with the `--exclude {PATTERN} or --exclude_from {FILE}. This lets you include the symlink and from that the file and skip the file itself.

  • To only include files and not the symlink you can use find /dir1 -type f |tar {etc}

share|improve this answer
    
The -h option would include the file the symlink points to, which would be much larger than the symlink itself, and seems to be what happened here, so wold not solve the problem. A symlink is very small, and generally will only take a few bytes of space in a tar file, not several MiB. Also, for using find, you probably don't want to use /dir (full path), but use the relative path instead, such as find dir1 while in dir1's containing directory. –  dobey Nov 25 '12 at 15:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.