4

I have an issue with a tarball created on a SuSe 10.3 Server version.

The .tar file has a size of 6.5 GB but if I untar it under Ubuntu 9.10 the resulting folder only has a size of 1.5 GB.

commands used: tar cvf for packing, tar xvf for unpacking.

Perhaps somebody knows how this can be fixed, would be great.

Cheers.

Froggiz
  • 3,043
  • 1
  • 19
  • 30

4 Answers4

2

if you have symlinks or hardlinks in the directory, then tar might be adding each one as a seperate file. When you then decompress it on a linux filesystem, it would reinstate the links and then everything would take up less space.

Tar is not for compression, just for creating a file containing multiple files. That is why you usually find it piped through gzip or bzip.

BuildTheRobots
  • 842
  • 5
  • 11
  • 1
    There are versions of tar out there that will do compression and decompression, but "cvf" and "xvf" aren't going to trigger that, in any version I know of. – David Thornley Jan 30 '10 at 15:54
  • some versions of tar (gnu tar does, irrc) have wrappers to decompress bzip/gzip etc... compressed tar files, but I was under the impression that they relied on the native libs from the compression schema. – BuildTheRobots Feb 01 '10 at 03:18
0

you may have better results with cpio , it's much more suited for larger backups and can be scripted to handle sym links and special files correctly.

The Unix Janitor
  • 2,458
  • 15
  • 13
0

If you have lots of small files then you may run into blocking and directory overhead in tar. The important information is how large was the source directory. tar may have compressed empty space in files by not allocating blocks for them. Try the --apparent-size option to du.

You could try comparing the list of files generated by tar -tf to the files extracted. Extract with tar -xf to see if you are getting any errors on extract. Try recreating a copy of the tar to see how large it is.

BillThor
  • 27,737
  • 3
  • 37
  • 69
0

I'd suggest trying pax. At least, this is how it's called in CentOS. IIRC, it can handle corrupted TAR files by skipping the invalid tar members. Otherwise I suggest you experiment with the tarfile module of the Python standard library and do this programmatically. I had done something like that a few years ago.

Born To Ride
  • 1,084
  • 6
  • 10