mksquashfs - Create or modify a Squash file system
mksquashfssource... dest [options] [-e list of exclude dirs/files] [-ef exclude_file]
A squashfs is a compressed read-only file system. Use the
mksquashfsprogram to create a new squashed file system, and to append new data to an existing squashed file system.
If a single source directory is specified (i.e.
mksquashfs sourceoutput_fs), the squashfs filesystem will consist of that directory, with the top-level root directory corresponding to the source directory.
If multiple source directories or files are specified,
mksquashfswill merge the specified sources into a single filesystem, with the root directory containing each of the source files/directories. The name of each directory entry will be the basename of the source path. If more than one source entry maps to the same name, the conflicts are named
xxx_2, etc. where
xxxis the original name.
destargument can either be a conventional file or a block device. If the file doesn't exist it will be created, if it does exist and a squashfs filesystem exists on it,
mksquashfswill append. The
-noappend option will write a new filesystem irrespective of whether an existing filesystem is present.
There are a large number of options that can be used to control the compression in
mksquashfs. By and large the defaults are the most optimum settings and should only be changed in exceptional circumstances !
-noFragmentCompression) can be used to force
mksquashfsto not compress inodes/directories, data and fragments respectively. Giving all options generates an uncompressed filesystem.
By default files in the generated filesystem inherit the UID and GID ownership of the original file. However,
mksquashfsprovides a number of options which can be used to override the ownership:
-root-owned(both do exactly the same thing) force all file uids/gids in the generated Squashfs filesystem to be
root. This allows root owned filesystems to be built without root access on the host machine.
-force-uid uidoption forces all files in the generated Squashfs filesystem to be owned by the specified
uid. The uid can be specified either by name (i.e.
root) or by number.
-force-gid gidoption forces all files in the generated Squashfs filesystem to be group owned by the specified
gid. The gid can be specified either by name (i.e.
root) or by number.
-efoptions allow files/directories to be specified which are excluded from the output filesystem. The
-eoption takes the exclude files/directories from the command line, the
-efoption takes the exlude files/directories from the specified exclude file, one file/directory per line. If an exclude file/directory is absolute (i.e. prefixed with
./) the entry is treated as absolute, however, if an exclude file/directory is relative, it is treated as being relative to each of the sources in turn, i.e.
mksquashfs /tmp/source1 source2 output_fs -e ex1 /tmp/source1/ex2 out/ex3Will generate exclude files
-efexclude options are usefully used in archiving the entire filesystem, where it is wished to avoid archiving
/proc, and the filesystem being generated, i.e.
mksquashfs / /tmp/root.sqsh -e proc /tmp/root.sqsh
-efoptions can be specified on the command line, and the
-efoption can be used in conjuction with the
-infooption displays the files/directories as they are compressed and added to the filesystem. The original uncompressed size of each file is printed, along with
if the file is a duplicate of a file in the filesystem.
-beoptions can be used to force
mksquashfsto generate a little endian or big endian filesystem. Normally
mksquashfswill generate a filesystem in the host byte order. Squashfs, for portability, will mount different ordered filesystems (i.e. it can mount big endian filesystems running on a little endian machine), but these options can be used for greater optimisation.
print version, licence and copyright message.
print files written to filesystem
set data block to
block_size. This can be either 4096, 8192, 16384, 32768 or 65536 bytes. Default is 65536 bytes
create a 2.0 filesystem
-noI or -noInodeCompression
do not compress inode table
do not compress data blocks
-noF or -noFragmentCompression
do not compress fragment blocks
do not use fragments: tells
mksquashfsto not generate fragment blocks, and rather generate a filesystem similar to a Squashfs 1.x filesystem. It will of course still be a Squashfs 2.0 filesystem but without fragments, and so it won't be mountable on a Squashfs 1.x system.
use fragment blocks for files larger than block size: tells
mksquashfsto always generate fragments for files irrespective of the file length. By default only small files less than the block size are packed into fragment blocks. The ends of files which do not fit fully into a block, are
NOTby default packed into fragments. To illustrate this, a 100K file has an initial 64K block and a 36K remainder. This 36K remainder is not packed into a fragment by default. This is because to do so leads to a 10 - 20% drop in sequential I/O performance, as a disk head seek is needed to seek to the initial file data and another disk seek is need to seek to the fragment block. Specify this option if you want file remainders to be packed into fragment blocks. Doing so may increase the compression obtained
BUTat the expense of I/O speed.
do not perform duplicate checking: tells
mksquashfsto not check the files being added to the filesystem for duplicates. This can result in quicker filesystem generation and appending although obviously compression will suffer badly if there is a lot of duplicate files.
do not append to existing filesystem
if one source directory is specified, create a root directory containing that directory, rather than the contents of the directory
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
-all-root or -root-owned
make all files owned by root
set all file uids to
set all file gids to
create a little endian filesystem
create a big endian filesystem
do not pad filesystem to a multiple of 4Ko. This is performed by default to enable the output filesystem file to be mounted by loopback, which requires files to be a 4K multiple. If the filesystem is being written to a block device, or is to be stored in a bootimage, the extra pad bytes are not needed.
add checkdata for greater filesystem checks
sort files according to priorities in
sort_file. One file or dir with priority per line. Priority -32768 to 32767, default priority 0
-e list of exclude dirs/files
inline list of files / directories to exclude
file containing a list of files / directories to exclude, one per line
For following examples, take two example directories:
This is the same as the first example, except for
-keep-as-directory. This will generate a root directory containing directory
test, rather than the
Squashfs was written by
<email@example.com>, in Chepstow, Wales, UK. If you like the program, or have any problems, then please email me, as it's nice to get feedback !
This manual page was written by Frédéric Boiteux
system (but may be used by others) using the
Artemiy I. Pavlov
READMEfile. Permission is granted to copy, distribute and/or modify this document under the terms of the
General Public License, Version 2 any later version published by the Free Software Foundation.
On Debian systems, the complete text of the
General Public License can be found in