share
Unix & LinuxWhy does the PIGZ produce a different md5sum
[0] [1] alper
[2020-04-17 12:47:36]
[ files tar hashsum ]
[ https://unix.stackexchange.com/questions/580685/why-does-the-pigz-produce-a-different-md5sum ]

I observe that when I use PIGZ version, generated tar file's md5sum hash is different than the next one generated.

Instead of PIGZ=-n if I use GZIP=-n generated hashes are same. I have followed following answer for Tar produces different files each time [1].

$ find sourceCode -print0 | LC_ALL=C sort -z | PIGZ=-n tar \
--mode=a+rwX --owner=0  --group=0 --absolute-names --no-recursion --null -T - -zcvf file.tar.gz
$ md5sum file.tar.gz # some hash is generated

# When I apply the same operation above output for md5sum file.tar.gz is different

=> Is this a normal case? or is it possible to have same behavior for PIGZ like GZIP?

[+3] [2020-04-17 13:03:51] Stephen Kitt [ACCEPTED]

If you want tar to use pigz, you need to ask it to do so:

... | PIGZ=-n tar -Ipigz --mode=a+rwX --owner=0  --group=0 --absolute-names --no-recursion --null -T - -cvf file.tar.gz

With the -Ipigz option, and without -z, tar uses pigz and the PIGZ variable is taken into account. This results in tarballs with the same contents as gzip-compressed archives with GZIP=-n.


Also is it neccesary for me to use --mode=a+rwX --owner=0 --group=0 --absolute-names parametes in addition to your answer on tar produces different files each time. - alper
(1) That’s a somewhat different question; the answer depends on what variability you want to allow. You need to set the owner/group if you want to allow different users to build your tarball and still produce the same tarball. - Stephen Kitt
When I add a character and remove a character from the file I am tarring, even the data's hash is same, its zipped hash differs. I am not sure what may be the real cause of it or is it a normal behavior. Please see as a new question: unix.stackexchange.com/questions/630736/… - alper
1