Jun 07, 2023
7zip CLI - Best compression method (ultra LZMA2)
When using the 7zip CLI (7z) you may want to use the highest possible Ultra LZMA2 compression you can select in the 7zip UI.
The following flags will do this:
7z a -t7z <filename.7z> <source> -m0=lzma2 -mx=9
For example:
7z a -t7z myarchive.7z /path/to/myfiles -m0=lzma2 -mx=9
Breaking this down by argument:
atells 7z that we are adding files to an archive (new or existing)-t7ztells 7z that the type of archive we are creating is 7zip (as opposed to one of the other formats that the 7z CLI supports)-m0=lzma2tells 7z to use LZMA2 compression-mx=9tells 7z to use the highest possible compression setting for the selected method