Scroll to navigation

MKSQUASHFS(1) User Commands MKSQUASHFS(1)

NAME

mksquashfs - tool to create and append to squashfs filesystems

SYNOPSIS

mksquashfs source1 source2 ... FILESYSTEM [OPTIONS] [-e list of exclude dirs/files]

DESCRIPTION

Squashfs is a highly compressed read-only filesystem for Linux. It uses either gzip/xz/lzo/lz4/zstd compression to compress both files, inodes and directories. Inodes in the system are very small and all blocks are packed to minimise data overhead. Block sizes greater than 4K are supported up to a maximum of 1Mbytes (default block size 128K).

Squashfs is intended for general read-only filesystem use, for archival use (i.e. in cases where a .tar.gz file may be used), and in constrained block device/memory systems (e.g. embedded systems) where low overhead is needed.

OPTIONS

Filesystem build options:

read uncompressed tar file from standard in (stdin).
act like tar, and do not strip leading directories from source files.
alternative name for -no-strip.
act like cpio, and read files from standard in (stdin).
like -cpiostyle, but filenames are null terminated.
select COMP compression. Compressors available: gzip (default), lzo, lz4, xz, zstd, lzma.
set data block to BLOCK_SIZE. Default 128 Kbytes. Optionally a suffix of K or M can be given to specify Kbytes or Mbytes respectively.
build filesystems that are reproducible (default).
build filesystems that are not reproducible.
set filesystem creation timestamp to TIME, which is an unsigned 32-bit int indicating seconds since the epoch (1970-01-01).
synonym for mkfs-time.
set all file timestamps to TIME, which is an unsigned 32-bit int indicating seconds since the epoch (1970-01-01).
don't make filesystem exportable via NFS (-tar default).
make filesystem exportable via NFS (default).
don't detect sparse files.
don't store extended attributes.
store extended attributes (default).
do not compress inode table.
do not compress the uid/gid table (implied by -noI).
do not compress data blocks.
do not compress fragment blocks.
do not compress extended attributes.
don't pack tail ends into fragments (default).
pack tail ends into fragments.
do not use fragments.
use fragment blocks for files larger than block size.
do not perform duplicate checking.
do not hardlink files, instead store duplicates.
make all files owned by root.
set root directory time to TIME.
set root directory permissions to octal MODE.
set root directory owner to UID.
set root directory group to GID.
set all file uids to UID.
set all file gids to GID.
if one source directory is specified, create a root directory containing that directory, rather than the contents of the directory.
evaluate EXPRESSION on every file, and execute ACTION if it returns TRUE.
as above, but log expression evaluation results and actions performed.
as above, but only log expressions which return TRUE.
as above, but only log expressions which return FALSE.
as action, but read actions from FILE.
as -log-action, but read actions from FILE.
as -true-action, but read actions from FILE.
as -false-action, but read actions from FILE.

Filesystem filter options:

Add pseudo file definition. The definition should be quoted.
Add list of pseudo file definitions. Pseudo file definitions in pseudo-files should not be quoted.
sort files according to priorities in SORT_FILE. One file or dir with priority per line. Priority -32768 to 32767, default priority 0.
list of exclude dirs/files. One per line.
Allow extended shell wildcards (globbing) to be used in exclude dirs/files.
Allow POSIX regular expressions to be used in exclude dirs/files.
Do not cross filesystem boundaries when scanning sources.

Filesystem append options:

do not append to existing filesystem.
when appending source files/directories, make the original root become a subdirectory in the new root called NAME, rather than adding the new source items to the original root.

Mksquashfs runtime options:

print version, licence and copyright message.
treat normally ignored errors as fatal.
recover filesystem data using recovery file NAME.
don't generate a recovery file.
use NAME as the directory to store the recovery file.
no verbose output.
print files written to filesystem.
don't display the progress bar.
display progress bar when using the -info option.
throttle the I/O input rate by the given percentage. This can be used to reduce the I/O and CPU consumption of Mksquashfs.
limit the I/O input rate to the given percentage. This can be used to reduce the I/O and CPU consumption of Mksquashfs (alternative to -throttle).
Use NUMBER processors. By default will use number of processors available.
Use SIZE physical memory. Optionally a suffix of K, M or G can be given to specify Kbytes, Mbytes or Gbytes respectively.

Expert options (these may make the filesystem unmountable):

do not pad filesystem to a multiple of 4K.
Skip OFFSET bytes at the beginning of FILESYSTEM. Optionally a suffix of K, M or G can be given to specify Kbytes, Mbytes or Gbytes respectively. Default 0 bytes.
synonym for -offset.

Miscellaneous options:

alternative name for -all-root.
alternative name for -noI.
alternative name for -noId.
alternative name for -noD.
alternative name for -noF.
alternative name for -noX.
output this options text to stdout.
output this options text to stdout.
print compressor options for selected compressor.

PSEUDO FILE DEFINITION FORMAT

create a directory.
modify filename.
create a block device.
create a character device.
create file from stdout of command.
create a symbolic link.
create a socket (s) or FIFO (f).
create a hard-link to linkname.
same, but link to pseudo file.
create a directory with timestamp time.
modify a file with timestamp time.
create block device with timestamp time.
create char device with timestamp time.
create file with timestamp time.
create symlink with timestamp time.
create socket/fifo with timestamp time.

COMPRESSORS AVAILABLE AND COMPRESSOR SPECIFIC OPTIONS

gzip (default):

COMPRESSION-LEVEL should be 1 .. 9 (default 9).
WINDOW-SIZE should be 8 .. 15 (default 15).
Compress using strategy1,strategy2,...,strategyN in turn and choose the best compression. Available strategies: default, filtered, huffman_only, run_length_encoded and fixed.

lzo:

Where ALGORITHM is one of: lzo1x_1, lzo1x_1_11, lzo1x_1_12, lzo1x_1_15, lzo1x_999 (default).
COMPRESSION-LEVEL should be 1 .. 9 (default 8) Only applies to lzo1x_999 algorithm.

lz4:

Compress using LZ4 High Compression.

xz:

Compress using filter1,filter2,...,filterN in turn (in addition to no filter), and choose the best compression. Available filters: x86, arm, armthumb, powerpc, sparc, ia64.
Use DICT-SIZE as the XZ dictionary size. The dictionary size can be specified as a percentage of the block size, or as an absolute value. The dictionary size must be less than or equal to the block size and 8192 bytes or larger. It must also be storable in the xz header as either 2^n or as 2^n+2^(n+1). Example dict-sizes are 75%, 50%, 37.5%, 25%, or 32K, 16K, 8K etc.

zstd:

COMPRESSION-LEVEL should be 1 .. 22 (default 15).

lzma:

(no options) (deprecated - no kernel support)

ENVIRONMENT

If set, this is used as the filesystem creation timestamp. Also any file timestamps which are after SOURCE_DATE_EPOCH will be clamped to SOURCE_DATE_EPOCH. See https://reproducible-builds.org/docs/source-date-epoch/ for more information.

EXAMPLES

Create a Squashfs filesystem from the contents of DIRECTORY, writing the output to IMAGE.SQSH. Mksquashfs will use the default compressor (normally gzip), and block size of 128 Kbytes.
Create a Squashfs filesystem containing DIRECTORY and FILE1 and FILE2. If multiple sources are specified on the command line they will be combined into a single directory.
Use a block size of 1 Mbyte and Zstandard compression to create the filesystem.
Exclude file1 and file2 from DIRECTORY when creating filesystem. No wildcard matching of files.
Exclude anything in DIRECTORY which matches the wildcard pattern "*.gz".
Exclude files which match the wildcard pattern "*.gz" anywhere within DIRECTORY and its sub-directories. The initial "..." indicates the wildcard pattern is "non-anchored" and will match anywhere.

Note: when passing wildcarded names to Mksquashfs, they should be quoted (as in the above examples), to ensure that they are not processed by the shell.

Using pseudo file definitions

Create a directory called "build_dir" in the output filesystem.
Create a reference called "version.txt" to a file outside DIRECTORY, which acts as if the file "/tmp/build/version" was copied or hard-linked into DIRECTORY before calling Mksquashfs.
Create a file called "date.txt" which holds the output (stdout) from running the "date" command.
As above, but, showing that filenames can have spaces, if they are quoted. The quotes need to be blackslashed to protect them from the shell.
Create a file containing the contents of partition /dev/sda1". Ordinarily Mksquashfs given a device, fifo, or named socket will place that special file within the Squashfs filesystem, the above allows input from these special files to be captured and placed in the Squashfs filesystem. Note there are no other sources than the pseudo file, and so the command line source is "-". If there are no other sources than pseudo files, the root (/) directory must be defined too, as seen in this example.

Note: pseudo file definitions should be quoted (as in the above examples), to ensure that they are passed to Mksquashfs as a single argument, and to ensure that they are not processed by the shell.

Using Actions to not compress, change attributes etc.

Specify that any files matching the wildcards "*.jpg" and "*.mpg" should not be compressed. Additionally, it also specifies any files matching the wildcard "*.img" and are larger than 1 Gigabyte should be uncompressed too. This shows test operators can be combined with logical expressions.
If any files within DIRECTORY are not readable by "others", then make them readable by others in the Squashfs filesystem.
As previous, match on any files which are not readable by "others", but, in this case change the owner of the file to "phillip" in the Squashfs filesystem.
Delete any symbolic link within DIRECTORY which points outside of DIRECTORY, i.e. will be unresolvable in the Squashfs filesystem.
Create a Squashfs filesystem containing the two top most levels (contents of DIRECTORY and immediate sub-directories), and exclude anything at level 3 or below.

Note: actions should be quoted (as in the above examples), to ensure that they are passed to Mksquashfs as a single argument, and to ensure that they are not processed by the shell.

AUTHOR

Written by Phillip Lougher <phillip@squashfs.org.uk>

COPYRIGHT

Copyright © 2022 Phillip Lougher <phillip@squashfs.org.uk>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

SEE ALSO

unsquashfs(1), sqfstar(1), sqfscat(1)

The README for the Squash-tools 4.5.1 release, describing the new features can be read here https://github.com/plougher/squashfs-tools/blob/master/README-4.5.1

The Squashfs-tools USAGE guide can be read here https://github.com/plougher/squashfs-tools/blob/master/USAGE

The ACTIONS-README file describing how to use the new actions feature can be read here https://github.com/plougher/squashfs-tools/blob/master/ACTIONS-README

March 2022 mksquashfs version 4.5.1