Parallel gzip and bzip2
November 9, 2011
It’s great to see parallel versions of core system utilities like gzip and bzip2 popping up. In particular, pigz (pronounced pig-zee) is a drop-in replacement for gzip and lbzip2 and pbzip2 are drop-in replacements for bzip2.
An easy way to use them by default in Linux without messing with the
/bin
tree is to create symbolic links in /usr/local/bin
as
follows:
ln -s /usr/bin/lbzip2 /usr/local/bin/bzip2
ln -s /usr/bin/lbzip2 /usr/local/bin/bunzip2
ln -s /usr/bin/lbzip2 /usr/local/bin/bzcat
ln -s /usr/bin/pigz /usr/local/bin/gzip
ln -s /usr/bin/pigz /usr/local/bin/gunzip
ln -s /usr/bin/pigz /usr/local/bin/zcat
As for Debian-Linux-specific instructions, there are packages for all three of these tools:
sudo apt-get install pigz lbzip2 pbzip2
Clearly, these should be made to work with the Debian alternatives system, but that hasn’t happened yet. So, for now it seems the symbolic links above are probably the best bet.
Update 2012–01–27: Laszlo Ersek pointed out that there is a simple
way to use symlinks in /usr/bin
, where many other scripts and
programs will expect gzip
and bzip2
to live, without causing
problems with the Debian package manager. Specifically, bzip-divert
can be used, for example, to relocate /bin/bzip2
to
/bin/bzip2.distrib
. Then the /bin/bzip2
symlink will be left
untouched during upgrades, during which the relocated binary will be
updated instead. For more details, Debian Administration has a useful
article called “Replacing binaries with dpkg-divert”.