What Is SquashFS in Linux and How It Works

SquashFS is an open-source, highly compressed, read-only file system for the Linux operating system designed to minimize storage consumption while preserving fast read performance. By packaging entire directory trees into dense, read-only block-level archives, it allows operating systems and applications to access files directly without prior decompression to a drive. This article explains the primary purpose of SquashFS, the mechanics behind its high-density architecture, its core technical benefits, and the typical environments where it is deployed, including embedded firmware, Live media, and modern containerized package managers.

The Primary Purpose of SquashFS

The fundamental goal of SquashFS is to maximize storage efficiency in environments where data needs to be read frequently but never altered. Traditional writable file systems like ext4, Btrfs, or XFS allocate significant metadata overhead for file journals, block allocation maps, write locks, and fragmentation management. Because SquashFS is strictly read-only, it discards all write-related mechanisms entirely. This allows the file system to arrange data blocks and metadata in a continuous, fully compressed stream that dramatically lowers storage requirements.

How SquashFS Operates

SquashFS packages files, inodes, directories, and extended attributes into fixed-size blocks (typically ranging from 4 KiB up to 1 MiB). Instead of decompressing an entire archive to access a single file—as is required by formats like .tar.gz—the Linux kernel mounts the SquashFS image directly as a block device via a loop device.

When the operating system requests a specific file, SquashFS identifies the precise compressed blocks containing that data, reads them from the physical storage, decompresses them into system RAM, and serves them to the user space. It supports multiple standard compression algorithms depending on the use-case requirements:

SquashFS also implements duplicate-file detection during image creation. If multiple identical files exist across different directories, SquashFS stores only a single copy of the data blocks, pointing multiple directory entries to the same offset to further reduce disk usage.

Key Advantages

Common Use Cases