LZ4

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
(Added DWARFS as a user of LZ4.)
(Added link for magic bytes, only for FormatInfo. Added more "signature bytes" depending on version. Clarified which magic bytes belongs to which versions of LZ4.)
Line 5: Line 5:
 
|wikidata={{wikidata|Q15624241}} (Compression algorithm)<br />{{wikidata|Q28770292}} (file format)
 
|wikidata={{wikidata|Q15624241}} (Compression algorithm)<br />{{wikidata|Q28770292}} (file format)
 
|compression=lossless, mandatory
 
|compression=lossless, mandatory
|magic=02 21 4c 18 (legacy)<br />04 22 4d 18
+
|magic=[https://github.com/file/file/blob/master/magic/Magdir/compress#L304 02 21 4c 18] (v0.1-v0.9)<br />[https://github.com/file/file/blob/master/magic/Magdir/compress#L302 03 21 4c 18] (v1.0-v1.3)<br />[https://github.com/file/file/blob/master/magic/Magdir/compress#L298 04 22 4d 18] (v1.4+)
 
|released=2011
 
|released=2011
 
}}
 
}}
Line 18: Line 18:
  
 
== Identification ==
 
== Identification ==
When used as a file format, LZ4 files begin with signature bytes {{magic|04 22 4d 18}}.
+
* LZ4 (v1.4+) compressed files begin with signature bytes {{magic|04 22 4d 18}}.
 
+
* LZ4 (v1.0-v1.3) compressed files begin with signature bytes {{magic|03 21 4c 18}}.
There is also a legacy format, whose signature is {{magic|02 21 4c 18}}.
+
* LZ4 (v0.1-v0.9) compressed files begin with signature bytes {{magic|02 21 4c 18}}.
  
 
== Resources ==
 
== Resources ==

Revision as of 11:27, 16 August 2025

File Format
Name LZ4
Ontology
Extension(s) .lz4
Wikidata ID Q15624241 (Compression algorithm)
Q28770292 (file format)
Compression lossless, mandatory
Magic Bytes 02 21 4c 18 (v0.1-v0.9)
03 21 4c 18 (v1.0-v1.3)
04 22 4d 18 (v1.4+)
Released 2011

LZ4 is a lossless data compression algorithm and compressed data format. It is designed to support very fast compression.

In Linux, LZ4 appears as one of the many compression format for:

Identification

  • LZ4 (v1.4+) compressed files begin with signature bytes 04 22 4d 18.
  • LZ4 (v1.0-v1.3) compressed files begin with signature bytes 03 21 4c 18.
  • LZ4 (v0.1-v0.9) compressed files begin with signature bytes 02 21 4c 18.

Resources

References

  1. extract-vmlinux shell script (line 56) - Linus Torvalds' kernel - GitHub
  2. dracut.conf.5.adoc - dracut-ng manual pages - GitHub
  3. mkinitcpio.conf (lines 61-67) - mkinitcpio - Arch Linux GitLab
  4. manpage.md (line 57) - booster - GitHub
  5. compressor.c (lines 31-77) - squashfs-tools - GitHub
  6. 2) Select compression algorithm - zram: Compressed RAM-based block devices -- The Linux Kernel documentation
  7. lz4.cpp - DWARFS - GitHub
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox