Understanding the 7-Zip -m Switch Family
The -m switch family in the 7-Zip command line utility
is used to specify advanced compression methods and parameters when
creating or updating archives. This article explains the core functions
of the -m switch, breaks down its most common parameter
variants—such as compression levels, algorithms, dictionary sizes, and
multithreading—and demonstrates how to structure these commands for
optimal archive performance.
Core Purpose of the
-m Switch
In 7-Zip (7z.exe or 7za.exe), the
-m switch controls how data is packed. While standard
commands like 7z a archive.7z files/ will compress using
default settings, appending -m flags allows users to
fine-tune the balance between compression ratio, memory usage, and
processing speed.
The general syntax follows the pattern:
-m<parameter>=<value>
In many cases, shorthand forms such as -mx9 are used
directly without an equals sign.
Key -m Switch
Parameters
1. Compression Level
(-mx)
The -mx parameter sets the overall compression intensity
on a scale from 0 to 9:
-mx0: Copy mode (no compression, files are only archived).-mx1: Fastest compression (lowest ratio, minimal CPU usage).-mx3: Fast compression.-mx5: Normal compression (default setting).-mx7: Maximum compression.-mx9: Ultra compression (highest ratio, maximum CPU and RAM usage).
2. Compression Method
(-m0=)
The method switch designates the primary compression algorithm used for the archive:
-m0=LZMA: Standard Lempel-Ziv-Markov chain algorithm.-m0=LZMA2: Improved version of LZMA offering better multithreading support and handling of uncompressible data (default for.7z).-m0=PPMd: Optimized for compressing plain text files.-m0=BZip2: Standard block-sorting algorithm.-m0=Deflate: Standard algorithm used primarily for.zipformat compatibility.-m0=Copy: No compression applied.
3. Dictionary Size
(-md)
The dictionary size determines how much data the algorithm analyzes at one time to find repeating patterns. A larger dictionary typically improves the compression ratio but increases memory consumption during both compression and decompression.
- Syntax:
-md=[size][k|m|g] - Example:
-md=64msets the dictionary size to 64 megabytes.
4. Fast Bytes / Word Size
(-mfb)
The fast bytes parameter sets the number of bytes evaluated when searching for matches.
- Syntax:
-mfb=[number] - Values range from 5 to 273 (for LZMA/LZMA2). Higher values can slightly improve the compression ratio at the cost of processing speed.
5. Solid Archiving
(-ms)
Solid archiving treats all files as a single continuous data stream, which significantly improves compression ratios for archives containing many similar files.
-ms=on: Enables solid block mode (default for.7z).-ms=off: Disables solid mode, allowing faster extraction of individual files.-ms=[size][k|m|g]: Limits solid blocks to a specific total data size.
6. Multithreading
(-mmt)
Controls the number of CPU threads allocated to the compression task.
-mmt=onor-mmt=off: Toggles multithreading.-mmt=[N]: Explicitly sets the number of CPU threads to use (e.g.,-mmt=4for four threads).
Practical Examples
Create an Ultra-Compressed Archive Using 8 Threads:
7z a -mx9 -mmt=8 archive.7z /path/to/files/Fastest Compression with Large Dictionary Size:
7z a -m0=LZMA2 -mx1 -md=128m archive.7z /path/to/files/Store-Only Mode (No Compression, Fast Packaging):
7z a -mx0 backup.7z /path/to/files/