Format:LUKS
| On this wiki | Facts · Code · Notes · Topics |
|---|
Linux Unified Key Setup disk-encryption header, recognition level: magic "LUKS\xba\xbe" followed by a big-endian version; LUKS1 has a fixed 592-byte binary header with eight keyslots, LUKS2 a binary header plus JSON metadata area, with a second copy marked "SKUL\xba\xbe".
This page covers how to recognise and delimit a LUKS container. It does not cover key recovery.
Identification
Bytes 4C 55 4B 53 BA BE at offset 0 of the encrypted device, then a 16-bit big-endian version (1 or 2). blkid-style tools use this to report crypto_LUKS.
LUKS1 header (cryptsetup lib/luks1/luks.h, struct luks_phdr)
magic (6), version (2), cipherName (32), cipherMode (32), hashSpec (32), payloadOffset (4, in 512-byte sectors), keyBytes (4), mkDigest (20, SHA-1 sized), mkDigestSalt (32), mkDigestIterations (4), uuid (40, text), then 8 keyslot structs (LUKS_NUMKEYS 8) each: active (4; 0x00AC71F3 enabled, 0x0000DEAD disabled), passwordIterations (4), passwordSalt (32), keyMaterialOffset (4, sectors), stripes (4; LUKS_STRIPES 4000), plus 432 bytes padding to 592. Fields are big endian. Key material areas are aligned to 4096 bytes.
LUKS2 header (lib/luks2/luks2.h, struct luks2_hdr_disk)
magic (6) "LUKS\xba\xbe" in the primary copy and "SKUL\xba\xbe" in the secondary; version 2 (2); hdr_size (8, total bytes including the JSON area); seqid (8, increased per update); label (48); checksum_alg (32, e.g. sha256); salt (64); uuid (40); subsystem (48); hdr_offset (8, this copy's byte offset); padding; csum (64) computed with csum zeroed over the binary header plus the whole JSON area. The binary part is 4096 bytes; a JSON area follows describing keyslots, tokens, segments, digests and config.
Sizes: valid hdr_size is 16 KiB (0x4000) up to 4 MiB (0x400000); the secondary header sits at offset = hdr_size; allowed header sizes are the list 0x4000, 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000, 0x200000, 0x400000. Default metadata + keyslot area is 16 MiB; keyslot area max 128 MiB. The data segment offset is given in the JSON segments object.
Related
- qcow2 can embed a LUKS header (Format:QCOW2, header extension 0x0537BE77).
- Do not publish keys or key material from real containers.
Code & repositories
- cryptsetup (GPL-2.0-or-later with exceptions; Unverified exact SPDX).
- https://github.com/mbroz/cryptsetup @
102e91cb0fee849bb86fb1ec4d6ea218e45563cd· license: GPL-2.0
lib/luks1/luks.h and lib/luks2/luks2.h: LUKS1 and LUKS2 on-disk header structures (GitHub mirror of the GitLab project)
Tested on: source read, not run: source read only · checked 2026-10-19; last activity 2026-10-16