MKSQUASHFS(1)
๐ธ mksquashfs โ the girlies' guide to squishing filesystems ๐ธ
okay so this is the manual page for mksquashfs, from the User Commands section of the manual (section 1, iykyk). she's long, she's powerful, she's giving main character energy. let's get into it bestie ๐ซถ
โจ NAME โจ
mksquashfs โ the tool that creates squashfs filesystems and appends to them. yes bestie, both. she does it all ๐
โจ SYNOPSIS โจ
mksquashfs source1 source2 ... FILESYSTEM [OPTIONS] [-e list of exclude
dirs/files]
โจ DESCRIPTION โจ
so Squashfs is a highly compressed read-only filesystem for Linux ๐. she compresses files, inodes and directories using either gzip/xz/lzo/lz4/zstd compression. the inodes in the system are tiny tiny tiny and every block is packed to minimise data overhead. block sizes bigger than 4K are supported up to a maximum of 1Mbytes โ and the default block size is 128K โจ
Squashfs is intended for:
- general read-only filesystem use
- archival use (like, the cases where you'd reach for a
.tar.gzfile, fr fr) - constrained block device / memory systems (embedded systems bestie ๐) where low overhead is the whole vibe
โจ OPTIONS โจ
๐ธ Filesystem compression options:
-b BLOCK-SIZEโ set the data block toBLOCK-SIZE. default is 128 Kbytes. you can optionally slap a suffix on it:K,KB,KbytesorM,MB,Mbytesto specify Kbytes or Mbytes respectively โจ-comp COMPโ pick yourCOMPcompression. run-help-comp COMPto get the compressor options forCOMP, orALLfor every single compressor. the compressors available are:gzip(default bestie ๐),lzo,lz4,xz,zstd,lzma.-noIโ do not compress the inode table.-noIdโ do not compress the uid/gid table (this one is implied by-noI, so she comes along for the ride).-noDโ do not compress data blocks.-noFโ do not compress fragment blocks.-noXโ do not compress extended attributes.-no-compressionโ do not compress any of the data or metadata. this is equivalent to specifying-noI -noD -noFand-noXall at once. yeah, she's the bundle deal ๐
๐ Filesystem build options:
-tarโ read an uncompressed tar file from standard in (stdin).-no-stripโ act liketar, and do not strip leading directories from source files.-tarstyleโ alternative name for-no-strip.-cpiostyleโ act likecpio, and read file pathnames from standard in (stdin).-cpiostyle0โ like-cpiostyle, but filenames are null terminated. can be used with thefind -print0action.-no-exportsโ do not make the filesystem exportable via NFS (-tardefault).-exportsโ make the filesystem exportable via NFS (default).-no-sparseโ do not detect sparse files.-no-tailendsโ do not pack tail ends into fragments (default).-tailendsโ pack tail ends into fragments.-no-fragmentsโ do not use fragments.-no-duplicatesโ do not perform duplicate checking.-no-hardlinksโ do not hardlink files, instead store duplicates.-keep-as-directoryโ if one source directory is specified, create a root directory containing that directory, rather than the contents of the directory.
๐ฆ Filesystem time options:
-mkfs-time TIMEโ set the filesystem creation timestamp toTIME.TIMEcan be"inode", which means use the latest inode timestamp, an unsigned 32-bit int indicating seconds since the epoch (1970-01-01), or a string value which is passed to the"date"command to parse. any string value which thedatecommand recognises can be used, such as"now","last week", or"Wed Feb 15 21:02:39 GMT 2023".-inode-time TIMEโ set all file and directory timestamps toTIME.TIMEcan be"inode", which means use the latest inode timestamp, an unsigned 32-bit int indicating seconds since the epoch (1970-01-01), or a string value which is passed to the"date"command to parse. any string value which thedatecommand recognises can be used, such as"now","last week", or"Wed Feb 15 21:02:39 GMT 2025". โ ๏ธ this option sets and overrides the-root-timeoption.-root-time TIMEโ set the root directory time toTIME.TIMEcan be"inode", which means use the latest inode timestamp, an unsigned 32-bit int indicating seconds since the epoch (1970-01-01), or a string value which is passed to the"date"command to parse. any string value which thedatecommand recognises can be used, such as"now","last week", or"Wed Feb 15 21:02:39 GMT 2025".-reproโ build a reproducible filesystem image. this is equivalent to-mkfs-time inode, which achieves reproducibility by setting the filesystem build time to the latest inode timestamp. obviously the image won't be reproducible if the timestamps or content changes, bestie โ that's just the math ๐-repro-time TIMEโ build a reproducible filesystem image. this is equivalent to specifying-mkfs-time TIMEand-inode-time TIME, which achieves reproducibility by setting all timestamps toTIME. this option can be used in cases where timestamps may change, and where-reprocannot be used for this reason.
๐ Filesystem permissions options:
-all-rootโ make all files and directories owned by root. periodt.-root-mode MODEโ set root directory permissions toMODE.MODEcan be symbolic or octal (see section Symbolic mode specification). default root mode isugo=rwxor0777octal.-root-uid USERโ set the root directory owner to specifiedUSER.USERcan be either an integer uid or a user name.-root-gid GROUPโ set the root directory group to specifiedGROUP.GROUPcan be either an integer gid or a group name.-force-file-mode MODEโ set all file (non-directory) permissions toMODE.MODEcan be symbolic or octal (see section Symbolic mode specification).-force-dir-mode MODEโ set all directory permissions toMODE.MODEcan be symbolic or octal (see section Symbolic mode specification).-force-uid USERโ set all file and directory uids to specifiedUSER.USERcan be either an integer uid or a user name.-force-gid GROUPโ set all file and directory gids to specifiedGROUP.GROUPcan be either an integer gid or a group name.-uid-gid-offset VALUEโ offset all uid and gids by specifiedVALUE.VALUEshould be a positive integer.
๐ง Filesystem pseudo options:
-p PSEUDO-DEFINITIONโ add pseudo file definition. the definition should be quoted. see section "Pseudo file definition format" for format details.-pd "d mode uid gid"โ specify a default pseudo directory which will be used in pseudo definitions if a directory in the pathname does not exist. this also allows pseudo definitions to be specified without specifying all the directories in the pathname. the definition should be quoted โจ-pd "D time mode uid gid"โ specify a default pseudo directory which will be used in pseudo definitions if a directory in the pathname does not exist. theDtype also allows a timestamp to be specified in addition tomode,uidandgid.-pf PSEUDO-FILEโ add list of pseudo file definitions fromPSEUDO-FILE, use-forstdin. pseudo file definitions should not be quoted.-pseudo-overrideโ make pseudo file uids and gids override the-all-root,-force-uidand-force-gidoptions.
๐ Filesystem filter options:
-sort SORT-FILEโ sort files according to priorities inSORT-FILE. one file or dir with priority per line. priority-32768to32767, default priority0.-ef EXCLUDE-FILEโ list of exclude dirs/files. one per line.-wildcardsโ allow extended shell wildcards (globbing) to be used in exclude dirs/files.-regexโ allow POSIX regular expressions to be used in exclude dirs/files.-max-depth LEVELSโ descend at mostLEVELSof directories when scanning the filesystem.-one-file-systemโ do not cross filesystem boundaries. if a directory crosses the boundary, create an empty directory for each mount point. if a file crosses the boundary, ignore it.-one-file-system-xโ do not cross filesystem boundaries. like the-one-file-systemoption except directories are also ignored if they cross the boundary.
๐ Filesystem extended attribute (xattrs) options:
-no-xattrsโ do not store extended attributes.-xattrsโ store extended attributes (default).-xattrs-exclude REGEXโ exclude any xattr names matchingREGEX.REGEXis a POSIX regular expression, e.g.-xattrs-exclude '^user.'excludes xattrs from theusernamespace.-xattrs-include REGEXโ include any xattr names matchingREGEX.REGEXis a POSIX regular expression, e.g.-xattrs-include '^user.'includes xattrs from theusernamespace.-xattrs-add NAME=VALโ add the xattrNAMEwithVALto files. if it's a user xattr it will be added to regular files and directories (seeman 7 xattr). otherwise it will be added to all files.VALby default will be treated as binary (i.e. an uninterpreted byte sequence), but it can be prefixed with0s, where it will be treated as base64 encoded, or prefixed with0x, wherevalwill be treated as hexidecimal. additionally it can be prefixed with0twhere this encoding is similar to binary encoding, except backslashes are specially treated, and a backslash followed by 3 octal digits can be used to encode any ASCII character, which obviously can be used to encode control codes. the option can be repeated multiple times to add multiple xattrs ๐
๐ Mksquashfs runtime options:
-versionโ print version, licence and copyright message.-exit-on-errorโ treat normally ignored errors as fatal. ๐-quietโ no verbose output.-infoโ print files written to the filesystem tostdout. this automatically disables the progress bar. see-info-fileto output to file without disabling the progress bar.-info-file FILEโ print files written to the filesystem to fileFILE. this does not disable the progress bar.-no-progressโ do not display the progress bar.-progressโ display the progress bar when using the-infooption.-percentageโ display a percentage rather than the full progress bar. can be used withdialog --gaugeetc.-throttle PERCENTAGEโ throttle the I/O input rate by the givenPERCENTAGE. this can be used to reduce the I/O and CPU consumption of Mksquashfs.-limit PERCENTAGEโ limit the I/O input rate to the givenPERCENTAGE. this can be used to reduce the I/O and CPU consumption of Mksquashfs (alternative to-throttle).-processors NUMBERโ useNUMBERprocessors. by default will use the number of processors available. โจ-mem SIZEโ useSIZEphysical memory for caches, bestie. Slap aK,MorGon the end to say Kbytes, Mbytes or Gbytes respectively โจ-mem-percent PERCENTโ usePERCENTof physical memory for caches instead. Default is25%๐-mem-defaultโ just print the default memory usage in Mbytes and dip.-single-readerโ read files with a single thread. This reads files sequentially from the source(s), one at a time, no chaos ๐ธ-small-readers Nโ useNthreads to read small files (files less than a block size) in parallel from the source(s). Default is4๐ฆ-block-readers Nโ useNthreads to read block files (files a block or larger in size) in parallel from the source(s). Default is4๐ฆ-overcommit PERCENTโ letPERCENTmore threads run in parallel than there are available processors. Doing this may increase CPU utilisation. Default is0%, because normally overcommiting reduces performance due to trashing. Heads up: the percentage value is at the granularity of the number of processors โ e.g.4processors have a percentage granularity of25%, and20processors have a percentage granularity of5%. Math is mathing ๐ฅ
๐ Filesystem append options ๐
-noappendโ do not append to an existing filesystem. Fresh start energy โจ-root-becomes NAMEโ when appending source files/directories, make the original root become a subdirectory in the new root calledNAME, rather than adding the new source items to the original root.-no-recoveryโ do not generate a recovery file.-recovery-path NAMEโ useNAMEas the directory to store the recovery file.-recover NAMEโ recover filesystem data using recovery fileNAME.
๐ Filesystem actions options ๐
-action ACTION@EXPRESSIONโ evaluateEXPRESSIONon every file and directory, and executeACTIONif it returnsTRUE. It's giving conditional, iykyk ๐-log-action ACTION@EXPRESSIONโ same as-action, but it also logs expression evaluation results and the actions performed ๐-true-action ACTION@EXPRESSIONโ same as-action, but only log expressions which returnTRUE.-false-action ACTION@EXPRESSIONโ same as-action, but only log expressions which returnFALSE.-action-file FILEโ same asaction, but read actions fromFILE.-log-action-file FILEโ same as-log-action, but read actions fromFILE.-true-action-file FILEโ same as-true-action, but read actions fromFILE.-false-action-file FILEโ same as-false-action, but read actions fromFILE.
๐ง Tar file only options ๐ง
These ones are only for when you're feeding Mksquashfs a tar file, bestie ๐
-default-mode MODEโ tar files often do not store permissions for intermediate directories. This option sets the default directory permissions toMODE.MODEcan be symbolic or octal (see the section Symbolic mode specification). Default mode isu=rwx,go=rxor0755octal. This also sets the root directory mode ๐-default-uid VALUEโ tar files often do not store uids for intermediate directories. This option sets the default directory owner toVALUE, rather than the user running Mksquashfs.VALUEcan be either an integer uid or a user name. This also sets the root directory uid.-default-gid VALUEโ tar files often do not store gids for intermediate directories. This option sets the default directory group toVALUE, rather than the group of the user running Mksquashfs.VALUEcan be either an integer uid or a group name. This also sets the root directory gid.-ignore-zerosโ allow tar files to be concatenated together and fed to Mksquashfs. Normally a tarfile has two consecutive512byte blocks filled with zeros which means EOF, and Mksquashfs will stop reading after the first tar file on encountering them. This option makes Mksquashfs ignore the zero filled blocks ๐-numeric-ownerโ use the numeric uid and gid in the tarfile rather than the user name or group name. This is useful where the user name or group name maps to a different uid or gid on the system where Mksquashfs is being run, and this remapping behaviour is not wanted.
๐ Expert options (these may make the filesystem unmountable) ๐
Okay so listen. Read the heading again. Unmountable. These are main character options with main character consequences, no cap ๐ญ
-streamโ output the filesystem toSTDOUTrather than to a file. This allows the output to be piped to another program or elsewhere withssh. The resultant streamed Squashfs filesystem will not be a normal Squashfs filesystem because the super block will be at the end of the filesystem. But it can be fixed up afterwards with the-fixoption, and Unsquashfs 4.7.3 and later can read streamed unfixed up filesystems directly. Use-for the outputFILESYSTEMon the command line. Duplicate detection is disabled using the-streamoption ๐ซถ-fix FILESYSTEMโ fixFILESYSTEMgenerated using the-streamoption.-nopadโ do not pad filesystem to a multiple of4K.-offset OFFSETโ skipOFFSETbytes at the beginning ofFILESYSTEM. Optionally a suffix ofK,MorGcan be given to specify Kbytes, Mbytes or Gbytes respectively. Default is0bytes.-o OFFSETโ synonym for-offset.
๐ Help options ๐
-helpโ print help summary information to pager (or stdout if not a terminal).-help-option REGEXโ print the help information for options matchingREGEXto pager (or stdout if not a terminal).-help-section SECTIONโ print the help information for sectionSECTIONto pager (or stdout if not a terminal). IfSECTIONdoes not exactly match a section name, it is treated as a regular expression, and all section names that match are displayed. Use"list"as section name to get a list of sections and their names ๐-help-comp COMPโ print compressor options for compressorCOMP. Use"list"to get a list of available compressors, and"all"to get the compressor options for all the compressors.-help-allโ print help information for all Mksquashfs options and sections to pager (or stdout if not a terminal).-Xhelpโ print compressor options for selected compressor.-hโ shorthand alternative to-help.-ho REGEXโ shorthand alternative to-help-option.-hs SECTIONโ shorthand alternative to-help-section.-haโ shorthand alternative to-help-all.-no-pagerโ do not use a pager to output help information.-cols WIDTHโ useWIDTHcolumns to output help information. Useful if output is not to a terminal.
โจ Miscellaneous options โจ
-fstime TIMEโ alternative name for-mkfs-time.-always-use-fragmentsโ alternative name for-tailends.-root-ownedโ alternative name for-all-root.-noInodeCompressionโ alternative name for-noI.-noIdTableCompressionโ alternative name for-noId.-noDataCompressionโ alternative name for-noD.-noFragmentCompressionโ alternative name for-noF.-noXattrCompressionโ alternative name for-noX.-pseudo-dirโ alternative name for-pd.
๐ธ PSEUDO FILE DEFINITION FORMAT ๐ธ
Okay bestie, this is the part where you just build files out of thin air with -p. Obsessed, honestly ๐ซถ
-p "filename d mode uid gid"โ create a directory.-p "filename m mode uid gid"โ modifyfilename.-p "filename b mode uid gid major minor"โ create a block device.-p "filename c mode uid gid major minor"โ create a character device.-p "filename f mode uid gid command"โ create file from stdout ofcommand.-p "filename s mode uid gid symlink"โ create a symbolic link.-p "filename i mode uid gid [s|f]"โ create a socket (s) or FIFO (f).-p "filename x name=val"โ create an extended attribute.-p "filename h linkname"โ create a hard-link tolinkname, follows symlinks.-p "filename l linkname"โ create a hard-link tolinkname.-p "filename L pseudo_filename"โ same, but link to pseudo file.-p "filename D time mode uid gid"โ create a directory with timestamptime.-p "filename M time mode uid gid"โ modify a file with timestamptime.-p "filename B time mode uid gid major minor"โ create block device with timestamptime.-p "filename C time mode uid gid major minor"โ create char device with timestamptime.-p "filename F time mode uid gid command"โ create file with timestamptime.-p "filename S time mode uid gid symlink"โ create symlink with timestamptime.-p "filename I time mode uid gid [s|f]"โ create socket/fifo with timestamptime.
๐ฆ SYMBOLIC MODE SPECIFICATION ๐ฆ
The symbolic mode is of the format:
[ugoa]*[[+-=]PERMS]+
and PERMS = [rwxXst]+ or [ugo], and the sequence can be repeated separated with commas. It's giving chmod but make it fashion ๐
A combination of the letters ugoa specify which permission bits will be affected: u means user, g means group, o means other, and a means all or ugo โจ
The next letter is +, - or =. The letter + means add to the existing permission bits, - means remove the bits from the existing permission bits, and = means set the permission bits.
The permission bits (PERMS) are a combination of [rwxXst] which sets/adds/removes those bits for the specified ugoa combination: r means read, w means write, and x means execute for files or search for directories. X has a special meaning โ if the file is a directory it is equivalent to x or search, but if it is a non-directory, it only takes effect if execute is already set for user, group or other. The s flag sets user or group ID on execution, and the t flag on a directory sets restricted deletion, or historically made the file sticky if a non-directory ๐
The permission bits can also be u, g or o, which takes the permission bits from the user, group or other of the file respectively.
โญ EXIT STATUS โญ
0โ Mksquashfs successfully generated a filesystem. Slay ๐1โ Fatal errors occurred, Mksquashfs aborted and did not generate a filesystem (or update if appending). Devastating, honestly ๐ญ
๐ gzip (default) ๐
The og. The one you get if you don't say anything. Bestie's default fave.
-Xcompression-level COMPRESSION-LEVELโ COMPRESSION-LEVEL should be1 .. 9(default9).-Xwindow-size WINDOW-SIZEโ WINDOW-SIZE should be8 .. 15(default15).-Xstrategy strategy1,strategy2,...,strategyNโ compress usingstrategy1,strategy2,...,strategyNin turn and keep whichever one slayed the hardest (best compression). Available strategies:default,filtered,huffman_only,run_length_encodedandfixed.
๐ฆ lzo ๐ฆ
-Xalgorithm ALGORITHMโ where ALGORITHM is one of:lzo1x_1,lzo1x_1_11,lzo1x_1_12,lzo1x_1_15,lzo1x_999(default).-Xcompression-level COMPRESSION-LEVELโ COMPRESSION-LEVEL should be1 .. 9(default8). Lowkey only applies to thelzo1x_999algorithm, so don't waste your energy otherwise.
โก lz4 โก
-Xhcโ compress using LZ4 High Compression. That's it. That's the whole option. Iconic minimalism.
๐ xz ๐
-Xbcj filter1,filter2,...,filterNโ compress usingfilter1,filter2,...,filterNin turn (on top of no filter at all), then choose the best compression. Available filters:x86,arm,armthumb,arm64,powerpc,sparc,ia64,riscv.-Xdict-size DICT-SIZEโ use DICT-SIZE as the XZ dictionary size. You can give the dictionary size as a percentage of the block size, or as an absolute value. Rules, bestie, there are rules: the dictionary size must be less than or equal to the block size and 8192 bytes or larger. It also has to be storable in the xz header as either2^nor as2^n+2^(n+1). Example dict-sizes are75%,50%,37.5%,25%, or32K,16K,8Ketc.
๐ zstd ๐
-Xcompression-level COMPRESSION-LEVELโ COMPRESSION-LEVEL should be-131072 .. -1or1 .. 22(default15). The negative compression levels are the zstd--fastoption energy.
๐ง lzma ๐ง
(no options) โ deprecated, no kernel support. Not me showing up with zero options and a whole "nobody supports me" arc ๐. It's giving legacy. Just don't.
๐ธ ENVIRONMENT ๐ธ
Yes, this program reads the vibes of your environment. Respect them.
SQFS_CMDLINEโ if set, this is used as the directory to write the filesqfs_cmdline, which contains the command line arguments given to Mksquashfs. Each command line argument is wrapped in quotes so there's zero ambiguity when arguments contain spaces. If the file already exists, then the command line is appended to the file.SOURCE_DATE_EPOCHโ if set, this is used as the filesystem creation timestamp. Also, any file timestamps that are afterSOURCE_DATE_EPOCHwill be clamped toSOURCE_DATE_EPOCH. Seehttps://reproducible-builds.org/docs/source-date-epoch/for more info. (Reproducible builds besties, this one's for you ๐ซถ)PAGERโ if set, this is used as the name of the program used to display the help text. The value can be a simple command or a pathname. The default is/usr/bin/pager.
โจ EXAMPLES โจ
Time for the main character moment: actual commands you can copy.
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.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 get combined into a single directory. Friendship bracelet energy.mksquashfs DIRECTORY IMAGE.SQFS -b 1M -comp zstdโ use a block size of 1 Mbyte and Zstandard compression to create the filesystem.mksquashfs DIRECTORY IMAGE.SQFS -all-time nowโ set all file and directory timestamps to "now" (current time) in the filesystem.mksquashfs DIRECTORY IMAGE.SQFS -force-uid phillip -force-gid phillipโ make all files and directories in the filesystem owned by "phillip".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.mksquashfs DIRECTORY IMAGE.SQFS -e file1 file2โ excludefile1andfile2from DIRECTORY when creating the filesystem. No wildcard matching of files, so no sneaky pattern behaviour here.mksquashfs DIRECTORY IMAGE.SQFS -wildcards -e "*.gz"โ exclude anything in DIRECTORY which matches the wildcard pattern"*.gz".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.
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. Let the shell stay out of it, bestie.
๐ Using pseudo file definitions
mksquashfs DIRECTORY IMAGE.SQFS -p "build_dir d 0644 0 0"โ create a directory called"build_dir"in the output filesystem.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/versionwas copied or hard-linked into DIRECTORY before calling Mksquashfs.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 thedatecommand.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 backslashed to protect them from the shell.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.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. No middleman, no mess, we love to see it.
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 extended attribute options
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. They're simply not invited.mksquashfs DIRECTORY IMAGE.SQFS -xattrs-include "^user."โ filter the extended attributes in the source files, and only store extended attributes in theusernamespace in the Squashfs filesystem.mksquashfs DIRECTORY IMAGE.SQFS -xattrs-exclude "^user."โ filter the extended attributes in the source files, and don't store any extended attributes in theusernamespace in the Squashfs filesystem.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.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 (012octal).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".mksquashfs DIRECTORY IMAGE.SQFS -action "-xattrs-include(^user.) @ type(f)"โ filter the extended attributes but only in regular files (typef), and only store extended attributes in theusernamespace.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 (012octal).
๐ฅ Using Actions to not compress, change attributes etc.
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 1 Gigabyte or larger should be uncompressed too. This shows test operators can be combined with logical expressions. Logic gates but make it fashion.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.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.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. Broken-link girlies, you're getting pruned ๐.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.mksquashfs DIRECTORY IMAGE.SQFS -action "-xattrs-include(^user.) @ type(f)"โ filter the extended attributes but only in regular files (typef), and only store extended attributes in theusernamespace.
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>
(Yes, the actual legend who made this whole thing. Stan respectfully. ๐)
๐ COPYRIGHT ๐
okay bestie, legal era, we're doing it, stay with me ๐ซถ
Copyright ยฉ 2026 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. ๐ญ no promises bestie, that's literally the deal
fr fr though, that warranty bit is not a joke โ it's giving "you're on your own if it eats your filesystem", so read the license, it's right there.
๐ SEE ALSO ๐
the squad, the besties, the whole friend group โจ go read these too:
unsquashfs(1)โ the one that unpacks everything you just made ๐sqfstar(1)โ tar-flavoured icon behavior ๐sqfscat(1)โ cat but make it squashfs ๐
The README for the Squashfs-tools 4.7.5 release, describing the new features can be read here
https://github.com/plougher/squashfs-tools/blob/master/Documentation/4.7.5/README.md
The MKSQUASHFS usage guide can be read here
https://github.com/plougher/squashfs-tools/blob/master/Documentation/4.7.5/USAGE-MKSQUASHFS.md
The CHANGELOG for Squashfs tools can be read here
https://github.com/plougher/squashfs-tools/blob/master/CHANGES.md
The ACTIONS-README for the actions subsystem can be read here
https://github.com/plougher/squashfs-tools/blob/master/Documentation/4.7.5/ACTIONS-README.md
and that's a wrap on the whole page, bestie ๐ฆ you made it to the very end, main character energy fr ๐
tiny sign-off before you go: this whole thing is mksquashfs version 4.7.5, dated March 2026, and the manual page itself answers to the name MKSQUASHFS(1) ๐ธ
go squash something iconic, ily, bye ๐โจ
๐ฆ where this page comes from
- arch rolling: squashfs-tools 4.7.5-1 ยท GPL-2.0-or-later
- ubuntu resolute: squashfs-tools 1:4.7.5-1 ยท GPL-2.0-or-later
- ubuntu stonking: squashfs-tools 1:4.7.5-1 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms