Upgrade xz from 5.0.4 to 5.0.7 on the vendor branch
[dragonfly.git] / contrib / xz / src / xz / xz.1
1 '\" t
2 .\"
3 .\" Author: Lasse Collin
4 .\"
5 .\" This file has been put into the public domain.
6 .\" You can do whatever you want with this file.
7 .\"
8 .TH XZ 1 "2013-06-21" "Tukaani" "XZ Utils"
9 .
10 .SH NAME
11 xz, unxz, xzcat, lzma, unlzma, lzcat \- Compress or decompress .xz and .lzma files
12 .
13 .SH SYNOPSIS
14 .B xz
15 .RI [ option... ]
16 .RI [ file... ]
17 .
18 .SH COMMAND ALIASES
19 .B unxz
20 is equivalent to
21 .BR "xz \-\-decompress" .
22 .br
23 .B xzcat
24 is equivalent to
25 .BR "xz \-\-decompress \-\-stdout" .
26 .br
27 .B lzma
28 is equivalent to
29 .BR "xz \-\-format=lzma" .
30 .br
31 .B unlzma
32 is equivalent to
33 .BR "xz \-\-format=lzma \-\-decompress" .
34 .br
35 .B lzcat
36 is equivalent to
37 .BR "xz \-\-format=lzma \-\-decompress \-\-stdout" .
38 .PP
39 When writing scripts that need to decompress files,
40 it is recommended to always use the name
41 .B xz
42 with appropriate arguments
43 .RB ( "xz \-d"
44 or
45 .BR "xz \-dc" )
46 instead of the names
47 .B unxz
48 and
49 .BR xzcat .
50 .
51 .SH DESCRIPTION
52 .B xz
53 is a general-purpose data compression tool with
54 command line syntax similar to
55 .BR gzip (1)
56 and
57 .BR bzip2 (1).
58 The native file format is the
59 .B .xz
60 format, but the legacy
61 .B .lzma
62 format used by LZMA Utils and
63 raw compressed streams with no container format headers
64 are also supported.
65 .PP
66 .B xz
67 compresses or decompresses each
68 .I file
69 according to the selected operation mode.
70 If no
71 .I files
72 are given or
73 .I file
74 is
75 .BR \- ,
76 .B xz
77 reads from standard input and writes the processed data
78 to standard output.
79 .B xz
80 will refuse (display an error and skip the
81 .IR file )
82 to write compressed data to standard output if it is a terminal.
83 Similarly,
84 .B xz
85 will refuse to read compressed data
86 from standard input if it is a terminal.
87 .PP
88 Unless
89 .B \-\-stdout
90 is specified,
91 .I files
92 other than
93 .B \-
94 are written to a new file whose name is derived from the source
95 .I file
96 name:
97 .IP \(bu 3
98 When compressing, the suffix of the target file format
99 .RB ( .xz
100 or
101 .BR .lzma )
102 is appended to the source filename to get the target filename.
103 .IP \(bu 3
104 When decompressing, the
105 .B .xz
106 or
107 .B .lzma
108 suffix is removed from the filename to get the target filename.
109 .B xz
110 also recognizes the suffixes
111 .B .txz
112 and
113 .BR .tlz ,
114 and replaces them with the
115 .B .tar
116 suffix.
117 .PP
118 If the target file already exists, an error is displayed and the
119 .I file
120 is skipped.
121 .PP
122 Unless writing to standard output,
123 .B xz
124 will display a warning and skip the
125 .I file
126 if any of the following applies:
127 .IP \(bu 3
128 .I File
129 is not a regular file.
130 Symbolic links are not followed,
131 and thus they are not considered to be regular files.
132 .IP \(bu 3
133 .I File
134 has more than one hard link.
135 .IP \(bu 3
136 .I File
137 has setuid, setgid, or sticky bit set.
138 .IP \(bu 3
139 The operation mode is set to compress and the
140 .I file
141 already has a suffix of the target file format
142 .RB ( .xz
143 or
144 .B .txz
145 when compressing to the
146 .B .xz
147 format, and
148 .B .lzma
149 or
150 .B .tlz
151 when compressing to the
152 .B .lzma
153 format).
154 .IP \(bu 3
155 The operation mode is set to decompress and the
156 .I file
157 doesn't have a suffix of any of the supported file formats
158 .RB ( .xz ,
159 .BR .txz ,
160 .BR .lzma ,
161 or
162 .BR .tlz ).
163 .PP
164 After successfully compressing or decompressing the
165 .IR file ,
166 .B xz
167 copies the owner, group, permissions, access time,
168 and modification time from the source
169 .I file
170 to the target file.
171 If copying the group fails, the permissions are modified
172 so that the target file doesn't become accessible to users
173 who didn't have permission to access the source
174 .IR file .
175 .B xz
176 doesn't support copying other metadata like access control lists
177 or extended attributes yet.
178 .PP
179 Once the target file has been successfully closed, the source
180 .I file
181 is removed unless
182 .B \-\-keep
183 was specified.
184 The source
185 .I file
186 is never removed if the output is written to standard output.
187 .PP
188 Sending
189 .B SIGINFO
190 or
191 .B SIGUSR1
192 to the
193 .B xz
194 process makes it print progress information to standard error.
195 This has only limited use since when standard error
196 is a terminal, using
197 .B \-\-verbose
198 will display an automatically updating progress indicator.
199 .
200 .SS "Memory usage"
201 The memory usage of
202 .B xz
203 varies from a few hundred kilobytes to several gigabytes
204 depending on the compression settings.
205 The settings used when compressing a file determine
206 the memory requirements of the decompressor.
207 Typically the decompressor needs 5\ % to 20\ % of
208 the amount of memory that the compressor needed when
209 creating the file.
210 For example, decompressing a file created with
211 .B xz \-9
212 currently requires 65\ MiB of memory.
213 Still, it is possible to have
214 .B .xz
215 files that require several gigabytes of memory to decompress.
216 .PP
217 Especially users of older systems may find
218 the possibility of very large memory usage annoying.
219 To prevent uncomfortable surprises,
220 .B xz
221 has a built-in memory usage limiter, which is disabled by default.
222 While some operating systems provide ways to limit
223 the memory usage of processes, relying on it
224 wasn't deemed to be flexible enough (e.g. using
225 .BR ulimit (1)
226 to limit virtual memory tends to cripple
227 .BR mmap (2)).
228 .PP
229 The memory usage limiter can be enabled with
230 the command line option \fB\-\-memlimit=\fIlimit\fR.
231 Often it is more convenient to enable the limiter
232 by default by setting the environment variable
233 .BR XZ_DEFAULTS ,
234 e.g.\&
235 .BR XZ_DEFAULTS=\-\-memlimit=150MiB .
236 It is possible to set the limits separately
237 for compression and decompression
238 by using \fB\-\-memlimit\-compress=\fIlimit\fR and
239 \fB\-\-memlimit\-decompress=\fIlimit\fR.
240 Using these two options outside
241 .B XZ_DEFAULTS
242 is rarely useful because a single run of
243 .B xz
244 cannot do both compression and decompression and
245 .BI \-\-memlimit= limit
246 (or \fB\-M\fR \fIlimit\fR)
247 is shorter to type on the command line.
248 .PP
249 If the specified memory usage limit is exceeded when decompressing,
250 .B xz
251 will display an error and decompressing the file will fail.
252 If the limit is exceeded when compressing,
253 .B xz
254 will try to scale the settings down so that the limit
255 is no longer exceeded (except when using \fB\-\-format=raw\fR
256 or \fB\-\-no\-adjust\fR).
257 This way the operation won't fail unless the limit is very small.
258 The scaling of the settings is done in steps that don't
259 match the compression level presets, e.g. if the limit is
260 only slightly less than the amount required for
261 .BR "xz \-9" ,
262 the settings will be scaled down only a little,
263 not all the way down to
264 .BR "xz \-8" .
265 .
266 .SS "Concatenation and padding with .xz files"
267 It is possible to concatenate
268 .B .xz
269 files as is.
270 .B xz
271 will decompress such files as if they were a single
272 .B .xz
273 file.
274 .PP
275 It is possible to insert padding between the concatenated parts
276 or after the last part.
277 The padding must consist of null bytes and the size
278 of the padding must be a multiple of four bytes.
279 This can be useful e.g. if the
280 .B .xz
281 file is stored on a medium that measures file sizes
282 in 512-byte blocks.
283 .PP
284 Concatenation and padding are not allowed with
285 .B .lzma
286 files or raw streams.
287 .
288 .SH OPTIONS
289 .
290 .SS "Integer suffixes and special values"
291 In most places where an integer argument is expected,
292 an optional suffix is supported to easily indicate large integers.
293 There must be no space between the integer and the suffix.
294 .TP
295 .B KiB
296 Multiply the integer by 1,024 (2^10).
297 .BR Ki ,
298 .BR k ,
299 .BR kB ,
300 .BR K ,
301 and
302 .B KB
303 are accepted as synonyms for
304 .BR KiB .
305 .TP
306 .B MiB
307 Multiply the integer by 1,048,576 (2^20).
308 .BR Mi ,
309 .BR m ,
310 .BR M ,
311 and
312 .B MB
313 are accepted as synonyms for
314 .BR MiB .
315 .TP
316 .B GiB
317 Multiply the integer by 1,073,741,824 (2^30).
318 .BR Gi ,
319 .BR g ,
320 .BR G ,
321 and
322 .B GB
323 are accepted as synonyms for
324 .BR GiB .
325 .PP
326 The special value
327 .B max
328 can be used to indicate the maximum integer value
329 supported by the option.
330 .
331 .SS "Operation mode"
332 If multiple operation mode options are given,
333 the last one takes effect.
334 .TP
335 .BR \-z ", " \-\-compress
336 Compress.
337 This is the default operation mode when no operation mode option
338 is specified and no other operation mode is implied from
339 the command name (for example,
340 .B unxz
341 implies
342 .BR \-\-decompress ).
343 .TP
344 .BR \-d ", " \-\-decompress ", " \-\-uncompress
345 Decompress.
346 .TP
347 .BR \-t ", " \-\-test
348 Test the integrity of compressed
349 .IR files .
350 This option is equivalent to
351 .B "\-\-decompress \-\-stdout"
352 except that the decompressed data is discarded instead of being
353 written to standard output.
354 No files are created or removed.
355 .TP
356 .BR \-l ", " \-\-list
357 Print information about compressed
358 .IR files .
359 No uncompressed output is produced,
360 and no files are created or removed.
361 In list mode, the program cannot read
362 the compressed data from standard
363 input or from other unseekable sources.
364 .IP ""
365 The default listing shows basic information about
366 .IR files ,
367 one file per line.
368 To get more detailed information, use also the
369 .B \-\-verbose
370 option.
371 For even more information, use
372 .B \-\-verbose
373 twice, but note that this may be slow, because getting all the extra
374 information requires many seeks.
375 The width of verbose output exceeds
376 80 characters, so piping the output to e.g.\&
377 .B "less\ \-S"
378 may be convenient if the terminal isn't wide enough.
379 .IP ""
380 The exact output may vary between
381 .B xz
382 versions and different locales.
383 For machine-readable output,
384 .B \-\-robot \-\-list
385 should be used.
386 .
387 .SS "Operation modifiers"
388 .TP
389 .BR \-k ", " \-\-keep
390 Don't delete the input files.
391 .TP
392 .BR \-f ", " \-\-force
393 This option has several effects:
394 .RS
395 .IP \(bu 3
396 If the target file already exists,
397 delete it before compressing or decompressing.
398 .IP \(bu 3
399 Compress or decompress even if the input is
400 a symbolic link to a regular file,
401 has more than one hard link,
402 or has the setuid, setgid, or sticky bit set.
403 The setuid, setgid, and sticky bits are not copied
404 to the target file.
405 .IP \(bu 3
406 When used with
407 .B \-\-decompress
408 .BR \-\-stdout
409 and
410 .B xz
411 cannot recognize the type of the source file,
412 copy the source file as is to standard output.
413 This allows
414 .B xzcat
415 .B \-\-force
416 to be used like
417 .BR cat (1)
418 for files that have not been compressed with
419 .BR xz .
420 Note that in future,
421 .B xz
422 might support new compressed file formats, which may make
423 .B xz
424 decompress more types of files instead of copying them as is to
425 standard output.
426 .BI \-\-format= format
427 can be used to restrict
428 .B xz
429 to decompress only a single file format.
430 .RE
431 .TP
432 .BR \-c ", " \-\-stdout ", " \-\-to\-stdout
433 Write the compressed or decompressed data to
434 standard output instead of a file.
435 This implies
436 .BR \-\-keep .
437 .TP
438 .B \-\-no\-sparse
439 Disable creation of sparse files.
440 By default, if decompressing into a regular file,
441 .B xz
442 tries to make the file sparse if the decompressed data contains
443 long sequences of binary zeros.
444 It also works when writing to standard output
445 as long as standard output is connected to a regular file
446 and certain additional conditions are met to make it safe.
447 Creating sparse files may save disk space and speed up
448 the decompression by reducing the amount of disk I/O.
449 .TP
450 \fB\-S\fR \fI.suf\fR, \fB\-\-suffix=\fI.suf
451 When compressing, use
452 .I .suf
453 as the suffix for the target file instead of
454 .B .xz
455 or
456 .BR .lzma .
457 If not writing to standard output and
458 the source file already has the suffix
459 .IR .suf ,
460 a warning is displayed and the file is skipped.
461 .IP ""
462 When decompressing, recognize files with the suffix
463 .I .suf
464 in addition to files with the
465 .BR .xz ,
466 .BR .txz ,
467 .BR .lzma ,
468 or
469 .B .tlz
470 suffix.
471 If the source file has the suffix
472 .IR .suf ,
473 the suffix is removed to get the target filename.
474 .IP ""
475 When compressing or decompressing raw streams
476 .RB ( \-\-format=raw ),
477 the suffix must always be specified unless
478 writing to standard output,
479 because there is no default suffix for raw streams.
480 .TP
481 \fB\-\-files\fR[\fB=\fIfile\fR]
482 Read the filenames to process from
483 .IR file ;
484 if
485 .I file
486 is omitted, filenames are read from standard input.
487 Filenames must be terminated with the newline character.
488 A dash
489 .RB ( \- )
490 is taken as a regular filename; it doesn't mean standard input.
491 If filenames are given also as command line arguments, they are
492 processed before the filenames read from
493 .IR file .
494 .TP
495 \fB\-\-files0\fR[\fB=\fIfile\fR]
496 This is identical to \fB\-\-files\fR[\fB=\fIfile\fR] except
497 that each filename must be terminated with the null character.
498 .
499 .SS "Basic file format and compression options"
500 .TP
501 \fB\-F\fR \fIformat\fR, \fB\-\-format=\fIformat
502 Specify the file
503 .I format
504 to compress or decompress:
505 .RS
506 .TP
507 .B auto
508 This is the default.
509 When compressing,
510 .B auto
511 is equivalent to
512 .BR xz .
513 When decompressing,
514 the format of the input file is automatically detected.
515 Note that raw streams (created with
516 .BR \-\-format=raw )
517 cannot be auto-detected.
518 .TP
519 .B xz
520 Compress to the
521 .B .xz
522 file format, or accept only
523 .B .xz
524 files when decompressing.
525 .TP
526 .BR lzma ", " alone
527 Compress to the legacy
528 .B .lzma
529 file format, or accept only
530 .B .lzma
531 files when decompressing.
532 The alternative name
533 .B alone
534 is provided for backwards compatibility with LZMA Utils.
535 .TP
536 .B raw
537 Compress or uncompress a raw stream (no headers).
538 This is meant for advanced users only.
539 To decode raw streams, you need use
540 .B \-\-format=raw
541 and explicitly specify the filter chain,
542 which normally would have been stored in the container headers.
543 .RE
544 .TP
545 \fB\-C\fR \fIcheck\fR, \fB\-\-check=\fIcheck
546 Specify the type of the integrity check.
547 The check is calculated from the uncompressed data and
548 stored in the
549 .B .xz
550 file.
551 This option has an effect only when compressing into the
552 .B .xz
553 format; the
554 .B .lzma
555 format doesn't support integrity checks.
556 The integrity check (if any) is verified when the
557 .B .xz
558 file is decompressed.
559 .IP ""
560 Supported
561 .I check
562 types:
563 .RS
564 .TP
565 .B none
566 Don't calculate an integrity check at all.
567 This is usually a bad idea.
568 This can be useful when integrity of the data is verified
569 by other means anyway.
570 .TP
571 .B crc32
572 Calculate CRC32 using the polynomial from IEEE-802.3 (Ethernet).
573 .TP
574 .B crc64
575 Calculate CRC64 using the polynomial from ECMA-182.
576 This is the default, since it is slightly better than CRC32
577 at detecting damaged files and the speed difference is negligible.
578 .TP
579 .B sha256
580 Calculate SHA-256.
581 This is somewhat slower than CRC32 and CRC64.
582 .RE
583 .IP ""
584 Integrity of the
585 .B .xz
586 headers is always verified with CRC32.
587 It is not possible to change or disable it.
588 .TP
589 .BR \-0 " ... " \-9
590 Select a compression preset level.
591 The default is
592 .BR \-6 .
593 If multiple preset levels are specified,
594 the last one takes effect.
595 If a custom filter chain was already specified, setting
596 a compression preset level clears the custom filter chain.
597 .IP ""
598 The differences between the presets are more significant than with
599 .BR gzip (1)
600 and
601 .BR bzip2 (1).
602 The selected compression settings determine
603 the memory requirements of the decompressor,
604 thus using a too high preset level might make it painful
605 to decompress the file on an old system with little RAM.
606 Specifically,
607 .B "it's not a good idea to blindly use \-9 for everything"
608 like it often is with
609 .BR gzip (1)
610 and
611 .BR bzip2 (1).
612 .RS
613 .TP
614 .BR "\-0" " ... " "\-3"
615 These are somewhat fast presets.
616 .B \-0
617 is sometimes faster than
618 .B "gzip \-9"
619 while compressing much better.
620 The higher ones often have speed comparable to
621 .BR bzip2 (1)
622 with comparable or better compression ratio,
623 although the results
624 depend a lot on the type of data being compressed.
625 .TP
626 .BR "\-4" " ... " "\-6"
627 Good to very good compression while keeping
628 decompressor memory usage reasonable even for old systems.
629 .B \-6
630 is the default, which is usually a good choice
631 e.g. for distributing files that need to be decompressible
632 even on systems with only 16\ MiB RAM.
633 .RB ( \-5e
634 or
635 .B \-6e
636 may be worth considering too.
637 See
638 .BR \-\-extreme .)
639 .TP
640 .B "\-7 ... \-9"
641 These are like
642 .B \-6
643 but with higher compressor and decompressor memory requirements.
644 These are useful only when compressing files bigger than
645 8\ MiB, 16\ MiB, and 32\ MiB, respectively.
646 .RE
647 .IP ""
648 On the same hardware, the decompression speed is approximately
649 a constant number of bytes of compressed data per second.
650 In other words, the better the compression,
651 the faster the decompression will usually be.
652 This also means that the amount of uncompressed output
653 produced per second can vary a lot.
654 .IP ""
655 The following table summarises the features of the presets:
656 .RS
657 .RS
658 .PP
659 .TS
660 tab(;);
661 c c c c c
662 n n n n n.
663 Preset;DictSize;CompCPU;CompMem;DecMem
664 \-0;256 KiB;0;3 MiB;1 MiB
665 \-1;1 MiB;1;9 MiB;2 MiB
666 \-2;2 MiB;2;17 MiB;3 MiB
667 \-3;4 MiB;3;32 MiB;5 MiB
668 \-4;4 MiB;4;48 MiB;5 MiB
669 \-5;8 MiB;5;94 MiB;9 MiB
670 \-6;8 MiB;6;94 MiB;9 MiB
671 \-7;16 MiB;6;186 MiB;17 MiB
672 \-8;32 MiB;6;370 MiB;33 MiB
673 \-9;64 MiB;6;674 MiB;65 MiB
674 .TE
675 .RE
676 .RE
677 .IP ""
678 Column descriptions:
679 .RS
680 .IP \(bu 3
681 DictSize is the LZMA2 dictionary size.
682 It is waste of memory to use a dictionary bigger than
683 the size of the uncompressed file.
684 This is why it is good to avoid using the presets
685 .BR \-7 " ... " \-9
686 when there's no real need for them.
687 At
688 .B \-6
689 and lower, the amount of memory wasted is
690 usually low enough to not matter.
691 .IP \(bu 3
692 CompCPU is a simplified representation of the LZMA2 settings
693 that affect compression speed.
694 The dictionary size affects speed too,
695 so while CompCPU is the same for levels
696 .BR \-6 " ... " \-9 ,
697 higher levels still tend to be a little slower.
698 To get even slower and thus possibly better compression, see
699 .BR \-\-extreme .
700 .IP \(bu 3
701 CompMem contains the compressor memory requirements
702 in the single-threaded mode.
703 It may vary slightly between
704 .B xz
705 versions.
706 Memory requirements of some of the future multithreaded modes may
707 be dramatically higher than that of the single-threaded mode.
708 .IP \(bu 3
709 DecMem contains the decompressor memory requirements.
710 That is, the compression settings determine
711 the memory requirements of the decompressor.
712 The exact decompressor memory usage is slightly more than
713 the LZMA2 dictionary size, but the values in the table
714 have been rounded up to the next full MiB.
715 .RE
716 .TP
717 .BR \-e ", " \-\-extreme
718 Use a slower variant of the selected compression preset level
719 .RB ( \-0 " ... " \-9 )
720 to hopefully get a little bit better compression ratio,
721 but with bad luck this can also make it worse.
722 Decompressor memory usage is not affected,
723 but compressor memory usage increases a little at preset levels
724 .BR \-0 " ... " \-3 .
725 .IP ""
726 Since there are two presets with dictionary sizes
727 4\ MiB and 8\ MiB, the presets
728 .B \-3e
729 and
730 .B \-5e
731 use slightly faster settings (lower CompCPU) than
732 .B \-4e
733 and
734 .BR \-6e ,
735 respectively.
736 That way no two presets are identical.
737 .RS
738 .RS
739 .PP
740 .TS
741 tab(;);
742 c c c c c
743 n n n n n.
744 Preset;DictSize;CompCPU;CompMem;DecMem
745 \-0e;256 KiB;8;4 MiB;1 MiB
746 \-1e;1 MiB;8;13 MiB;2 MiB
747 \-2e;2 MiB;8;25 MiB;3 MiB
748 \-3e;4 MiB;7;48 MiB;5 MiB
749 \-4e;4 MiB;8;48 MiB;5 MiB
750 \-5e;8 MiB;7;94 MiB;9 MiB
751 \-6e;8 MiB;8;94 MiB;9 MiB
752 \-7e;16 MiB;8;186 MiB;17 MiB
753 \-8e;32 MiB;8;370 MiB;33 MiB
754 \-9e;64 MiB;8;674 MiB;65 MiB
755 .TE
756 .RE
757 .RE
758 .IP ""
759 For example, there are a total of four presets that use
760 8\ MiB dictionary, whose order from the fastest to the slowest is
761 .BR \-5 ,
762 .BR \-6 ,
763 .BR \-5e ,
764 and
765 .BR \-6e .
766 .TP
767 .B \-\-fast
768 .PD 0
769 .TP
770 .B \-\-best
771 .PD
772 These are somewhat misleading aliases for
773 .B \-0
774 and
775 .BR \-9 ,
776 respectively.
777 These are provided only for backwards compatibility
778 with LZMA Utils.
779 Avoid using these options.
780 .TP
781 .BI \-\-memlimit\-compress= limit
782 Set a memory usage limit for compression.
783 If this option is specified multiple times,
784 the last one takes effect.
785 .IP ""
786 If the compression settings exceed the
787 .IR limit ,
788 .B xz
789 will adjust the settings downwards so that
790 the limit is no longer exceeded and display a notice that
791 automatic adjustment was done.
792 Such adjustments are not made when compressing with
793 .B \-\-format=raw
794 or if
795 .B \-\-no\-adjust
796 has been specified.
797 In those cases, an error is displayed and
798 .B xz
799 will exit with exit status 1.
800 .IP ""
801 The
802 .I limit
803 can be specified in multiple ways:
804 .RS
805 .IP \(bu 3
806 The
807 .I limit
808 can be an absolute value in bytes.
809 Using an integer suffix like
810 .B MiB
811 can be useful.
812 Example:
813 .B "\-\-memlimit\-compress=80MiB"
814 .IP \(bu 3
815 The
816 .I limit
817 can be specified as a percentage of total physical memory (RAM).
818 This can be useful especially when setting the
819 .B XZ_DEFAULTS
820 environment variable in a shell initialization script
821 that is shared between different computers.
822 That way the limit is automatically bigger
823 on systems with more memory.
824 Example:
825 .B "\-\-memlimit\-compress=70%"
826 .IP \(bu 3
827 The
828 .I limit
829 can be reset back to its default value by setting it to
830 .BR 0 .
831 This is currently equivalent to setting the
832 .I limit
833 to
834 .B max
835 (no memory usage limit).
836 Once multithreading support has been implemented,
837 there may be a difference between
838 .B 0
839 and
840 .B max
841 for the multithreaded case, so it is recommended to use
842 .B 0
843 instead of
844 .B max
845 until the details have been decided.
846 .RE
847 .IP ""
848 See also the section
849 .BR "Memory usage" .
850 .TP
851 .BI \-\-memlimit\-decompress= limit
852 Set a memory usage limit for decompression.
853 This also affects the
854 .B \-\-list
855 mode.
856 If the operation is not possible without exceeding the
857 .IR limit ,
858 .B xz
859 will display an error and decompressing the file will fail.
860 See
861 .BI \-\-memlimit\-compress= limit
862 for possible ways to specify the
863 .IR limit .
864 .TP
865 \fB\-M\fR \fIlimit\fR, \fB\-\-memlimit=\fIlimit\fR, \fB\-\-memory=\fIlimit
866 This is equivalent to specifying \fB\-\-memlimit\-compress=\fIlimit
867 \fB\-\-memlimit\-decompress=\fIlimit\fR.
868 .TP
869 .B \-\-no\-adjust
870 Display an error and exit if the compression settings exceed
871 the memory usage limit.
872 The default is to adjust the settings downwards so
873 that the memory usage limit is not exceeded.
874 Automatic adjusting is always disabled when creating raw streams
875 .RB ( \-\-format=raw ).
876 .TP
877 \fB\-T\fR \fIthreads\fR, \fB\-\-threads=\fIthreads
878 Specify the number of worker threads to use.
879 The actual number of threads can be less than
880 .I threads
881 if using more threads would exceed the memory usage limit.
882 .IP ""
883 .B "Multithreaded compression and decompression are not"
884 .B "implemented yet, so this option has no effect for now."
885 .IP ""
886 .B "As of writing (2010-09-27), it hasn't been decided"
887 .B "if threads will be used by default on multicore systems"
888 .B "once support for threading has been implemented."
889 .B "Comments are welcome."
890 The complicating factor is that using many threads
891 will increase the memory usage dramatically.
892 Note that if multithreading will be the default,
893 it will probably be done so that single-threaded and
894 multithreaded modes produce the same output,
895 so compression ratio won't be significantly affected
896 if threading will be enabled by default.
897 .
898 .SS "Custom compressor filter chains"
899 A custom filter chain allows specifying
900 the compression settings in detail instead of relying on
901 the settings associated to the presets.
902 When a custom filter chain is specified,
903 preset options (\fB\-0\fR ... \fB\-9\fR and \fB\-\-extreme\fR)
904 earlier on the command line are forgotten.
905 If a preset option is specified
906 after one or more custom filter chain options,
907 the new preset takes effect and
908 the custom filter chain options specified earlier are forgotten.
909 .PP
910 A filter chain is comparable to piping on the command line.
911 When compressing, the uncompressed input goes to the first filter,
912 whose output goes to the next filter (if any).
913 The output of the last filter gets written to the compressed file.
914 The maximum number of filters in the chain is four,
915 but typically a filter chain has only one or two filters.
916 .PP
917 Many filters have limitations on where they can be
918 in the filter chain:
919 some filters can work only as the last filter in the chain,
920 some only as a non-last filter, and some work in any position
921 in the chain.
922 Depending on the filter, this limitation is either inherent to
923 the filter design or exists to prevent security issues.
924 .PP
925 A custom filter chain is specified by using one or more
926 filter options in the order they are wanted in the filter chain.
927 That is, the order of filter options is significant!
928 When decoding raw streams
929 .RB ( \-\-format=raw ),
930 the filter chain is specified in the same order as
931 it was specified when compressing.
932 .PP
933 Filters take filter-specific
934 .I options
935 as a comma-separated list.
936 Extra commas in
937 .I options
938 are ignored.
939 Every option has a default value, so you need to
940 specify only those you want to change.
941 .PP
942 To see the whole filter chain and
943 .IR options ,
944 use
945 .B "xz \-vv"
946 (that is, use
947 .B \-\-verbose
948 twice).
949 This works also for viewing the filter chain options used by presets.
950 .TP
951 \fB\-\-lzma1\fR[\fB=\fIoptions\fR]
952 .PD 0
953 .TP
954 \fB\-\-lzma2\fR[\fB=\fIoptions\fR]
955 .PD
956 Add LZMA1 or LZMA2 filter to the filter chain.
957 These filters can be used only as the last filter in the chain.
958 .IP ""
959 LZMA1 is a legacy filter,
960 which is supported almost solely due to the legacy
961 .B .lzma
962 file format, which supports only LZMA1.
963 LZMA2 is an updated
964 version of LZMA1 to fix some practical issues of LZMA1.
965 The
966 .B .xz
967 format uses LZMA2 and doesn't support LZMA1 at all.
968 Compression speed and ratios of LZMA1 and LZMA2
969 are practically the same.
970 .IP ""
971 LZMA1 and LZMA2 share the same set of
972 .IR options :
973 .RS
974 .TP
975 .BI preset= preset
976 Reset all LZMA1 or LZMA2
977 .I options
978 to
979 .IR preset .
980 .I Preset
981 consist of an integer, which may be followed by single-letter
982 preset modifiers.
983 The integer can be from
984 .B 0
985 to
986 .BR 9 ,
987 matching the command line options \fB\-0\fR ... \fB\-9\fR.
988 The only supported modifier is currently
989 .BR e ,
990 which matches
991 .BR \-\-extreme .
992 If no
993 .B preset
994 is specified, the default values of LZMA1 or LZMA2
995 .I options
996 are taken from the preset
997 .BR 6 .
998 .TP
999 .BI dict= size
1000 Dictionary (history buffer)
1001 .I size
1002 indicates how many bytes of the recently processed
1003 uncompressed data is kept in memory.
1004 The algorithm tries to find repeating byte sequences (matches) in
1005 the uncompressed data, and replace them with references
1006 to the data currently in the dictionary.
1007 The bigger the dictionary, the higher is the chance
1008 to find a match.
1009 Thus, increasing dictionary
1010 .I size
1011 usually improves compression ratio, but
1012 a dictionary bigger than the uncompressed file is waste of memory.
1013 .IP ""
1014 Typical dictionary
1015 .I size
1016 is from 64\ KiB to 64\ MiB.
1017 The minimum is 4\ KiB.
1018 The maximum for compression is currently 1.5\ GiB (1536\ MiB).
1019 The decompressor already supports dictionaries up to
1020 one byte less than 4\ GiB, which is the maximum for
1021 the LZMA1 and LZMA2 stream formats.
1022 .IP ""
1023 Dictionary
1024 .I size
1025 and match finder
1026 .RI ( mf )
1027 together determine the memory usage of the LZMA1 or LZMA2 encoder.
1028 The same (or bigger) dictionary
1029 .I size
1030 is required for decompressing that was used when compressing,
1031 thus the memory usage of the decoder is determined
1032 by the dictionary size used when compressing.
1033 The
1034 .B .xz
1035 headers store the dictionary
1036 .I size
1037 either as
1038 .RI "2^" n
1039 or
1040 .RI "2^" n " + 2^(" n "\-1),"
1041 so these
1042 .I sizes
1043 are somewhat preferred for compression.
1044 Other
1045 .I sizes
1046 will get rounded up when stored in the
1047 .B .xz
1048 headers.
1049 .TP
1050 .BI lc= lc
1051 Specify the number of literal context bits.
1052 The minimum is 0 and the maximum is 4; the default is 3.
1053 In addition, the sum of
1054 .I lc
1055 and
1056 .I lp
1057 must not exceed 4.
1058 .IP ""
1059 All bytes that cannot be encoded as matches
1060 are encoded as literals.
1061 That is, literals are simply 8-bit bytes
1062 that are encoded one at a time.
1063 .IP ""
1064 The literal coding makes an assumption that the highest
1065 .I lc
1066 bits of the previous uncompressed byte correlate
1067 with the next byte.
1068 E.g. in typical English text, an upper-case letter is
1069 often followed by a lower-case letter, and a lower-case
1070 letter is usually followed by another lower-case letter.
1071 In the US-ASCII character set, the highest three bits are 010
1072 for upper-case letters and 011 for lower-case letters.
1073 When
1074 .I lc
1075 is at least 3, the literal coding can take advantage of
1076 this property in the uncompressed data.
1077 .IP ""
1078 The default value (3) is usually good.
1079 If you want maximum compression, test
1080 .BR lc=4 .
1081 Sometimes it helps a little, and
1082 sometimes it makes compression worse.
1083 If it makes it worse, test e.g.\&
1084 .B lc=2
1085 too.
1086 .TP
1087 .BI lp= lp
1088 Specify the number of literal position bits.
1089 The minimum is 0 and the maximum is 4; the default is 0.
1090 .IP ""
1091 .I Lp
1092 affects what kind of alignment in the uncompressed data is
1093 assumed when encoding literals.
1094 See
1095 .I pb
1096 below for more information about alignment.
1097 .TP
1098 .BI pb= pb
1099 Specify the number of position bits.
1100 The minimum is 0 and the maximum is 4; the default is 2.
1101 .IP ""
1102 .I Pb
1103 affects what kind of alignment in the uncompressed data is
1104 assumed in general.
1105 The default means four-byte alignment
1106 .RI (2^ pb =2^2=4),
1107 which is often a good choice when there's no better guess.
1108 .IP ""
1109 When the aligment is known, setting
1110 .I pb
1111 accordingly may reduce the file size a little.
1112 E.g. with text files having one-byte
1113 alignment (US-ASCII, ISO-8859-*, UTF-8), setting
1114 .B pb=0
1115 can improve compression slightly.
1116 For UTF-16 text,
1117 .B pb=1
1118 is a good choice.
1119 If the alignment is an odd number like 3 bytes,
1120 .B pb=0
1121 might be the best choice.
1122 .IP ""
1123 Even though the assumed alignment can be adjusted with
1124 .I pb
1125 and
1126 .IR lp ,
1127 LZMA1 and LZMA2 still slightly favor 16-byte alignment.
1128 It might be worth taking into account when designing file formats
1129 that are likely to be often compressed with LZMA1 or LZMA2.
1130 .TP
1131 .BI mf= mf
1132 Match finder has a major effect on encoder speed,
1133 memory usage, and compression ratio.
1134 Usually Hash Chain match finders are faster than Binary Tree
1135 match finders.
1136 The default depends on the
1137 .IR preset :
1138 0 uses
1139 .BR hc3 ,
1140 1\-3
1141 use
1142 .BR hc4 ,
1143 and the rest use
1144 .BR bt4 .
1145 .IP ""
1146 The following match finders are supported.
1147 The memory usage formulas below are rough approximations,
1148 which are closest to the reality when
1149 .I dict
1150 is a power of two.
1151 .RS
1152 .TP
1153 .B hc3
1154 Hash Chain with 2- and 3-byte hashing
1155 .br
1156 Minimum value for
1157 .IR nice :
1158 3
1159 .br
1160 Memory usage:
1161 .br
1162 .I dict
1163 * 7.5 (if
1164 .I dict
1165 <= 16 MiB);
1166 .br
1167 .I dict
1168 * 5.5 + 64 MiB (if
1169 .I dict
1170 > 16 MiB)
1171 .TP
1172 .B hc4
1173 Hash Chain with 2-, 3-, and 4-byte hashing
1174 .br
1175 Minimum value for
1176 .IR nice :
1177 4
1178 .br
1179 Memory usage:
1180 .br
1181 .I dict
1182 * 7.5 (if
1183 .I dict
1184 <= 32 MiB);
1185 .br
1186 .I dict
1187 * 6.5 (if
1188 .I dict
1189 > 32 MiB)
1190 .TP
1191 .B bt2
1192 Binary Tree with 2-byte hashing
1193 .br
1194 Minimum value for
1195 .IR nice :
1196 2
1197 .br
1198 Memory usage:
1199 .I dict
1200 * 9.5
1201 .TP
1202 .B bt3
1203 Binary Tree with 2- and 3-byte hashing
1204 .br
1205 Minimum value for
1206 .IR nice :
1207 3
1208 .br
1209 Memory usage:
1210 .br
1211 .I dict
1212 * 11.5 (if
1213 .I dict
1214 <= 16 MiB);
1215 .br
1216 .I dict
1217 * 9.5 + 64 MiB (if
1218 .I dict
1219 > 16 MiB)
1220 .TP
1221 .B bt4
1222 Binary Tree with 2-, 3-, and 4-byte hashing
1223 .br
1224 Minimum value for
1225 .IR nice :
1226 4
1227 .br
1228 Memory usage:
1229 .br
1230 .I dict
1231 * 11.5 (if
1232 .I dict
1233 <= 32 MiB);
1234 .br
1235 .I dict
1236 * 10.5 (if
1237 .I dict
1238 > 32 MiB)
1239 .RE
1240 .TP
1241 .BI mode= mode
1242 Compression
1243 .I mode
1244 specifies the method to analyze
1245 the data produced by the match finder.
1246 Supported
1247 .I modes
1248 are
1249 .B fast
1250 and
1251 .BR normal .
1252 The default is
1253 .B fast
1254 for
1255 .I presets
1256 0\-3 and
1257 .B normal
1258 for
1259 .I presets
1260 4\-9.
1261 .IP ""
1262 Usually
1263 .B fast
1264 is used with Hash Chain match finders and
1265 .B normal
1266 with Binary Tree match finders.
1267 This is also what the
1268 .I presets
1269 do.
1270 .TP
1271 .BI nice= nice
1272 Specify what is considered to be a nice length for a match.
1273 Once a match of at least
1274 .I nice
1275 bytes is found, the algorithm stops
1276 looking for possibly better matches.
1277 .IP ""
1278 .I Nice
1279 can be 2\-273 bytes.
1280 Higher values tend to give better compression ratio
1281 at the expense of speed.
1282 The default depends on the
1283 .IR preset .
1284 .TP
1285 .BI depth= depth
1286 Specify the maximum search depth in the match finder.
1287 The default is the special value of 0,
1288 which makes the compressor determine a reasonable
1289 .I depth
1290 from
1291 .I mf
1292 and
1293 .IR nice .
1294 .IP ""
1295 Reasonable
1296 .I depth
1297 for Hash Chains is 4\-100 and 16\-1000 for Binary Trees.
1298 Using very high values for
1299 .I depth
1300 can make the encoder extremely slow with some files.
1301 Avoid setting the
1302 .I depth
1303 over 1000 unless you are prepared to interrupt
1304 the compression in case it is taking far too long.
1305 .RE
1306 .IP ""
1307 When decoding raw streams
1308 .RB ( \-\-format=raw ),
1309 LZMA2 needs only the dictionary
1310 .IR size .
1311 LZMA1 needs also
1312 .IR lc ,
1313 .IR lp ,
1314 and
1315 .IR pb .
1316 .TP
1317 \fB\-\-x86\fR[\fB=\fIoptions\fR]
1318 .PD 0
1319 .TP
1320 \fB\-\-powerpc\fR[\fB=\fIoptions\fR]
1321 .TP
1322 \fB\-\-ia64\fR[\fB=\fIoptions\fR]
1323 .TP
1324 \fB\-\-arm\fR[\fB=\fIoptions\fR]
1325 .TP
1326 \fB\-\-armthumb\fR[\fB=\fIoptions\fR]
1327 .TP
1328 \fB\-\-sparc\fR[\fB=\fIoptions\fR]
1329 .PD
1330 Add a branch/call/jump (BCJ) filter to the filter chain.
1331 These filters can be used only as a non-last filter
1332 in the filter chain.
1333 .IP ""
1334 A BCJ filter converts relative addresses in
1335 the machine code to their absolute counterparts.
1336 This doesn't change the size of the data,
1337 but it increases redundancy,
1338 which can help LZMA2 to produce 0\-15\ % smaller
1339 .B .xz
1340 file.
1341 The BCJ filters are always reversible,
1342 so using a BCJ filter for wrong type of data
1343 doesn't cause any data loss, although it may make
1344 the compression ratio slightly worse.
1345 .IP ""
1346 It is fine to apply a BCJ filter on a whole executable;
1347 there's no need to apply it only on the executable section.
1348 Applying a BCJ filter on an archive that contains both executable
1349 and non-executable files may or may not give good results,
1350 so it generally isn't good to blindly apply a BCJ filter when
1351 compressing binary packages for distribution.
1352 .IP ""
1353 These BCJ filters are very fast and
1354 use insignificant amount of memory.
1355 If a BCJ filter improves compression ratio of a file,
1356 it can improve decompression speed at the same time.
1357 This is because, on the same hardware,
1358 the decompression speed of LZMA2 is roughly
1359 a fixed number of bytes of compressed data per second.
1360 .IP ""
1361 These BCJ filters have known problems related to
1362 the compression ratio:
1363 .RS
1364 .IP \(bu 3
1365 Some types of files containing executable code
1366 (e.g. object files, static libraries, and Linux kernel modules)
1367 have the addresses in the instructions filled with filler values.
1368 These BCJ filters will still do the address conversion,
1369 which will make the compression worse with these files.
1370 .IP \(bu 3
1371 Applying a BCJ filter on an archive containing multiple similar
1372 executables can make the compression ratio worse than not using
1373 a BCJ filter.
1374 This is because the BCJ filter doesn't detect the boundaries
1375 of the executable files, and doesn't reset
1376 the address conversion counter for each executable.
1377 .RE
1378 .IP ""
1379 Both of the above problems will be fixed
1380 in the future in a new filter.
1381 The old BCJ filters will still be useful in embedded systems,
1382 because the decoder of the new filter will be bigger
1383 and use more memory.
1384 .IP ""
1385 Different instruction sets have have different alignment:
1386 .RS
1387 .RS
1388 .PP
1389 .TS
1390 tab(;);
1391 l n l
1392 l n l.
1393 Filter;Alignment;Notes
1394 x86;1;32-bit or 64-bit x86
1395 PowerPC;4;Big endian only
1396 ARM;4;Little endian only
1397 ARM-Thumb;2;Little endian only
1398 IA-64;16;Big or little endian
1399 SPARC;4;Big or little endian
1400 .TE
1401 .RE
1402 .RE
1403 .IP ""
1404 Since the BCJ-filtered data is usually compressed with LZMA2,
1405 the compression ratio may be improved slightly if
1406 the LZMA2 options are set to match the
1407 alignment of the selected BCJ filter.
1408 For example, with the IA-64 filter, it's good to set
1409 .B pb=4
1410 with LZMA2 (2^4=16).
1411 The x86 filter is an exception;
1412 it's usually good to stick to LZMA2's default
1413 four-byte alignment when compressing x86 executables.
1414 .IP ""
1415 All BCJ filters support the same
1416 .IR options :
1417 .RS
1418 .TP
1419 .BI start= offset
1420 Specify the start
1421 .I offset
1422 that is used when converting between relative
1423 and absolute addresses.
1424 The
1425 .I offset
1426 must be a multiple of the alignment of the filter
1427 (see the table above).
1428 The default is zero.
1429 In practice, the default is good; specifying a custom
1430 .I offset
1431 is almost never useful.
1432 .RE
1433 .TP
1434 \fB\-\-delta\fR[\fB=\fIoptions\fR]
1435 Add the Delta filter to the filter chain.
1436 The Delta filter can be only used as a non-last filter
1437 in the filter chain.
1438 .IP ""
1439 Currently only simple byte-wise delta calculation is supported.
1440 It can be useful when compressing e.g. uncompressed bitmap images
1441 or uncompressed PCM audio.
1442 However, special purpose algorithms may give significantly better
1443 results than Delta + LZMA2.
1444 This is true especially with audio,
1445 which compresses faster and better e.g. with
1446 .BR flac (1).
1447 .IP ""
1448 Supported
1449 .IR options :
1450 .RS
1451 .TP
1452 .BI dist= distance
1453 Specify the
1454 .I distance
1455 of the delta calculation in bytes.
1456 .I distance
1457 must be 1\-256.
1458 The default is 1.
1459 .IP ""
1460 For example, with
1461 .B dist=2
1462 and eight-byte input A1 B1 A2 B3 A3 B5 A4 B7, the output will be
1463 A1 B1 01 02 01 02 01 02.
1464 .RE
1465 .
1466 .SS "Other options"
1467 .TP
1468 .BR \-q ", " \-\-quiet
1469 Suppress warnings and notices.
1470 Specify this twice to suppress errors too.
1471 This option has no effect on the exit status.
1472 That is, even if a warning was suppressed,
1473 the exit status to indicate a warning is still used.
1474 .TP
1475 .BR \-v ", " \-\-verbose
1476 Be verbose.
1477 If standard error is connected to a terminal,
1478 .B xz
1479 will display a progress indicator.
1480 Specifying
1481 .B \-\-verbose
1482 twice will give even more verbose output.
1483 .IP ""
1484 The progress indicator shows the following information:
1485 .RS
1486 .IP \(bu 3
1487 Completion percentage is shown
1488 if the size of the input file is known.
1489 That is, the percentage cannot be shown in pipes.
1490 .IP \(bu 3
1491 Amount of compressed data produced (compressing)
1492 or consumed (decompressing).
1493 .IP \(bu 3
1494 Amount of uncompressed data consumed (compressing)
1495 or produced (decompressing).
1496 .IP \(bu 3
1497 Compression ratio, which is calculated by dividing
1498 the amount of compressed data processed so far by
1499 the amount of uncompressed data processed so far.
1500 .IP \(bu 3
1501 Compression or decompression speed.
1502 This is measured as the amount of uncompressed data consumed
1503 (compression) or produced (decompression) per second.
1504 It is shown after a few seconds have passed since
1505 .B xz
1506 started processing the file.
1507 .IP \(bu 3
1508 Elapsed time in the format M:SS or H:MM:SS.
1509 .IP \(bu 3
1510 Estimated remaining time is shown
1511 only when the size of the input file is
1512 known and a couple of seconds have already passed since
1513 .B xz
1514 started processing the file.
1515 The time is shown in a less precise format which
1516 never has any colons, e.g. 2 min 30 s.
1517 .RE
1518 .IP ""
1519 When standard error is not a terminal,
1520 .B \-\-verbose
1521 will make
1522 .B xz
1523 print the filename, compressed size, uncompressed size,
1524 compression ratio, and possibly also the speed and elapsed time
1525 on a single line to standard error after compressing or
1526 decompressing the file.
1527 The speed and elapsed time are included only when
1528 the operation took at least a few seconds.
1529 If the operation didn't finish, e.g. due to user interruption,
1530 also the completion percentage is printed
1531 if the size of the input file is known.
1532 .TP
1533 .BR \-Q ", " \-\-no\-warn
1534 Don't set the exit status to 2
1535 even if a condition worth a warning was detected.
1536 This option doesn't affect the verbosity level, thus both
1537 .B \-\-quiet
1538 and
1539 .B \-\-no\-warn
1540 have to be used to not display warnings and
1541 to not alter the exit status.
1542 .TP
1543 .B \-\-robot
1544 Print messages in a machine-parsable format.
1545 This is intended to ease writing frontends that want to use
1546 .B xz
1547 instead of liblzma, which may be the case with various scripts.
1548 The output with this option enabled is meant to be stable across
1549 .B xz
1550 releases.
1551 See the section
1552 .B "ROBOT MODE"
1553 for details.
1554 .TP
1555 .BR \-\-info\-memory
1556 Display, in human-readable format, how much physical memory (RAM)
1557 .B xz
1558 thinks the system has and the memory usage limits for compression
1559 and decompression, and exit successfully.
1560 .TP
1561 .BR \-h ", " \-\-help
1562 Display a help message describing the most commonly used options,
1563 and exit successfully.
1564 .TP
1565 .BR \-H ", " \-\-long\-help
1566 Display a help message describing all features of
1567 .BR xz ,
1568 and exit successfully
1569 .TP
1570 .BR \-V ", " \-\-version
1571 Display the version number of
1572 .B xz
1573 and liblzma in human readable format.
1574 To get machine-parsable output, specify
1575 .B \-\-robot
1576 before
1577 .BR \-\-version .
1578 .
1579 .SH "ROBOT MODE"
1580 The robot mode is activated with the
1581 .B \-\-robot
1582 option.
1583 It makes the output of
1584 .B xz
1585 easier to parse by other programs.
1586 Currently
1587 .B \-\-robot
1588 is supported only together with
1589 .BR \-\-version ,
1590 .BR \-\-info\-memory ,
1591 and
1592 .BR \-\-list .
1593 It will be supported for compression and
1594 decompression in the future.
1595 .
1596 .SS Version
1597 .B "xz \-\-robot \-\-version"
1598 will print the version number of
1599 .B xz
1600 and liblzma in the following format:
1601 .PP
1602 .BI XZ_VERSION= XYYYZZZS
1603 .br
1604 .BI LIBLZMA_VERSION= XYYYZZZS
1605 .TP
1606 .I X
1607 Major version.
1608 .TP
1609 .I YYY
1610 Minor version.
1611 Even numbers are stable.
1612 Odd numbers are alpha or beta versions.
1613 .TP
1614 .I ZZZ
1615 Patch level for stable releases or
1616 just a counter for development releases.
1617 .TP
1618 .I S
1619 Stability.
1620 0 is alpha, 1 is beta, and 2 is stable.
1621 .I S
1622 should be always 2 when
1623 .I YYY
1624 is even.
1625 .PP
1626 .I XYYYZZZS
1627 are the same on both lines if
1628 .B xz
1629 and liblzma are from the same XZ Utils release.
1630 .PP
1631 Examples: 4.999.9beta is
1632 .B 49990091
1633 and
1634 5.0.0 is
1635 .BR 50000002 .
1636 .
1637 .SS "Memory limit information"
1638 .B "xz \-\-robot \-\-info\-memory"
1639 prints a single line with three tab-separated columns:
1640 .IP 1. 4
1641 Total amount of physical memory (RAM) in bytes
1642 .IP 2. 4
1643 Memory usage limit for compression in bytes.
1644 A special value of zero indicates the default setting,
1645 which for single-threaded mode is the same as no limit.
1646 .IP 3. 4
1647 Memory usage limit for decompression in bytes.
1648 A special value of zero indicates the default setting,
1649 which for single-threaded mode is the same as no limit.
1650 .PP
1651 In the future, the output of
1652 .B "xz \-\-robot \-\-info\-memory"
1653 may have more columns, but never more than a single line.
1654 .
1655 .SS "List mode"
1656 .B "xz \-\-robot \-\-list"
1657 uses tab-separated output.
1658 The first column of every line has a string
1659 that indicates the type of the information found on that line:
1660 .TP
1661 .B name
1662 This is always the first line when starting to list a file.
1663 The second column on the line is the filename.
1664 .TP
1665 .B file
1666 This line contains overall information about the
1667 .B .xz
1668 file.
1669 This line is always printed after the
1670 .B name
1671 line.
1672 .TP
1673 .B stream
1674 This line type is used only when
1675 .B \-\-verbose
1676 was specified.
1677 There are as many
1678 .B stream
1679 lines as there are streams in the
1680 .B .xz
1681 file.
1682 .TP
1683 .B block
1684 This line type is used only when
1685 .B \-\-verbose
1686 was specified.
1687 There are as many
1688 .B block
1689 lines as there are blocks in the
1690 .B .xz
1691 file.
1692 The
1693 .B block
1694 lines are shown after all the
1695 .B stream
1696 lines; different line types are not interleaved.
1697 .TP
1698 .B summary
1699 This line type is used only when
1700 .B \-\-verbose
1701 was specified twice.
1702 This line is printed after all
1703 .B block
1704 lines.
1705 Like the
1706 .B file
1707 line, the
1708 .B summary
1709 line contains overall information about the
1710 .B .xz
1711 file.
1712 .TP
1713 .B totals
1714 This line is always the very last line of the list output.
1715 It shows the total counts and sizes.
1716 .PP
1717 The columns of the
1718 .B file
1719 lines:
1720 .PD 0
1721 .RS
1722 .IP 2. 4
1723 Number of streams in the file
1724 .IP 3. 4
1725 Total number of blocks in the stream(s)
1726 .IP 4. 4
1727 Compressed size of the file
1728 .IP 5. 4
1729 Uncompressed size of the file
1730 .IP 6. 4
1731 Compression ratio, for example
1732 .BR 0.123.
1733 If ratio is over 9.999, three dashes
1734 .RB ( \-\-\- )
1735 are displayed instead of the ratio.
1736 .IP 7. 4
1737 Comma-separated list of integrity check names.
1738 The following strings are used for the known check types:
1739 .BR None ,
1740 .BR CRC32 ,
1741 .BR CRC64 ,
1742 and
1743 .BR SHA\-256 .
1744 For unknown check types,
1745 .BI Unknown\- N
1746 is used, where
1747 .I N
1748 is the Check ID as a decimal number (one or two digits).
1749 .IP 8. 4
1750 Total size of stream padding in the file
1751 .RE
1752 .PD
1753 .PP
1754 The columns of the
1755 .B stream
1756 lines:
1757 .PD 0
1758 .RS
1759 .IP 2. 4
1760 Stream number (the first stream is 1)
1761 .IP 3. 4
1762 Number of blocks in the stream
1763 .IP 4. 4
1764 Compressed start offset
1765 .IP 5. 4
1766 Uncompressed start offset
1767 .IP 6. 4
1768 Compressed size (does not include stream padding)
1769 .IP 7. 4
1770 Uncompressed size
1771 .IP 8. 4
1772 Compression ratio
1773 .IP 9. 4
1774 Name of the integrity check
1775 .IP 10. 4
1776 Size of stream padding
1777 .RE
1778 .PD
1779 .PP
1780 The columns of the
1781 .B block
1782 lines:
1783 .PD 0
1784 .RS
1785 .IP 2. 4
1786 Number of the stream containing this block
1787 .IP 3. 4
1788 Block number relative to the beginning of the stream
1789 (the first block is 1)
1790 .IP 4. 4
1791 Block number relative to the beginning of the file
1792 .IP 5. 4
1793 Compressed start offset relative to the beginning of the file
1794 .IP 6. 4
1795 Uncompressed start offset relative to the beginning of the file
1796 .IP 7. 4
1797 Total compressed size of the block (includes headers)
1798 .IP 8. 4
1799 Uncompressed size
1800 .IP 9. 4
1801 Compression ratio
1802 .IP 10. 4
1803 Name of the integrity check
1804 .RE
1805 .PD
1806 .PP
1807 If
1808 .B \-\-verbose
1809 was specified twice, additional columns are included on the
1810 .B block
1811 lines.
1812 These are not displayed with a single
1813 .BR \-\-verbose ,
1814 because getting this information requires many seeks
1815 and can thus be slow:
1816 .PD 0
1817 .RS
1818 .IP 11. 4
1819 Value of the integrity check in hexadecimal
1820 .IP 12. 4
1821 Block header size
1822 .IP 13. 4
1823 Block flags:
1824 .B c
1825 indicates that compressed size is present, and
1826 .B u
1827 indicates that uncompressed size is present.
1828 If the flag is not set, a dash
1829 .RB ( \- )
1830 is shown instead to keep the string length fixed.
1831 New flags may be added to the end of the string in the future.
1832 .IP 14. 4
1833 Size of the actual compressed data in the block (this excludes
1834 the block header, block padding, and check fields)
1835 .IP 15. 4
1836 Amount of memory (in bytes) required to decompress
1837 this block with this
1838 .B xz
1839 version
1840 .IP 16. 4
1841 Filter chain.
1842 Note that most of the options used at compression time
1843 cannot be known, because only the options
1844 that are needed for decompression are stored in the
1845 .B .xz
1846 headers.
1847 .RE
1848 .PD
1849 .PP
1850 The columns of the
1851 .B summary
1852 lines:
1853 .PD 0
1854 .RS
1855 .IP 2. 4
1856 Amount of memory (in bytes) required to decompress
1857 this file with this
1858 .B xz
1859 version
1860 .IP 3. 4
1861 .B yes
1862 or
1863 .B no
1864 indicating if all block headers have both compressed size and
1865 uncompressed size stored in them
1866 .RE
1867 .PD
1868 .PP
1869 The columns of the
1870 .B totals
1871 line:
1872 .PD 0
1873 .RS
1874 .IP 2. 4
1875 Number of streams
1876 .IP 3. 4
1877 Number of blocks
1878 .IP 4. 4
1879 Compressed size
1880 .IP 5. 4
1881 Uncompressed size
1882 .IP 6. 4
1883 Average compression ratio
1884 .IP 7. 4
1885 Comma-separated list of integrity check names
1886 that were present in the files
1887 .IP 8. 4
1888 Stream padding size
1889 .IP 9. 4
1890 Number of files.
1891 This is here to
1892 keep the order of the earlier columns the same as on
1893 .B file
1894 lines.
1895 .PD
1896 .RE
1897 .PP
1898 If
1899 .B \-\-verbose
1900 was specified twice, additional columns are included on the
1901 .B totals
1902 line:
1903 .PD 0
1904 .RS
1905 .IP 10. 4
1906 Maximum amount of memory (in bytes) required to decompress
1907 the files with this
1908 .B xz
1909 version
1910 .IP 11. 4
1911 .B yes
1912 or
1913 .B no
1914 indicating if all block headers have both compressed size and
1915 uncompressed size stored in them
1916 .RE
1917 .PD
1918 .PP
1919 Future versions may add new line types and
1920 new columns can be added to the existing line types,
1921 but the existing columns won't be changed.
1922 .
1923 .SH "EXIT STATUS"
1924 .TP
1925 .B 0
1926 All is good.
1927 .TP
1928 .B 1
1929 An error occurred.
1930 .TP
1931 .B 2
1932 Something worth a warning occurred,
1933 but no actual errors occurred.
1934 .PP
1935 Notices (not warnings or errors) printed on standard error
1936 don't affect the exit status.
1937 .
1938 .SH ENVIRONMENT
1939 .B xz
1940 parses space-separated lists of options
1941 from the environment variables
1942 .B XZ_DEFAULTS
1943 and
1944 .BR XZ_OPT ,
1945 in this order, before parsing the options from the command line.
1946 Note that only options are parsed from the environment variables;
1947 all non-options are silently ignored.
1948 Parsing is done with
1949 .BR getopt_long (3)
1950 which is used also for the command line arguments.
1951 .TP
1952 .B XZ_DEFAULTS
1953 User-specific or system-wide default options.
1954 Typically this is set in a shell initialization script to enable
1955 .BR xz 's
1956 memory usage limiter by default.
1957 Excluding shell initialization scripts
1958 and similar special cases, scripts must never set or unset
1959 .BR XZ_DEFAULTS .
1960 .TP
1961 .B XZ_OPT
1962 This is for passing options to
1963 .B xz
1964 when it is not possible to set the options directly on the
1965 .B xz
1966 command line.
1967 This is the case e.g. when
1968 .B xz
1969 is run by a script or tool, e.g. GNU
1970 .BR tar (1):
1971 .RS
1972 .RS
1973 .PP
1974 .nf
1975 .ft CW
1976 XZ_OPT=\-2v tar caf foo.tar.xz foo
1977 .ft R
1978 .fi
1979 .RE
1980 .RE
1981 .IP ""
1982 Scripts may use
1983 .B XZ_OPT
1984 e.g. to set script-specific default compression options.
1985 It is still recommended to allow users to override
1986 .B XZ_OPT
1987 if that is reasonable, e.g. in
1988 .BR sh (1)
1989 scripts one may use something like this:
1990 .RS
1991 .RS
1992 .PP
1993 .nf
1994 .ft CW
1995 XZ_OPT=${XZ_OPT\-"\-7e"}
1996 export XZ_OPT
1997 .ft R
1998 .fi
1999 .RE
2000 .RE
2001 .
2002 .SH "LZMA UTILS COMPATIBILITY"
2003 The command line syntax of
2004 .B xz
2005 is practically a superset of
2006 .BR lzma ,
2007 .BR unlzma ,
2008 and
2009 .BR lzcat
2010 as found from LZMA Utils 4.32.x.
2011 In most cases, it is possible to replace
2012 LZMA Utils with XZ Utils without breaking existing scripts.
2013 There are some incompatibilities though,
2014 which may sometimes cause problems.
2015 .
2016 .SS "Compression preset levels"
2017 The numbering of the compression level presets is not identical in
2018 .B xz
2019 and LZMA Utils.
2020 The most important difference is how dictionary sizes
2021 are mapped to different presets.
2022 Dictionary size is roughly equal to the decompressor memory usage.
2023 .RS
2024 .PP
2025 .TS
2026 tab(;);
2027 c c c
2028 c n n.
2029 Level;xz;LZMA Utils
2030 \-0;256 KiB;N/A
2031 \-1;1 MiB;64 KiB
2032 \-2;2 MiB;1 MiB
2033 \-3;4 MiB;512 KiB
2034 \-4;4 MiB;1 MiB
2035 \-5;8 MiB;2 MiB
2036 \-6;8 MiB;4 MiB
2037 \-7;16 MiB;8 MiB
2038 \-8;32 MiB;16 MiB
2039 \-9;64 MiB;32 MiB
2040 .TE
2041 .RE
2042 .PP
2043 The dictionary size differences affect
2044 the compressor memory usage too,
2045 but there are some other differences between
2046 LZMA Utils and XZ Utils, which
2047 make the difference even bigger:
2048 .RS
2049 .PP
2050 .TS
2051 tab(;);
2052 c c c
2053 c n n.
2054 Level;xz;LZMA Utils 4.32.x
2055 \-0;3 MiB;N/A
2056 \-1;9 MiB;2 MiB
2057 \-2;17 MiB;12 MiB
2058 \-3;32 MiB;12 MiB
2059 \-4;48 MiB;16 MiB
2060 \-5;94 MiB;26 MiB
2061 \-6;94 MiB;45 MiB
2062 \-7;186 MiB;83 MiB
2063 \-8;370 MiB;159 MiB
2064 \-9;674 MiB;311 MiB
2065 .TE
2066 .RE
2067 .PP
2068 The default preset level in LZMA Utils is
2069 .B \-7
2070 while in XZ Utils it is
2071 .BR \-6 ,
2072 so both use an 8 MiB dictionary by default.
2073 .
2074 .SS "Streamed vs. non-streamed .lzma files"
2075 The uncompressed size of the file can be stored in the
2076 .B .lzma
2077 header.
2078 LZMA Utils does that when compressing regular files.
2079 The alternative is to mark that uncompressed size is unknown
2080 and use end-of-payload marker to indicate
2081 where the decompressor should stop.
2082 LZMA Utils uses this method when uncompressed size isn't known,
2083 which is the case for example in pipes.
2084 .PP
2085 .B xz
2086 supports decompressing
2087 .B .lzma
2088 files with or without end-of-payload marker, but all
2089 .B .lzma
2090 files created by
2091 .B xz
2092 will use end-of-payload marker and have uncompressed size
2093 marked as unknown in the
2094 .B .lzma
2095 header.
2096 This may be a problem in some uncommon situations.
2097 For example, a
2098 .B .lzma
2099 decompressor in an embedded device might work
2100 only with files that have known uncompressed size.
2101 If you hit this problem, you need to use LZMA Utils
2102 or LZMA SDK to create
2103 .B .lzma
2104 files with known uncompressed size.
2105 .
2106 .SS "Unsupported .lzma files"
2107 The
2108 .B .lzma
2109 format allows
2110 .I lc
2111 values up to 8, and
2112 .I lp
2113 values up to 4.
2114 LZMA Utils can decompress files with any
2115 .I lc
2116 and
2117 .IR lp ,
2118 but always creates files with
2119 .B lc=3
2120 and
2121 .BR lp=0 .
2122 Creating files with other
2123 .I lc
2124 and
2125 .I lp
2126 is possible with
2127 .B xz
2128 and with LZMA SDK.
2129 .PP
2130 The implementation of the LZMA1 filter in liblzma
2131 requires that the sum of
2132 .I lc
2133 and
2134 .I lp
2135 must not exceed 4.
2136 Thus,
2137 .B .lzma
2138 files, which exceed this limitation, cannot be decompressed with
2139 .BR xz .
2140 .PP
2141 LZMA Utils creates only
2142 .B .lzma
2143 files which have a dictionary size of
2144 .RI "2^" n
2145 (a power of 2) but accepts files with any dictionary size.
2146 liblzma accepts only
2147 .B .lzma
2148 files which have a dictionary size of
2149 .RI "2^" n
2150 or
2151 .RI "2^" n " + 2^(" n "\-1)."
2152 This is to decrease false positives when detecting
2153 .B .lzma
2154 files.
2155 .PP
2156 These limitations shouldn't be a problem in practice,
2157 since practically all
2158 .B .lzma
2159 files have been compressed with settings that liblzma will accept.
2160 .
2161 .SS "Trailing garbage"
2162 When decompressing,
2163 LZMA Utils silently ignore everything after the first
2164 .B .lzma
2165 stream.
2166 In most situations, this is a bug.
2167 This also means that LZMA Utils
2168 don't support decompressing concatenated
2169 .B .lzma
2170 files.
2171 .PP
2172 If there is data left after the first
2173 .B .lzma
2174 stream,
2175 .B xz
2176 considers the file to be corrupt.
2177 This may break obscure scripts which have
2178 assumed that trailing garbage is ignored.
2179 .
2180 .SH NOTES
2181 .
2182 .SS "Compressed output may vary"
2183 The exact compressed output produced from
2184 the same uncompressed input file
2185 may vary between XZ Utils versions even if
2186 compression options are identical.
2187 This is because the encoder can be improved
2188 (faster or better compression)
2189 without affecting the file format.
2190 The output can vary even between different
2191 builds of the same XZ Utils version,
2192 if different build options are used.
2193 .PP
2194 The above means that once
2195 .B \-\-rsyncable
2196 has been implemented,
2197 the resulting files won't necessarily be rsyncable
2198 unless both old and new files have been compressed
2199 with the same xz version.
2200 This problem can be fixed if a part of the encoder
2201 implementation is frozen to keep rsyncable output
2202 stable across xz versions.
2203 .
2204 .SS "Embedded .xz decompressors"
2205 Embedded
2206 .B .xz
2207 decompressor implementations like XZ Embedded don't necessarily
2208 support files created with integrity
2209 .I check
2210 types other than
2211 .B none
2212 and
2213 .BR crc32 .
2214 Since the default is
2215 .BR \-\-check=crc64 ,
2216 you must use
2217 .B \-\-check=none
2218 or
2219 .B \-\-check=crc32
2220 when creating files for embedded systems.
2221 .PP
2222 Outside embedded systems, all
2223 .B .xz
2224 format decompressors support all the
2225 .I check
2226 types, or at least are able to decompress
2227 the file without verifying the
2228 integrity check if the particular
2229 .I check
2230 is not supported.
2231 .PP
2232 XZ Embedded supports BCJ filters,
2233 but only with the default start offset.
2234 .
2235 .SH EXAMPLES
2236 .
2237 .SS Basics
2238 Compress the file
2239 .I foo
2240 into
2241 .I foo.xz
2242 using the default compression level
2243 .RB ( \-6 ),
2244 and remove
2245 .I foo
2246 if compression is successful:
2247 .RS
2248 .PP
2249 .nf
2250 .ft CW
2251 xz foo
2252 .ft R
2253 .fi
2254 .RE
2255 .PP
2256 Decompress
2257 .I bar.xz
2258 into
2259 .I bar
2260 and don't remove
2261 .I bar.xz
2262 even if decompression is successful:
2263 .RS
2264 .PP
2265 .nf
2266 .ft CW
2267 xz \-dk bar.xz
2268 .ft R
2269 .fi
2270 .RE
2271 .PP
2272 Create
2273 .I baz.tar.xz
2274 with the preset
2275 .B \-4e
2276 .RB ( "\-4 \-\-extreme" ),
2277 which is slower than e.g. the default
2278 .BR \-6 ,
2279 but needs less memory for compression and decompression (48\ MiB
2280 and 5\ MiB, respectively):
2281 .RS
2282 .PP
2283 .nf
2284 .ft CW
2285 tar cf \- baz | xz \-4e > baz.tar.xz
2286 .ft R
2287 .fi
2288 .RE
2289 .PP
2290 A mix of compressed and uncompressed files can be decompressed
2291 to standard output with a single command:
2292 .RS
2293 .PP
2294 .nf
2295 .ft CW
2296 xz \-dcf a.txt b.txt.xz c.txt d.txt.lzma > abcd.txt
2297 .ft R
2298 .fi
2299 .RE
2300 .
2301 .SS "Parallel compression of many files"
2302 On GNU and *BSD,
2303 .BR find (1)
2304 and
2305 .BR xargs (1)
2306 can be used to parallelize compression of many files:
2307 .RS
2308 .PP
2309 .nf
2310 .ft CW
2311 find . \-type f \e! \-name '*.xz' \-print0 \e
2312     | xargs \-0r \-P4 \-n16 xz \-T1
2313 .ft R
2314 .fi
2315 .RE
2316 .PP
2317 The
2318 .B \-P
2319 option to
2320 .BR xargs (1)
2321 sets the number of parallel
2322 .B xz
2323 processes.
2324 The best value for the
2325 .B \-n
2326 option depends on how many files there are to be compressed.
2327 If there are only a couple of files,
2328 the value should probably be 1;
2329 with tens of thousands of files,
2330 100 or even more may be appropriate to reduce the number of
2331 .B xz
2332 processes that
2333 .BR xargs (1)
2334 will eventually create.
2335 .PP
2336 The option
2337 .B \-T1
2338 for
2339 .B xz
2340 is there to force it to single-threaded mode, because
2341 .BR xargs (1)
2342 is used to control the amount of parallelization.
2343 .
2344 .SS "Robot mode"
2345 Calculate how many bytes have been saved in total
2346 after compressing multiple files:
2347 .RS
2348 .PP
2349 .nf
2350 .ft CW
2351 xz \-\-robot \-\-list *.xz | awk '/^totals/{print $5\-$4}'
2352 .ft R
2353 .fi
2354 .RE
2355 .PP
2356 A script may want to know that it is using new enough
2357 .BR xz .
2358 The following
2359 .BR sh (1)
2360 script checks that the version number of the
2361 .B xz
2362 tool is at least 5.0.0.
2363 This method is compatible with old beta versions,
2364 which didn't support the
2365 .B \-\-robot
2366 option:
2367 .RS
2368 .PP
2369 .nf
2370 .ft CW
2371 if ! eval "$(xz \-\-robot \-\-version 2> /dev/null)" ||
2372         [ "$XZ_VERSION" \-lt 50000002 ]; then
2373     echo "Your xz is too old."
2374 fi
2375 unset XZ_VERSION LIBLZMA_VERSION
2376 .ft R
2377 .fi
2378 .RE
2379 .PP
2380 Set a memory usage limit for decompression using
2381 .BR XZ_OPT ,
2382 but if a limit has already been set, don't increase it:
2383 .RS
2384 .PP
2385 .nf
2386 .ft CW
2387 NEWLIM=$((123 << 20))  # 123 MiB
2388 OLDLIM=$(xz \-\-robot \-\-info\-memory | cut \-f3)
2389 if [ $OLDLIM \-eq 0 \-o $OLDLIM \-gt $NEWLIM ]; then
2390     XZ_OPT="$XZ_OPT \-\-memlimit\-decompress=$NEWLIM"
2391     export XZ_OPT
2392 fi
2393 .ft R
2394 .fi
2395 .RE
2396 .
2397 .SS "Custom compressor filter chains"
2398 The simplest use for custom filter chains is
2399 customizing a LZMA2 preset.
2400 This can be useful,
2401 because the presets cover only a subset of the
2402 potentially useful combinations of compression settings.
2403 .PP
2404 The CompCPU columns of the tables
2405 from the descriptions of the options
2406 .BR "\-0" " ... " "\-9"
2407 and
2408 .B \-\-extreme
2409 are useful when customizing LZMA2 presets.
2410 Here are the relevant parts collected from those two tables:
2411 .RS
2412 .PP
2413 .TS
2414 tab(;);
2415 c c
2416 n n.
2417 Preset;CompCPU
2418 \-0;0
2419 \-1;1
2420 \-2;2
2421 \-3;3
2422 \-4;4
2423 \-5;5
2424 \-6;6
2425 \-5e;7
2426 \-6e;8
2427 .TE
2428 .RE
2429 .PP
2430 If you know that a file requires
2431 somewhat big dictionary (e.g. 32 MiB) to compress well,
2432 but you want to compress it quicker than
2433 .B "xz \-8"
2434 would do, a preset with a low CompCPU value (e.g. 1)
2435 can be modified to use a bigger dictionary:
2436 .RS
2437 .PP
2438 .nf
2439 .ft CW
2440 xz \-\-lzma2=preset=1,dict=32MiB foo.tar
2441 .ft R
2442 .fi
2443 .RE
2444 .PP
2445 With certain files, the above command may be faster than
2446 .B "xz \-6"
2447 while compressing significantly better.
2448 However, it must be emphasized that only some files benefit from
2449 a big dictionary while keeping the CompCPU value low.
2450 The most obvious situation,
2451 where a big dictionary can help a lot,
2452 is an archive containing very similar files
2453 of at least a few megabytes each.
2454 The dictionary size has to be significantly bigger
2455 than any individual file to allow LZMA2 to take
2456 full advantage of the similarities between consecutive files.
2457 .PP
2458 If very high compressor and decompressor memory usage is fine,
2459 and the file being compressed is
2460 at least several hundred megabytes, it may be useful
2461 to use an even bigger dictionary than the 64 MiB that
2462 .B "xz \-9"
2463 would use:
2464 .RS
2465 .PP
2466 .nf
2467 .ft CW
2468 xz \-vv \-\-lzma2=dict=192MiB big_foo.tar
2469 .ft R
2470 .fi
2471 .RE
2472 .PP
2473 Using
2474 .B \-vv
2475 .RB ( "\-\-verbose \-\-verbose" )
2476 like in the above example can be useful
2477 to see the memory requirements
2478 of the compressor and decompressor.
2479 Remember that using a dictionary bigger than
2480 the size of the uncompressed file is waste of memory,
2481 so the above command isn't useful for small files.
2482 .PP
2483 Sometimes the compression time doesn't matter,
2484 but the decompressor memory usage has to be kept low
2485 e.g. to make it possible to decompress the file on
2486 an embedded system.
2487 The following command uses
2488 .B \-6e
2489 .RB ( "\-6 \-\-extreme" )
2490 as a base and sets the dictionary to only 64\ KiB.
2491 The resulting file can be decompressed with XZ Embedded
2492 (that's why there is
2493 .BR \-\-check=crc32 )
2494 using about 100\ KiB of memory.
2495 .RS
2496 .PP
2497 .nf
2498 .ft CW
2499 xz \-\-check=crc32 \-\-lzma2=preset=6e,dict=64KiB foo
2500 .ft R
2501 .fi
2502 .RE
2503 .PP
2504 If you want to squeeze out as many bytes as possible,
2505 adjusting the number of literal context bits
2506 .RI ( lc )
2507 and number of position bits
2508 .RI ( pb )
2509 can sometimes help.
2510 Adjusting the number of literal position bits
2511 .RI ( lp )
2512 might help too, but usually
2513 .I lc
2514 and
2515 .I pb
2516 are more important.
2517 E.g. a source code archive contains mostly US-ASCII text,
2518 so something like the following might give
2519 slightly (like 0.1\ %) smaller file than
2520 .B "xz \-6e"
2521 (try also without
2522 .BR lc=4 ):
2523 .RS
2524 .PP
2525 .nf
2526 .ft CW
2527 xz \-\-lzma2=preset=6e,pb=0,lc=4 source_code.tar
2528 .ft R
2529 .fi
2530 .RE
2531 .PP
2532 Using another filter together with LZMA2 can improve
2533 compression with certain file types.
2534 E.g. to compress a x86-32 or x86-64 shared library
2535 using the x86 BCJ filter:
2536 .RS
2537 .PP
2538 .nf
2539 .ft CW
2540 xz \-\-x86 \-\-lzma2 libfoo.so
2541 .ft R
2542 .fi
2543 .RE
2544 .PP
2545 Note that the order of the filter options is significant.
2546 If
2547 .B \-\-x86
2548 is specified after
2549 .BR \-\-lzma2 ,
2550 .B xz
2551 will give an error,
2552 because there cannot be any filter after LZMA2,
2553 and also because the x86 BCJ filter cannot be used
2554 as the last filter in the chain.
2555 .PP
2556 The Delta filter together with LZMA2
2557 can give good results with bitmap images.
2558 It should usually beat PNG,
2559 which has a few more advanced filters than simple
2560 delta but uses Deflate for the actual compression.
2561 .PP
2562 The image has to be saved in uncompressed format,
2563 e.g. as uncompressed TIFF.
2564 The distance parameter of the Delta filter is set
2565 to match the number of bytes per pixel in the image.
2566 E.g. 24-bit RGB bitmap needs
2567 .BR dist=3 ,
2568 and it is also good to pass
2569 .B pb=0
2570 to LZMA2 to accommodate the three-byte alignment:
2571 .RS
2572 .PP
2573 .nf
2574 .ft CW
2575 xz \-\-delta=dist=3 \-\-lzma2=pb=0 foo.tiff
2576 .ft R
2577 .fi
2578 .RE
2579 .PP
2580 If multiple images have been put into a single archive (e.g.\&
2581 .BR .tar ),
2582 the Delta filter will work on that too as long as all images
2583 have the same number of bytes per pixel.
2584 .
2585 .SH "SEE ALSO"
2586 .BR xzdec (1),
2587 .BR xzdiff (1),
2588 .BR xzgrep (1),
2589 .BR xzless (1),
2590 .BR xzmore (1),
2591 .BR gzip (1),
2592 .BR bzip2 (1),
2593 .BR 7z (1)
2594 .PP
2595 XZ Utils: <http://tukaani.org/xz/>
2596 .br
2597 XZ Embedded: <http://tukaani.org/xz/embedded.html>
2598 .br
2599 LZMA SDK: <http://7-zip.org/sdk.html>