Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:SquashFS

From ReverseEngineering.wiki
Format
Magic 68 73 71 73 (hsqs) little-endian; sqsh big-endian
Extensions .squashfs, .sqfs, .sfs
Endianness little (big-endian variants exist)
License GPL-2.0+ (squashfs-tools)
On this wiki Facts · Code · Notes · Topics

Read-only compressed filesystem common in router, camera and IoT firmware: 96-byte superblock with magic 'hsqs' (73 71 73 68 little-endian), block size, compression id (1 zlib ... 6 zstd), flags, and table offsets.

Superblock (96 bytes at offset 0)

Offset Size Field
0 4 s_magic 0x73717368 (bytes 68 73 71 73, ASCII "hsqs"); big-endian images read sqsh
4 4 inode count
8 4 mkfs_time
12 4 block_size (power of two, 4096 to 1048576; default 131072)
16 4 fragment count
20 2 compression id
22 2 block_log (log2 of block_size)
24 2 flags
26 2 id count
28 2 s_major (4)
30 2 s_minor (0)
32 8 root inode reference
40 8 bytes_used
48 8 id_table_start
56 8 xattr_id_table_start (0xffffffffffffffff = none)
64 8 inode_table_start
72 8 directory_table_start
80 8 fragment_table_start
88 8 lookup (export) table start

Compression ids: 1 zlib, 2 LZMA, 3 LZO, 4 XZ, 5 LZ4, 6 zstd (see Format:Gzip, Format:LZMA, Format:XZ, Format:LZ4, Format:Zstandard, Library:LZO).

Flag bits: 0 uncompressed inodes, 1 uncompressed data, 3 uncompressed fragments, 4 no fragments, 5 always fragments, 6 duplicates removed, 7 exportable (NFS), 8 uncompressed xattrs, 9 no xattrs, 10 compressor options present (a metadata block follows the superblock).

Structure

Everything after the superblock is stored in metadata blocks (up to 8192 bytes uncompressed each) or data blocks of block_size. A u16 metadata header or u32 data block size carries the compressed length; bit 15 (metadata) or bit 24 (data) set means the block is stored uncompressed. Inode types: 1 dir, 2 file, 3 symlink, 4 block dev, 5 char dev, 6 fifo, 7 socket and 8-14 the extended variants (ldir, lreg, ...). File tails are packed into fragment blocks. The image is padded to 4096 bytes, so a dump often has trailing 0xFF or 0x00 beyond bytes_used.

Analyst notes

  • Extract with unsquashfs (squashfs-tools); if it refuses, the vendor may use a custom compressor or patched magic. Unverified leads from firmware tooling: magics shsq, qshs, tqsh, hsqt, sqlz appear in vendor builds with LZMA or non-standard layouts, and some Broadcom firmware uses SquashFS 3.x (s_major 3) with LZMA.
  • Locate in a firmware blob by scanning for hsqs; bytes_used gives the length to carve.
  • The rootfs usually carries the Linux userland of Platform:Linux kernel devices.

Sources: plougher/squashfs-tools squashfs-tools/squashfs_fs.h.

Code & repositories

  • https://github.com/plougher/squashfs-tools @ db038ef265ed00bb17aaf695a72f9b0c3489eb20 · license: GPL-2.0
    mksquashfs/unsquashfs; squashfs_fs.h has the on-disk structures
    Tested on: source read, not run: source read · checked 2026-10-18; last activity 2026-08-22