From LinuxReviews
Jump to navigationJump to search

Squashfs is a compressed read only file system. It supports all the modern compression algorithms, including gzip, lzma, lzo and zstd compression. It can be used together with aufs to provide a fast writable filesystem for desktop and embedded systems.


The Linux kernel must be built with CONFIG_SQUASHFS. It can be found in make menuconfig under File systems ▸ Miscellaneous filesystems. Several sub-options for it become visible once you select it. The default selection is usually fine.


There are two competing sets of user-space utilities for squashfs:

squashfs-tools development looked dead to those who looked at the SourceForge repository when the developers moved from SourceForge to GitHub in the mid-2010s. A few developers who assumed it was dead decided to fork it and actively maintain that fork. They looked at the code, scratched their heads and decided to just scrap everything and start over. Those efforts became squashfs-tools-ng. The current squashfs-tools-ng utilities share no code with squashfs-tools, they are entire different implementations.

The original developers squashfs-tools kept actively developing the original set of utilities at GitHub where it is still, as of March 2021, being actively maintained.

mksquashfs (squashfs-utils)

squashfs filesystems are made using mksquashfs. -b specifies the block size. 131072 (128k) is the default size. A larger block size will usually result in slightly better compression, but the read speed can be worse. The default block size is a good choice.

Shell command(s):
nice -n 19 mksquashfs /usr /squashed/backup/usr.sfs.`date --iso` -comp xz -b 131072

gzip compression is used if no -comp parameter is provided. gzip, lzma, lzo, lz2, xz and zstd are supported. See Comparison of Compression Algorithms to get an idea how they compare in general. You may want to refer to mksquashfs --help to see what options are available for each; there are algorithm-specific options (-Xcompression-level, for example, is only available for gzip, lzo and zstd).

Compression comparison

These are the results of a /usr tree on a very big Gentoo Linux installation with a few games being compressed using gzip and xz.

19090 Mbytes filesystem

gzip, 128k bs

gzip, 256k bs

xz, 128k bs

xz, 256k bs

Compressed size

8992.04 Mbytes

8955.73 Mbytes

8384.18 Mbytes

8247.87 Mbytes

% of uncompressed filesystem size





% uncompressed inode table size





% uncompressed dir size





The difference between xz and gzip is huge, the difference between 128k and 256k block sizes is not.


It is possible to combine read-only squashfs file systems with a writable file system on top that behind-the-scenes writes changes to another location.

Gentoo Linux users can use squashfs+aufs to create a fast root filesystem.[1]


Add your comment
LinuxReviews welcomes all comments. If you do not want to be anonymous, register or log in. It is free.