1MKSQUASHFS(1)                    User Commands                   MKSQUASHFS(1)
2
3
4

NAME

6       mksquashfs - tool to create and append to squashfs filesystems
7

SYNOPSIS

9       mksquashfs  source1  source2  ...  FILESYSTEM [OPTIONS] [-e list of ex‐
10       clude dirs/files]
11

DESCRIPTION

13       Squashfs is a highly compressed read-only  filesystem  for  Linux.   It
14       uses  either  gzip/xz/lzo/lz4/zstd  compression to compress both files,
15       inodes and directories.  Inodes in the system are very  small  and  all
16       blocks  are  packed to minimise data overhead. Block sizes greater than
17       4K are supported up to a maximum of 1Mbytes (default block size 128K).
18
19       Squashfs is intended for general read-only filesystem use, for archival
20       use  (i.e.  in  cases  where  a  .tar.gz file may be used), and in con‐
21       strained block device/memory systems (e.g. embedded systems) where  low
22       overhead is needed.
23

OPTIONS

25   Filesystem build options:
26       -tar   read uncompressed tar file from standard in (stdin).
27
28       -no-strip
29              act  like  tar, and do not strip leading directories from source
30              files.
31
32       -tarstyle
33              alternative name for -no-strip.
34
35       -cpiostyle
36              act like cpio, and read files from standard in (stdin).
37
38       -cpiostyle0
39              like -cpiostyle, but filenames are null terminated.
40
41       -comp COMP
42              select COMP compression. Compressors available: gzip  (default),
43              lzo, lz4, xz, zstd, lzma.
44
45       -b BLOCK_SIZE
46              set  data block to BLOCK_SIZE.  Default 128 Kbytes. Optionally a
47              suffix of K or M can be given to specify Kbytes  or  Mbytes  re‐
48              spectively.
49
50       -reproducible
51              build filesystems that are reproducible (default).
52
53       -not-reproducible
54              build filesystems that are not reproducible.
55
56       -mkfs-time TIME
57              set  filesystem creation timestamp to TIME, which is an unsigned
58              32-bit int indicating seconds since the epoch (1970-01-01).
59
60       -fstime TIME
61              synonym for mkfs-time.
62
63       -all-time TIME
64              set all file timestamps to TIME, which is an unsigned 32-bit int
65              indicating seconds since the epoch (1970-01-01).
66
67       -no-exports
68              don't make filesystem exportable via NFS (-tar default).
69
70       -exports
71              make filesystem exportable via NFS (default).
72
73       -no-sparse
74              don't detect sparse files.
75
76       -no-xattrs
77              don't store extended attributes.
78
79       -xattrs
80              store extended attributes (default).
81
82       -noI   do not compress inode table.
83
84       -noId  do not compress the uid/gid table (implied by -noI).
85
86       -noD   do not compress data blocks.
87
88       -noF   do not compress fragment blocks.
89
90       -noX   do not compress extended attributes.
91
92       -no-tailends
93              don't pack tail ends into fragments (default).
94
95       -tailends
96              pack tail ends into fragments.
97
98       -no-fragments
99              do not use fragments.
100
101       -always-use-fragments
102              use fragment blocks for files larger than block size.
103
104       -no-duplicates
105              do not perform duplicate checking.
106
107       -no-hardlinks
108              do not hardlink files, instead store duplicates.
109
110       -all-root
111              make all files owned by root.
112
113       -root-time TIME
114              set root directory time to TIME.
115
116       -root-mode MODE
117              set root directory permissions to octal MODE.
118
119       -root-uid UID
120              set root directory owner to UID.
121
122       -root-gid GID
123              set root directory group to GID.
124
125       -force-uid UID
126              set all file uids to UID.
127
128       -force-gid GID
129              set all file gids to GID.
130
131       -keep-as-directory
132              if  one  source  directory is specified, create a root directory
133              containing that directory, rather than the contents of  the  di‐
134              rectory.
135
136       -action ACTION@EXPRESSION
137              evaluate  EXPRESSION on every file, and execute ACTION if it re‐
138              turns TRUE.
139
140       -log-action ACTION@EXPRESSION
141              as above, but log expression evaluation results and actions per‐
142              formed.
143
144       -true-action ACTION@EXPRESSION
145              as above, but only log expressions which return TRUE.
146
147       -false-action ACTION@EXPRESSION
148              as above, but only log expressions which return FALSE.
149
150       -action-file FILE
151              as action, but read actions from FILE.
152
153       -log-action-file FILE
154              as -log-action, but read actions from FILE.
155
156       -true-action-file FILE
157              as -true-action, but read actions from FILE.
158
159       -false-action-file FILE
160              as -false-action, but read actions from FILE.
161
162   Filesystem filter options:
163       -p PSEUDO-DEFINITION
164              Add pseudo file definition.  The definition should be quoted.
165
166       -pf PSEUDO-FILE
167              Add list of pseudo file definitions.  Pseudo file definitions in
168              pseudo-files should not be quoted.
169
170       -sort SORT_FILE
171              sort files according to priorities in SORT_FILE.   One  file  or
172              dir  with  priority per line.  Priority -32768 to 32767, default
173              priority 0.
174
175       -ef EXCLUDE_FILE
176              list of exclude dirs/files.  One per line.
177
178       -wildcards
179              Allow extended shell wildcards (globbing) to be used in  exclude
180              dirs/files.
181
182       -regex Allow   POSIX   regular   expressions  to  be  used  in  exclude
183              dirs/files.
184
185       -one-file-system
186              Do not cross filesystem boundaries when scanning sources.
187
188   Filesystem append options:
189       -noappend
190              do not append to existing filesystem.
191
192       -root-becomes NAME
193              when appending source files/directories, make the original  root
194              become  a  subdirectory in the new root called NAME, rather than
195              adding the new source items to the original root.
196
197   Mksquashfs runtime options:
198       -version
199              print version, licence and copyright message.
200
201       -exit-on-error
202              treat normally ignored errors as fatal.
203
204       -recover NAME
205              recover filesystem data using recovery file NAME.
206
207       -no-recovery
208              don't generate a recovery file.
209
210       -recovery-path NAME
211              use NAME as the directory to store the recovery file.
212
213       -quiet no verbose output.
214
215       -info  print files written to filesystem.
216
217       -no-progress
218              don't display the progress bar.
219
220       -progress
221              display progress bar when using the -info option.
222
223       -throttle PERCENTAGE
224              throttle the I/O input rate by the given percentage. This can be
225              used to reduce the I/O and CPU consumption of Mksquashfs.
226
227       -limit PERCENTAGE
228              limit  the  I/O  input rate to the given percentage. This can be
229              used to reduce the I/O and CPU consumption of Mksquashfs (alter‐
230              native to -throttle).
231
232       -processors NUMBER
233              Use NUMBER processors.  By default will use number of processors
234              available.
235
236       -mem SIZE
237              Use SIZE physical memory. Optionally a suffix of K, M or  G  can
238              be given to specify Kbytes, Mbytes or Gbytes respectively.
239
240   Expert options (these may make the filesystem unmountable):
241       -nopad do not pad filesystem to a multiple of 4K.
242
243       -offset OFFSET
244              Skip  OFFSET  bytes at the beginning of FILESYSTEM. Optionally a
245              suffix of K, M or G can be given to specify  Kbytes,  Mbytes  or
246              Gbytes respectively. Default 0 bytes.
247
248       -o OFFSET
249              synonym for -offset.
250
251   Miscellaneous options:
252       -root-owned
253              alternative name for -all-root.
254
255       -noInodeCompression
256              alternative name for -noI.
257
258       -noIdTableCompression
259              alternative name for -noId.
260
261       -noDataCompression
262              alternative name for -noD.
263
264       -noFragmentCompression
265              alternative name for -noF.
266
267       -noXattrCompression
268              alternative name for -noX.
269
270       -help  output this options text to stdout.
271
272       -h     output this options text to stdout.
273
274       -Xhelp print compressor options for selected compressor.
275

