解決策 1:
export BZIP=--fast
tar cjf foo.tar.bz2 foo
または tar の出力をパイプします bzip2まで .
ただし、bzip2 の man ページから注意する必要があります:
-1 (or --fast) to -9 (or --best)
Set the block size to 100 k, 200 k .. 900 k when compressing.
Has no effect when decompressing. See MEMORY MANAGEMENT below.
The --fast and --best aliases are primarily for GNU gzip compat-
ibility. In particular, --fast doesn't make things signifi-
cantly faster. And --best merely selects the default behaviour.
解決策 2:
tar -cjf dir.tar.bz2 --options bzip2:compression-level=9 path/to/dir/
解決策 3:
bzip2 ブロックサイズ
bzip2 いくつかのブロック サイズ オプションがあります。マニュアルページ bzip2(1) から :
-1 (or --fast) to -9 (or --best)
Set the block size to 100 k, 200 k .. 900 k when compressing.
Has no effect when decompressing. See MEMORY MANAGEMENT below.
The --fast and --best aliases are primarily for GNU gzip
compatibility. In particular, --fast doesn't make things
significantly faster. And --best merely selects the default
behaviour.
bzip2 を使用して、圧縮率に関係なく、より高速な圧縮が必要な場合 、 -1 が必要なようです (または --fast ) オプション。
設定 bzip2 tar 使用時のブロックサイズ
bzip2 を設定できます tar 使用時のブロックサイズ いくつかの方法で。
UNLX のやり方
私のお気に入りの方法である UNlX の方法は、すべてのツールを個別に使用し、それらをパイプで組み合わせる方法です。
$ tar --create [FILE...] | bzip2 -1 > [ARCHIVE].tar.bz2
これは、「tar で .tar を作成する」と読むことができます -> bzip2 で bzip します -> [ARCHIVE].tar.bz2 に書き込みます ".
環境変数
bzip2 を設定することも可能です 環境変数 BZIP2 によるオプション .マニュアルページ bzip2(1) から :
bzip2 will read arguments from the environment variables BZIP2 and BZIP,
in that order, and will process them before any arguments read from the
command line. This gives a convenient way to supply default arguments.
tar でそれを使用するには 、たとえば次のようにできます:
$ BZIP2=-1 tar --create --bzip2 --file [ARCHIVE].tar.bz2 [FILE...]
より速い代替手段
bzip2 低速圧縮アルゴリズムを使用します。速度が気になる場合は、gzip で使用されているような代替アルゴリズムを調査できます。 または lzop .圧縮ツールを比較した素晴らしい記事は次のとおりです:https://aliver.wordpress.com/2010/06/22/huge-unix-file-compresser-shootout-with-tons-of-datagraphs/