Find the answer to your Linux question:
Results 1 to 9 of 9
I am trying to create a tar ball for some directory (say; abc). However, while tyring to redo the operation multiple times, the tar file (.tgz) generated is of different ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2006
    Posts
    36

    tar ball file size is different


    I am trying to create a tar ball for some directory (say; abc). However, while tyring to redo the operation multiple times, the tar file (.tgz) generated is of different size. The contents are exactly same. The distro is same.

    For Example:
    # tar czvif abc.tgz abc
    # ls -ltr abc.tgz
    -rw-r--r-- 1 root root 7707122 Jan 31 09:02 abc.tgz
    And from some other directory.
    # tar czvif abc.tgz abc
    # ls -ltr abc.tgz
    -rw-r--r-- 1 root root 7707129 Jan 31 09:02 abc.tgz

    WHY the byte size difference ? Any solution, or help ?

  2. #2
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    If I understand you correctly, it is because the way you are tarring the file, the absolute pathname is being stored. This will cause a difference in tar ball size depending on where you do the tarring from.

  3. #3
    Just Joined!
    Join Date
    Nov 2006
    Posts
    36
    My absolute path name is same : /data/temp/
    Any other paramter on which this might be dependent ?

  4. #4
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    If the file contents are the same, then it is most definitely because of the path. Simple tests can show you this.

  5. #5
    Just Joined!
    Join Date
    Nov 2006
    Posts
    36
    1. cd /data
    2 mkdir abc
    3 cd abc
    4 touch abc.txt
    5 cd ..
    6 tar czvif abc.tgz abc
    7 ls -ltr
    OUTPUT : -rw-r--r-- 1 root root 141 Sep 30 19:45 abc.tgz
    8 rm -rf abc*
    9 mkdir abc
    10 cd abc
    11 touch abc.txt
    12 cd ..
    13 tar czvif abc.tgz abc
    14 ls -ltr
    OUTPUT : -rw-r--r-- 1 root root 142 Sep 30 19:47 abc.tgz

  6. #6
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    Fragmentation possibly? Can I ask why this is bothering you so much?

  7. #7
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris
    Posts
    1,283
    Hi.

    I ran a set commands based on those from your post, and I got identical lengths.

    Is this a current test? It looks like the output is quite old -- Sep 30 ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  8. #8
    Just Joined!
    Join Date
    Nov 2006
    Posts
    36
    Well. Lets not worry about dates. That was my system date as set to something Sep...
    Why I want to do this ?
    -- I would like to distribute some software on a flash drive. While my scripts perform copy and tar (compression / extraction) the size of the files created on flash drive is different. This poses a problem indicating that if file sizes are different then the software may be different.
    Moreover, I think there must be a way out (which I do'nt know) to get an exact copy (memory wise). So if the file sizes are different then the md5sum's would also differ. I think I am looking out for correct OPTION for:
    (1) #cp OPTION
    (2) #tar OPTION while compression / extraction.

  9. #9
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris
    Posts
    1,283
    Hi, bvinay.

    I'd guess that the flash drive uses a filesystem different from your hard drive. If that's correct, then there likely is a difference.

    I recommend that you think in terms of using the flash drive only as a carrier, that you create the tar files on your hard disk, copy them to the flash drive, and provide instructions to your users to copy from the flash drive to a hard drive before extraction with tar ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •