Section: User Commands (1)
Updated: June 2019
tar2sqfs - create a SquashFS image from a tar archive
Quickly and painlessly turn a tar ball into a SquashFS filesystem image.
By default, the program reads the archive from standard input. Compressed
archives are supported.
- --root-becomes, -r <dir>
If set, only pack entries that are underneath the specified directory. The
prefix is stripped and the meta data for the directory itself is copied to the
root inode (i.e. the ownership, permissions, extended attributes,
If this option is not set, tar2sqfs implicitly treats ./ or absolute
paths this way, i.e. if the archive contains an entry for ./, it becomes
the root node and the prefix is stripped from all paths (and similar for
absolute paths and /).
- --no-symlink-retarget, -S
If --root-becomes is used, link targets are adjusted if they are prefixed by
the root path. By default, this is also done on symbolic links, that have a
target that is prefixed by the root path and they are converted to aboluste
paths with the prefix removed. However, because symlinks can point across mount
points, this may actually be intended for some use cases.
This flag allows changing the default behaviour, so only hard links are
- --compressor, -c <name>
Select the compressor to use.
Run tar2sqfs --help to get a list of all available compressors
and the default selection.
- --comp-extra, -X <options>
A comma separated list of extra options for the selected compressor. Specify
help to get a list of available options.
- --num-jobs, -j <count>
If libsquashfs was compiled with a thread pool based, parallel data
compressor, this option can be used to set the number of compressor
threads. If not set, the default is the number of available CPU cores.
- --queue-backlog, -Q <count>
Maximum number of data blocks in the thread worker queue before the packer
starts waiting for the block processors to catch up. Higher values result
in higher memory consumption. Defaults to 10 times the number of workers.
- --block-size, -b <size>
Block size to use for SquashFS image.
Defaults to 131072.
- --dev-block-size, -B <size>
Device block size to padd the image to.
Defaults to 4096.
- --defaults, -d <options>
A comma separated list of default values for
implicitly created directories.
The following values can be set:
|mtime=<value>||$SOURCE_DATE_EPOCH if set, 0 otherwise|
- --no-keep-time, -k
Replace the time stamps from the tar archive with default time stamps for all
The default behavior is to preserve the time stamps from the archive to the
extent possible (SquashFS has second resolution and 32 bit time stamps; tar can
use extensions to specify much larger timestamps with arbitrary precision). The
root inode (unless --root-becomes is used) and the modification time on
the SquashFS image itself will still be set to defaults.
- --no-xattr, -x
Do not copy extended attributes from archive. Default behaviour is to copy all
extended attributes and skip the ones that cannot be encoded in SquashFS.
- --no-skip, -s
Abort if a tar record cannot be read instead of skipping it.
- --exportable, -e
Generate an export table for NFS support.
- --no-tail-packing, -T
Do not perform tail end packing on files that are larger than the
specified block size.
- --force, -f
Overwrite the output file if it exists.
- --quiet, -q
Do not print out progress reports.
- --help, -h
Print help text and exit.
- --version, -V
Print version information and exit.
Currently the program can process v7 format, pre-POSIX ustar, POSIX tar and GNU
tar archives. PAX extension headers are also supported. Global PAX headers are
The support for GNU tar is limited to a commonly used subset (i.e. some legacy
extensions that GNU tar itself no longer generates are not supported; neither
are multi volume archives).
The input tar file can either be uncompressed, or stream compressed using
gzip, xz, zstd or bzip2. The program transparently
auto-detects and unpacks any stream compressed archive. The exact list of
supported compressors depends on the compile configuration.
Extended attributes are supported through the SCHILY.xattr extension
(favoured by GNU tar and star) or through the LIBARCHIVE.xattr extension.
If any unsupported section or extended attribute key is encountered in an
archive, a warning message is written to stderr. If the --no-skip
option is set, processing aborts. By default, unknown sections and unsupported
extended attributes are simply skipped after issuing a warning.
If the command line switch --defaults
is not used or no default mtime
is specified, the value of the environment variable SOURCE_DATE_EPOCH
is used for all file and filesystem timestamps.
If SOURCE_DATE_EPOCH is not set, not a parsable number or it is out of
range, the timestamps default to 0.
Environment variables are only used if no explicit command line switches
are set. Explicit command line switches are always preferred over the
- Turn an uncompressed tar archive into a SquashFS image:
tar2sqfs rootfs.sqfs < rootfs.tar.gz
Written by David Oberhollenzer.
Copyright © 2019 David Oberhollenzer
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.