The mksquashfs tool can be used for creating new squashed file systems, as well as for appending new data to existing squashed file systems.
The general format for mksquashfs from the command-line is:
bash# mksquashfs source1 source2 ... destination [options] [-e files to exclude] |
source items can be files and directories with mixed relative/absolute paths; destination can be regular files (thus, you will have a file system image on your disk), or a block device, such as /dev/fd0 or /dev/hda3.
When the new files are added to the new file system or appended to an existing one, mksquashfs will automatically rename files with duplicate names: if two or more files named text will appear in the same resulting directory, the second file will be renamed to text_1, third one to text_2 and so on. Additionally, duplicate files will be removed, so there will be only one physical instance.
If destination has a pre-existing SquashFS file system on it, by default, the new source items will be appended to existing root directory. Examine the options table below to force mksquashfs to overwrite the whole destination and/or change the way new source items are added.
If a single source file or directory is given, it becomes the root in a newly created file system. If two or more source files and/or directories are given, they will all become sub-items in the root of the new file system.
Files to exclude can be used to specify which files and/or directories you want to omit from the new file system that is to be created. The usage of this option will be described later.
See the next section for more details about mksquashfs options.
All possible options for mksquashfs are shown in the table below.
Table 1. mksquashfs command-line options
Option | Description |
---|---|
-info | print files, their original size and compression ratio, as they are added to the file system |
-version | print the version, copyright and licence message |
-noI or -noInodeCompression | do not compress the inode table |
-noD or -noDataCompression | do not compress the data |
-b [block size] | use [block size] filesystem block size (32 Kbytes default) - this can be either 512, 1024, 2048, 4096, 8192, 16384 or 32768 |
-nopad | do not pad the resulting file system to a multiple of 4 KBytes |
-be or -le | force a big or little endian file system, respectively |
-check-data | enable additional file system checks |
-keep-as-directory | if the source is a single directory, force this directory to be a subdirectory of the root in the created file system |
-noappend | if the destination file/device already contains a squashed file system, overwrite it, rather than append the new data to an existing file system. |
-root-becomes [name] | can be used while appending to a pre-existing squashed file system, it will make a new root, and [name] directory will contain all pre-existing files/directories. |
In most cases, you should leave all compression/block options by default, as they allow mksquashfs to achieve the best possible compression ratios.