Decompress bz2 File in (Linux unix ubuntu Mac)

bzip2 is mono-threaded, which means it will take a long time to decompress a large file.

To decompress a .bz2 file multithreaded, you can use the free, open-source program lbzip2:

sudo apt-get install lbzip2lbzip2 -d file_name.bz2

-d indicates you wish to decompress the file. It would automatically determine how many threads it will use. To specify the exact number of threads you want to use, use the -n parameter, e.g.:

lbzip2 -d -n 32 file_name.bz2

A few more useful commands with lbzip2:

To compress a folder:

tar -c -I lbzip2 -f file_name.tar.bz2 folder_name

To uncompress a folder:

 tar -I lbzip2 -xvf file_name.tar.bz2

Parameters:

-I, --use-compress-program PROG      filter through PROG (must accept -d)-x, --extract, --get      extract files from an archive-v, --verbose      verbosely list files processed-f, --file ARCHIVE      use archive file or device ARCHIVE

Some alternatives to decompress a .bz2 file multithreaded:

pbzip2:

sudo apt-get install pbzip2pbzip2 -d my_file.bz2

mpibzip2: designed to be used on cluster machines.


If you need some large .bz2 files to experiment with: https://dumps.wikimedia.org/mirrors.html

For example (a 14 GB .bz2 file, 200 GB uncompressed):

wget http://dumps.wikimedia.your.org/wikidatawiki/20170120/wikidatawiki-20170120-pages-articles-multistream.xml.bz2 lbzip2 -d -n 32 wikidatawiki-20170120-pages-articles-multistream.xml.bz2