Skip to content

pigz | Cheatsheet

pigz, which stands for parallel implementation of gzip, is a fully functional replacement for gzip that exploits multiple processors and multiple cores to the hilt when compressing data. pigz was written by Mark Adler, and uses the zlib and pthread libraries.


Install app-arch/pigz

echo "net-dns/dnsmasq auth-dns conntrack dbus dhcp-tools dnssec script tftp" \ 
  > /etc/portage/package/use/dnsmasq
emerge --ask app-arch/pigz

Fast compress

tar -cf archive.tar.gz-I pigz /opt                                                        

Compress with best compression

tar cf - paths-to-archive|pigz -9 -p 32 > archive.tar.gz                      

Compress via pigz and tar

tar --use-compress-program="pigz --best --recursive" -cf archive.tar.gz' <folder>

Compress with tar and monitor process with pv

tar --use-compress-program="pigz --best --recursive | pv" -cf archive.tar.gz <folder>  

Compress a single file with 4 cpu cores

pigz -9 -k -p4 gentoo-linux.iso                                               

Another way to compress a tar archive via pigz

tar cf - /home/user/path|pigz > pictures.tar.gz

Decrompressing file

pigz -d gentoo-linux.iso

Fast decrompressing

tar -I pigz -xf /home/user/archive.tar.gz -C /tmp  

Decrompess without deleting file

pigz -f -d gentoo-linux.iso