SquashFS is a compressed read-only Linux file system (2002) with fast random access, used for live CD and USB images, firmware of routers and NAS devices, and containers and snap packages. It is actively maintained in the kernel.
Overview
SquashFS packs files, directories and inodes into compressed metadata and data blocks. The superblock records the compression method, block size and the locations of the inode table, directory table, fragment table, ID table and export table. Small file tails are collected into shared fragment blocks. Supported compressors include zlib, LZO, LZMA, XZ, LZ4 and zstd depending on version.
History
Written by Phillip Lougher in 2002.
Merged into the Linux kernel in 2.6.29 (2009).
Later versions added XZ, LZ4 and zstd compression.
Structures
Offsets are in bytes from the start of the structure named in each heading. Field names are descriptive and are not an official specification. Fixed-width integers are shown as u/i (unsigned/signed) followed by bit width and byte order.
Get Children
Offset
Size
Type
Field
Notes
at
4
u32 LE
Count
at
2
u16 LE
Offset
at + 2
2
i16 LE
Delta
at + 4
4
u32 LE
Start Block
at + 4
2
u16 LE
Type
at + 6
2
u16 LE
Name Length
at + 8
4
i32 LE
Base Number
Read Inode
Offset
Size
Type
Field
Notes
24 + length
4
u32 LE
–
headerLength + i * 4
4
u32 LE
–
Read Inode
Offset
Size
Type
Field
Notes
0x0
2
u16 LE
Type
0x2
2
u16 LE
Ode
0x10
8
u64 LE
Start
0x18
2
u16 LE
Size
0x18
8
u64 LE
Size
0x1A
2
u16 LE
Offset
0x22
2
u16 LE
Offset
at
2
u16 LE
Index
at
4
u32 LE
–
Read Xattrs
Offset
Size
Type
Field
Notes
0x0
2
u16 LE
Type
0x2
2
u16 LE
Name Length
Squash Fs File System
Offset
Size
Type
Field
Notes
0x0
8
u64 LE
Xattr Table Start
0x8
4
u32 LE
Count
Squash Fs File System
Offset
Size
Type
Field
Notes
i * 16 + 8
4
u32 LE
I
i * 16 + 12
4
u32 LE
I
i * 16
8
u64 LE
I
Parse
Offset
Size
Type
Field
Notes
0x0
4
u32 LE
–
0x4
4
u32 LE
Inodes
0x8
4
u32 LE
Mkfs Time
0xC
4
u32 LE
Block Size
0x10
4
u32 LE
Fragments
0x14
2
u16 LE
Compression
0x18
2
u16 LE
Flags
0x1A
2
u16 LE
Id Count
0x1C
2
u16 LE
Major
0x1E
2
u16 LE
Minor
0x20
8
u64 LE
Root Inode
0x28
8
i64 LE
Bytes Used
0x30
8
i64 LE
Id Table Start
0x38
8
i64 LE
Xattr Id Table Start
0x40
8
i64 LE
Inode Table Start
0x48
8
i64 LE
Directory Table Start
0x50
8
i64 LE
Fragment Table Start
Other fields read
Read in
Offset
Size
Type
Field
Notes
Metadata Block
0x0
2
u16 LE
Word
Read Table
i * 8
8
u64 LE
Position
Read Xattrs
4
u32 LE
Length
Read Xattrs
4
u32 LE
Value Length
Read Xattrs
0x0
8
u64 LE
Value Reference
Squash Fs File System
i * 4
4
u32 LE
I
Probe
0x0
4
u32 LE
Agic
Constants
Squash Fs Superblock
Name
Value
Type
Notes
Magic
0x73717368
uint
“hsqs”
Size
96
int
Squash Fs File System
Name
Value
Type
Notes
MetadataSize
8192
int
UncompressedMetadata
0x8000
ushort
UncompressedData
1 << 24
uint
NoFragment
0xFFFFFFFF
uint
Sector
512
int
Squash Fs File Stream
Name
Value
Type
Notes
UncompressedData
1 << 24
uint
Implementation limits
Class
Name
Value
Notes
Squash Fs File System
MaxCachedBlocks
512
Structures and constants were extracted from the implementation. Prose sections are a summary from public sources; verify details before relying on them.