PSEUDO FILE DEFINITION FORMAT

277       -p "filename d mode uid gid"
278              create a directory.
279
280       -p "filename m mode uid gid"
281              modify filename.
282
283       -p "filename b mode uid gid major minor"
284              create a block device.
285
286       -p "filename c mode uid gid major minor"
287              create a character device.
288
289       -p "filename f mode uid gid command"
290              create file from stdout of command.
291
292       -p "filename s mode uid gid symlink"
293              create a symbolic link.
294
295       -p "filename i mode uid gid [s|f]"
296              create a socket (s) or FIFO (f).
297
298       -p "filename l linkname"
299              create a hard-link to linkname.
300
301       -p "filename L pseudo_filename"
302              same, but link to pseudo file.
303
304       -p "filename D time mode uid gid"
305              create a directory with timestamp time.
306
307       -p "filename M time mode uid gid"
308              modify a file with timestamp time.
309
310       -p "filename B time mode uid gid major minor"
311              create block device with timestamp time.
312
313       -p "filename C time mode uid gid major minor"
314              create char device with timestamp time.
315
316       -p "filename F time mode uid gid command"
317              create file with timestamp time.
318
319       -p "filename S time mode uid gid symlink"
320              create symlink with timestamp time.
321
322       -p "filename I time mode uid gid [s|f]"
323              create socket/fifo with timestamp time.
324

COMPRESSORS AVAILABLE AND COMPRESSOR SPECIFIC OPTIONS

326   gzip (default):
327       -Xcompression-level COMPRESSION-LEVEL
328              COMPRESSION-LEVEL should be 1 .. 9 (default 9).
329
330       -Xwindow-size WINDOW-SIZE
331              WINDOW-SIZE should be 8 .. 15 (default 15).
332
333       -Xstrategy strategy1,strategy2,...,strategyN
334              Compress  using  strategy1,strategy2,...,strategyN  in  turn and
335              choose the best compression. Available strategies: default, fil‐
336              tered, huffman_only, run_length_encoded and fixed.
337
338   lzo:
339       -Xalgorithm ALGORITHM
340              Where  ALGORITHM  is  one  of:  lzo1x_1, lzo1x_1_11, lzo1x_1_12,
341              lzo1x_1_15, lzo1x_999 (default).
342
343       -Xcompression-level COMPRESSION-LEVEL
344              COMPRESSION-LEVEL should be 1 .. 9 (default 8) Only  applies  to
345              lzo1x_999 algorithm.
346
347   lz4:
348       -Xhc   Compress using LZ4 High Compression.
349
350   xz:
351       -Xbcj filter1,filter2,...,filterN
352              Compress  using filter1,filter2,...,filterN in turn (in addition
353              to no filter), and choose the best compression.  Available  fil‐
354              ters: x86, arm, armthumb, powerpc, sparc, ia64.
355
356       -Xdict-size DICT-SIZE
357              Use  DICT-SIZE  as  the XZ dictionary size.  The dictionary size
358              can be specified as a percentage of the block size, or as an ab‐
359              solute value.  The dictionary size must be less than or equal to
360              the block size and 8192  bytes  or  larger.   It  must  also  be
361              storable in the xz header as either 2^n or as 2^n+2^(n+1). Exam‐
362              ple dict-sizes are 75%, 50%, 37.5%, 25%, or 32K, 16K, 8K etc.
363
364   zstd:
365       -Xcompression-level COMPRESSION-LEVEL
366              COMPRESSION-LEVEL should be 1 .. 22 (default 15).
367
368   lzma:
369              (no options) (deprecated - no kernel support)
370

ENVIRONMENT

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

EXAMPLES

