LinuxCommandLibrary

unsquashfs

Extract files from a SquashFS filesystem

TLDR

Extract a squashfs filesystem to squashfs-root in the current working directory

$ unsquashfs [filesystem.squashfs]
copy

Extract a squashfs filesystem to the specified directory
$ unsquashfs [[-d|-dest]] [path/to/directory] [filesystem.squashfs]
copy

Display the names of files as they are extracted
$ unsquashfs [[-i|-info]] [filesystem.squashfs]
copy

Display the names of files and their attributes as they are extracted
$ unsquashfs [[-li|-linfo]] [filesystem.squashfs]
copy

List files inside the squashfs filesystem (without extracting)
$ unsquashfs [[-l|-ls]] [filesystem.squashfs]
copy

List files and their attributes inside the squashfs filesystem (without extracting)
$ unsquashfs [[-ll|-lls]] [filesystem.squashfs]
copy

SYNOPSIS

unsquashfs [OPTIONS] <SQUASHFS_FILE> [FILE_OR_DIR] ...

PARAMETERS

-d , --dest
    Specify the destination directory for extracted files.

-f, --force
    Overwrite existing files without prompting.

-i, --info
    Display information about the SquashFS image, but do not extract.

-l, --ls
    List the contents of the SquashFS image, but do not extract.

-p , --processors
    Use a specified number of processors for parallel decompression.

-q, --quiet
    Suppress most output during extraction.

-s, --stat
    Display statistics about the extraction process, such as decompression rates and total bytes.

-v, --verbose
    Produce verbose output during extraction, showing files as they are processed.

-o , --offset
    Specify an offset in bytes at the start of the image to skip. Useful for images embedded within other files.

DESCRIPTION

unsquashfs is a utility used to extract the contents of a SquashFS filesystem image. SquashFS is a highly compressed, read-only filesystem for Linux, primarily used for live CDs, embedded systems, and general purpose data archiving. unsquashfs allows users to decompress and access the files and directories stored within a SquashFS image, effectively reversing the squashing process. It can extract to the current directory or a specified target directory, preserving file metadata like permissions and timestamps where possible. It's an essential tool for inspecting, modifying (indirectly), or accessing data within SquashFS archives often found in system recovery partitions, firmware, or live operating system environments.

CAVEATS

unsquashfs requires sufficient disk space to store the uncompressed contents. The original file permissions and timestamps are preserved if the extracting user has the necessary privileges; otherwise, permissions might be adjusted to match the current user's capabilities. It cannot modify a SquashFS image directly; to alter contents, one must extract, modify, and then re-create the image using mksquashfs. Corrupted SquashFS images might lead to incomplete or failed extractions.

USAGE WITH SPECIFIC FILES/DIRECTORIES

You can extract only specific files or directories by listing them as arguments after the SquashFS image path. For example: unsquashfs image.sqfs /path/to/file.txt /another/directory/. This allows for selective extraction, saving time and disk space when only a few items are needed.

EMBEDDING SQUASHFS IMAGES

The -o or --offset option is particularly useful when a SquashFS image is appended to another file (e.g., a kernel or bootloader) or embedded within a larger archive. This allows unsquashfs to start reading the SquashFS data from the correct position, ignoring the preceding data.

HISTORY

SquashFS and its accompanying tools, including unsquashfs, were developed to provide a highly compressed, read-only filesystem suitable for various uses, particularly in embedded systems, live Linux distributions (like Knoppix, Ubuntu Live CDs), and for distributing software. The first public release was around 2002. unsquashfs has evolved with the SquashFS format, supporting newer compression algorithms and features over time. Its utility lies in enabling easy access to the contents of these often-large compressed archives without needing to mount the entire filesystem.

SEE ALSO

mksquashfs(8), squashfs(5), mount(8)

Copied to clipboard