[Name]
mksquashfs - tool to create and append to squashfs filesystems

[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.

[Examples]
.TP
mksquashfs DIRECTORY IMAGE.SQFS
Create a Squashfs filesystem from the contents of DIRECTORY, writing the output
to IMAGE.SQFS.  Mksquashfs will use the default compressor (normally gzip), and
a block size of 128 Kbytes.
.TP
mksquashfs DIRECTORY FILE1 FILE2 IMAGE.SQFS
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.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -b 1M -comp zstd
Use a block size of 1 Mbyte and Zstandard compression to create the filesystem. 
.TP
mksquashfs DIRECTORY IMAGE.SQFS -all-time now
Set all file and directory timestamps to "now" (current time) in the filesystem.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -force-uid phillip -force-gid phillip
Make all files and directories in the filesystem owned by "phillip".
.TP
mksquashfs DIRECTORY IMAGE.SQFS -force-file-mode ugo+r,go-w
Make all files readable by everyone, but only writable by user, all other
permission bits are unaffected.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -e file1 file2
Exclude file1 and file2 from DIRECTORY when creating filesystem.  No wildcard
matching of files.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -wildcards -e "*.gz"
Exclude anything in DIRECTORY which matches the wildcard pattern "*.gz".
.TP
mksquashfs DIRECTORY IMAGE.SQFS -wildcards -e "... *.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.
.PP
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.

.SS Using pseudo file definitions
.TP
mksquashfs DIRECTORY IMAGE.SQFS -p "build_dir d 0644 0 0"
Create a directory called "build_dir" in the output filesystem.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -p "version.txt l /tmp/build/version"
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.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -p "date.txt f 0644 0 0 date"
Create a file called "date.txt" which holds the output (stdout) from running
the "date" command.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -p "\\"hello world\\" f 0644 0 0 date"
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.
.TP
mksquashfs - IMAGE.SQFS -p "input f 0644 root root dd if=/dev/sda1 bs=1024" -p "/ d 0644 0 0"
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.
.TP
unsquashfs -pf - IMAGE.SQFS | mksquashfs - NEW.SQFS -pf -
Transcode IMAGE.SQFS to NEW.SQFS by piping the pseudo file output from
Unsquashfs to Mksquashfs using stdout and stdin.  This can convert from
earlier Squashfs filesystems or change compression algorithm, block size etc.
without needing to unpack into an intermediate directory or file.
.PP
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.

.SS Using extended attribute options
.TP
mksquashfs DIRECTORY IMAGE.SQFS -no-xattrs
Do not store any extended attributes in the Squashfs filesystem.  Any extended
attributes in the source files will be ignored.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -xattrs-include "^user."
Filter the extended attributes in the source files, and only store extended
attributes in the user namespace in the Squashfs filesystem.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -xattrs-exclude "^user."
Filter the extended attributes in the source files, and don't store any
extended attributes in the user namespace in the Squashfs filesystem.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -xattrs-add "user.comment=hello world"
Add the extended attribute called "user.comment" with the content "hello world"
to all files and directories in the Squashfs filesystem.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -xattrs-add "user.comment=0thello world\\012"
Add the extended attribute called "user.comment" to all files and directories,
but in this case the contents of the extended attribute will be "hello world"
with a trailing newline character (012 octal).
.TP
mksquashfs DIRECTORY IMAGE.SQFS -xattrs-add "user.comment=0saGVsbG8gd29ybGQ="
Add the extended attribute called "user.comment" to all files and directories,
where the value is given in base64 encoding, representing "hello world".
.TP
mksquashfs DIRECTORY IMAGE.SQFS -action "-xattrs-include(^user.) @ type(f)"
Filter the extended attributes but only in regular files (type f), and only
store extended attributes in the user namespace.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -p "hello_world x user.comment=0tsalve mundi\\012"
Add the extended attribute called "user.comment" to the file called
"hello_world", with the contents of the extended attribute being "salve mundi"
with a trailing newline character (012 octal).

.SS Using Actions to not compress, change attributes etc.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -action "uncompressed @ (name(*.jpg) || name(*.mpg) ) || (name(*.img) && filesize(+1G))"
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.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -action "chmod(o+r)@! perm(o+r)"
If any files within DIRECTORY are not readable by "others", then make them
readable by others in the Squashfs filesystem.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -action "uid(phillip)@! perm(o+r)"
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.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -action "prune @ type(l) && ! exists"
Delete any symbolic link within DIRECTORY which points outside of DIRECTORY,
i.e. will be unresolvable in the Squashfs filesystem.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -action "exclude @ depth(3)"
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.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -action "-xattrs-include(^user.) @ type(f)"
Filter the extended attributes but only in regular files (type f), and only
store extended attributes in the user namespace.
.PP
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.