379       mksquashfs DIRECTORY IMAGE.SQFS
380              Create  a  Squashfs  filesystem  from the contents of DIRECTORY,
381              writing the output to IMAGE.SQSH.  Mksquashfs will use  the  de‐
382              fault compressor (normally gzip), and block size of 128 Kbytes.
383
384       mksquashfs DIRECTORY FILE1 FILE2 IMAGE.SQFS
385              Create  a Squashfs filesystem containing DIRECTORY and FILE1 and
386              FILE2.  If multiple sources are specified on  the  command  line
387              they will be combined into a single directory.
388
389       mksquashfs DIRECTORY IMAGE.SQFS -b 1M -comp zstd
390              Use  a block size of 1 Mbyte and Zstandard compression to create
391              the filesystem.
392
393       mksquashfs DIRECTORY IMAGE.SQFS -e file1 file2
394              Exclude file1 and file2 from DIRECTORY when creating filesystem.
395              No wildcard matching of files.
396
397       mksquashfs DIRECTORY IMAGE.SQFS -wildcards -e "*.gz"
398              Exclude anything in DIRECTORY which matches the wildcard pattern
399              "*.gz".
400
401       mksquashfs DIRECTORY IMAGE.SQFS -wildcards -e "... *.gz"
402              Exclude files which match the wildcard pattern  "*.gz"  anywhere
403              within DIRECTORY and its sub-directories.  The initial "..." in‐
404              dicates the wildcard pattern is "non-anchored"  and  will  match
405              anywhere.
406
407       Note:  when  passing  wildcarded  names  to  Mksquashfs, they should be
408       quoted (as in the above examples), to ensure that  they  are  not  pro‐
409       cessed by the shell.
410
411
412   Using pseudo file definitions
413       mksquashfs DIRECTORY IMAGE.SQFS -p "build_dir d 0644 0 0"
414              Create a directory called "build_dir" in the output filesystem.
415
416       mksquashfs DIRECTORY IMAGE.SQFS -p "version.txt l /tmp/build/version"
417              Create a reference called "version.txt" to a file outside DIREC‐
418              TORY, which acts as if the file "/tmp/build/version" was  copied
419              or hard-linked into DIRECTORY before calling Mksquashfs.
420
421       mksquashfs DIRECTORY IMAGE.SQFS -p "date.txt f 0644 0 0 date"
422              Create  a file called "date.txt" which holds the output (stdout)
423              from running the "date" command.
424
425       mksquashfs DIRECTORY IMAGE.SQFS -p "\"hello world\" f 0644 0 0 date"
426              As above, but, showing that filenames can have spaces,  if  they
427              are  quoted.  The quotes need to be blackslashed to protect them
428              from the shell.
429
430       mksquashfs - IMAGE.SQFS -p "input f  0644  root  root  dd  if=/dev/sda1
431       bs=1024" -p "/ d 0644 0 0"
432              Create  a  file containing the contents of partition /dev/sda1".
433              Ordinarily Mksquashfs given a device, fifo, or named socket will
434              place  that  special  file  within  the Squashfs filesystem, the
435              above allows input from these special files to be  captured  and
436              placed  in  the  Squashfs  filesystem.   Note there are no other
437              sources than the pseudo file, and so the command line source  is
438              "-".   If there are no other sources than pseudo files, the root
439              (/) directory must be defined too, as seen in this example.
440
441       Note: pseudo file definitions should be quoted (as in the  above  exam‐
442       ples),  to  ensure that they are passed to Mksquashfs as a single argu‐
443       ment, and to ensure that they are not processed by the shell.
444
445   Using Actions to not compress, change attributes etc.
446       mksquashfs DIRECTORY IMAGE.SQSH -action "uncompressed @ (name(*.jpg) ||
447       name(*.mpg) ) || (name(*.img) && filesize(+1G))"
448              Specify  that  any  files  matching  the  wildcards  "*.jpg" and
449              "*.mpg" should not be compressed.  Additionally, it also  speci‐
450              fies any files matching the wildcard "*.img" and are larger than
451              1 Gigabyte should be uncompressed too.  This shows  test  opera‐
452              tors can be combined with logical expressions.
453
454       mksquashfs DIRECTORY IMAGE.SQSH -action "chmod(o+r)@! perm(o+r)"
455              If any files within DIRECTORY are not readable by "others", then
456              make them readable by others in the Squashfs filesystem.
457
458       mksquashfs DIRECTORY IMAGE.SQSH -action "uid(phillip)@! perm(o+r)"
459              As previous, match on any files which are not readable by  "oth‐
460              ers",  but,  in  this  case  change  the  owner  of  the file to
461              "phillip" in the Squashfs filesystem.
462
463       mksquashfs DIRECTORY IMAGE.SQSH -action "prune @ type(l) && ! exists"
464              Delete any symbolic link within DIRECTORY which  points  outside
465              of DIRECTORY, i.e. will be unresolvable in the Squashfs filesys‐
466              tem.
467
468       mksquashfs DIRECTORY IMAGE.SQSH -action "exclude @ depth(3)"
469              Create a Squashfs filesystem containing the two top most  levels
470              (contents  of  DIRECTORY and immediate sub-directories), and ex‐
471              clude anything at level 3 or below.
472
473       Note: actions should be quoted (as in the above  examples),  to  ensure
474       that  they are passed to Mksquashfs as a single argument, and to ensure
475       that they are not processed by the shell.
476

AUTHOR

478       Written by Phillip Lougher <phillip@squashfs.org.uk>
479
481       Copyright © 2022 Phillip Lougher <phillip@squashfs.org.uk>
482
483       This program is free software; you can redistribute it and/or modify it
484       under  the  terms of the GNU General Public License as published by the
485       Free Software Foundation; either version 2, or  (at  your  option)  any
486       later version.
487
488       This  program  is  distributed  in the hope that it will be useful, but
489       WITHOUT ANY  WARRANTY;  without  even  the  implied  warranty  of  MER‐
490       CHANTABILITY  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
491       Public License for more details.
492

SEE ALSO

494       unsquashfs(1), sqfstar(1), sqfscat(1)
495
496       The README for the Squash-tools 4.5.1 release, describing the new  fea‐
497       tures              can             be             read             here
498       https://github.com/plougher/squashfs-tools/blob/master/README-4.5.1
499
500       The    Squashfs-tools    USAGE    guide    can     be     read     here
501       https://github.com/plougher/squashfs-tools/blob/master/USAGE
502
503       The  ACTIONS-README  file describing how to use the new actions feature
504       can be read  here  https://github.com/plougher/squashfs-tools/blob/mas
505       ter/ACTIONS-README
506
507
508
509mksquashfs version 4.5.1          March 2022                     MKSQUASHFS(1)
Impressum