SQUASHFS Files Explained

Squash filesystem

📂Archive
🎯application/octet-stream

Squashfs Filesystem

Overview

Squashfs is a compressed read-only filesystem for Linux and other Unix-like operating systems. It compresses files, inodes, and directories, and supports block sizes from 4 KiB up to 1 MiB for greater compression. Squashfs is widely used in embedded systems, live CDs/DVDs, and container images due to its excellent compression ratio and fast random access capabilities.

Technical Specifications

Format Details

  • Filesystem Type: Compressed read-only
  • Block Sizes: 4KB to 1MB (default: 128KB)
  • Compression: Multiple algorithms supported
  • Endianness: Little-endian and big-endian support
  • Maximum File Size: 2^63 bytes

Compression Algorithms

  • GZIP: Default, good balance of speed and compression
  • LZMA/XZ: Better compression but slower
  • LZO: Faster decompression
  • LZ4: Very fast compression/decompression
  • ZSTD: Modern algorithm with good speed/ratio balance

History and Development

Squashfs was created by Phillip Lougher and first released in 2002:

  • 2002: Initial release (Squashfs 1.0)
  • 2004: Squashfs 2.0 with improved compression
  • 2006: Squashfs 3.0 included in Linux kernel
  • 2009: Squashfs 4.0 with major format changes
  • 2014: XZ compression support added
  • 2017: LZ4 compression support
  • 2020: ZSTD compression support

Common Use Cases

Live Operating Systems

# Creating a live CD/DVD filesystem
mksquashfs /source/directory filesystem.squashfs -comp xz -Xbcj x86

# Mounting the filesystem
sudo mount -t squashfs filesystem.squashfs /mnt/squashfs

Container Images

# Docker layers often use squashfs
# Extract Docker image layer
docker save image:tag | tar -xvf -
unsquashfs layer.tar

Embedded Systems

# Creating firmware image
mksquashfs /rootfs /firmware/rootfs.squashfs -comp lzo -b 64K

# Optimizing for space
mksquashfs /system system.squashfs -comp xz -Xdict-size 100%

Tools and Software

Creation Tools

# Basic squashfs creation
mksquashfs source_directory output.squashfs

# Advanced options
mksquashfs /source /output.squashfs \
    -comp xz \
    -Xbcj x86 \
    -b 1M \
    -processors 4 \
    -no-recovery

Extraction Tools

# Extract entire filesystem
unsquashfs filesystem.squashfs

# Extract to specific directory
unsquashfs -d /target/dir filesystem.squashfs

# List contents without extracting
unsquashfs -l filesystem.squashfs

Advanced Tools

  • squashfs-tools: Standard utilities (mksquashfs, unsquashfs)
  • squashfs-tools-ng: Next generation tools
  • squashfuse: FUSE implementation for user-space mounting

Technical Features

Compression Options

# GZIP compression (default)
mksquashfs /source output.squashfs -comp gzip

# XZ compression for maximum compression
mksquashfs /source output.squashfs -comp xz -Xdict-size 100%

# LZ4 for fastest access
mksquashfs /source output.squashfs -comp lz4 -Xhc

# ZSTD balanced approach
mksquashfs /source output.squashfs -comp zstd -Xcompression-level 15

Block Size Optimization

# Small block size for better compression
mksquashfs /source output.squashfs -b 4K

# Large block size for better I/O performance
mksquashfs /source output.squashfs -b 1M

# Auto-detect optimal block size
mksquashfs /source output.squashfs -b 0

File System Features

  • Hard Links: Preserved and shared
  • Symbolic Links: Fully supported
  • Extended Attributes: Preserved
  • File Holes: Detected and optimized
  • Duplicate Detection: Automatic deduplication

Performance Characteristics

Compression Comparison

Algorithm Compression Ratio Compression Speed Decompression Speed
GZIP Good Medium Fast
XZ/LZMA Excellent Slow Medium
LZO Fair Fast Very Fast
LZ4 Fair Very Fast Very Fast
ZSTD Very Good Fast Fast

Optimization Examples

# For maximum compression (slow creation, normal access)
mksquashfs /source output.squashfs -comp xz -Xdict-size 100% -b 1M

# For fastest access (larger size)
mksquashfs /source output.squashfs -comp lz4 -b 64K

# Balanced approach
mksquashfs /source output.squashfs -comp zstd -Xcompression-level 10

Best Practices

Creation Guidelines

  • Choose compression based on use case
  • Use larger block sizes for sequential access
  • Use smaller block sizes for random access
  • Consider target hardware capabilities

Optimization Strategies

# Remove unnecessary files before compression
mksquashfs /source output.squashfs -e dev proc sys tmp

# Sort files for better compression
mksquashfs /source output.squashfs -sort sort_file.txt

# Use wildcards for exclusions
mksquashfs /source output.squashfs -wildcards -e "*.tmp" "*.log"

Mounting Options

# Standard mounting
mount -t squashfs -o loop image.squashfs /mnt

# With specific options
mount -t squashfs -o loop,ro,noatime image.squashfs /mnt

# User-space mounting with squashfuse
squashfuse image.squashfs /mnt

Security Considerations

Read-Only Nature

  • Inherently secure against modification
  • Cannot be corrupted by runtime errors
  • Suitable for trusted boot environments

Integrity Checking

  • Built-in checksums for data integrity
  • Filesystem metadata is checksummed
  • Corruption detection during access

Use in Secure Environments

# Create filesystem with verification
mksquashfs /source output.squashfs -comp xz -check-data

# Verify filesystem integrity
unsquashfs -fsck output.squashfs

Integration Examples

Docker and Containers

# Using squashfs in container builds
FROM alpine:latest
RUN apk add --no-cache squashfs-tools
COPY create_layer.sh /
RUN ./create_layer.sh

Embedded Linux

# Buildroot integration
BR2_TARGET_ROOTFS_SQUASHFS=y
BR2_TARGET_ROOTFS_SQUASHFS4_XZ=y

# OpenWrt usage
make menuconfig # Enable squashfs for rootfs

Live Systems

# Create live system
mksquashfs /chroot livefs.squashfs -comp xz
# Add to ISO or boot media

File Format Structure

Filesystem Layout

  1. Superblock: Filesystem metadata
  2. Compression Options: Algorithm parameters
  3. Datablocks: Compressed file data
  4. Metadata Blocks: Compressed metadata
  5. Inode Table: File system objects
  6. Directory Table: Directory entries
  7. Fragment Table: Small file fragments
  8. Export Table: NFS export support

Advantages

  • Excellent compression ratios
  • Fast random access
  • Low memory usage during access
  • Cross-platform compatibility
  • Atomic filesystem image

Limitations

  • Read-only filesystem
  • Cannot be modified after creation
  • Requires kernel support for mounting
  • Creation can be CPU intensive

Squashfs remains the preferred choice for read-only filesystems where space efficiency and fast access are critical, particularly in embedded systems, live operating systems, and containerized environments.

File Information

File Description

Squash filesystem

Category

Archive

Extensions

MIME Type

application/octet-stream

Related File Types

Other file types in the Archive category you might also need:

Start Analyzing SQUASHFS Files Now

Use our free AI-powered tool to detect and analyze Squash filesystem files instantly with Google's Magika technology.

Try File Detection Tool