Friday tip: Use pbzip2 or pigz for parallel compression and decompression

Today I’m starting new series: “Friday Tip”. (I hope) each Friday I will post short blog post with some tip about Raspberry Pi usage. Usually it will be some interesting command or configuration option.

First tip is about file compression for new Raspberry Pi 2 users.

On Linux systems bzip2 and gzip formats are very popular. bzip2 and gzip commands are designed to run only on one CPU but Pi2 has 4 cores!

pbzip2 and pigz for rescue

Fortunately there are two programs which can significantly speed up the process of compression and decompression. Both programs are modern implementations of this algorithms and can run on many cores.

gz format

For this format you can use pigz program. To install it on Rasbian just run:

Usage is the same as for gzip command:

During my tests pigz was about 2.5x faster than gz, but sometimes the speed was the same. A lot depends on compressed file.

bzip2 format

For this format you can use pbzip2 program. To install it on rasbian just run:

Usage is the same as for bzip2 command:

During my tests pbzip2 was about 2.4x faster than standard bzip2 command.

Next ArticleFriday tip: How to quickly serve files from any directory