64

Is there anyway to extract a tar.gz file faster than tar -zxvf filenamehere?

We have large files, and trying to optimize the operation.

David Houde
  • 3,240
Justin
  • 5,668

4 Answers4

85

pigz is a parallel version of gzip. Although it only uses a single thread for decompression, it starts 3 additional threads for reading, writing, and check calculation. Your results may vary but we have seen significant improvement in decompression of some of our datasets. Once you install pigz, the tar file can be extracted with:

pigz -dc target.tar.gz | tar xf -
TimS
  • 2,206
17

if there are many many many small files in the tar ball, cancel the ā€˜v’ parameter, try again!

anonymous
  • 187
17

If you want to see progress use something like pv. Here is an Example:

pigz -dc mysql-binary-backup.tar.gz | pv | tar xf -
Tim Hughes
  • 373
  • 3
  • 10
1

With pigz you can speed up extraction and with pv you can view the progress of the extraction. Storing the output of pv to a file allows you to run your command in the background and view the progress at any time.

pigz -dc mysql-binary-backup.tar.gz | pv --force 2> progress.txt | tar xf - &

pv typically will not output a visual display if stderr is not a terminal. --force ensures that pv is forced to do so. Then we simply redirect stderr using 2> to progress.txt and pipe the stdout to the tar command. & at the end will run the command in the background.

You can see the progress of the extraction by simply running tail -f progress.txt