summaryrefslogtreecommitdiffstats
path: root/generate-manpages/mksquashfs.h2m
blob: 8f9acaa7708e88936b3cbf1ecbee4e0b901693ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
[Name]
mksquashfs - tool to create and append to squashfs filesystems

[Description]
Squashfs is a highly compressed read-only filesystem for Linux.
It uses either gzip/xz/lzo/lz4/zstd compression to compress both files, inodes
and directories.  Inodes in the system are very small and all blocks are
packed to minimise data overhead. Block sizes greater than 4K are supported
up to a maximum of 1Mbytes (default block size 128K).

Squashfs is intended for general read-only filesystem use, for archival
use (i.e. in cases where a .tar.gz file may be used), and in constrained
block device/memory systems (e.g. embedded systems) where low overhead is
needed.

[Examples]
.TP
mksquashfs DIRECTORY IMAGE.SQFS
Create a Squashfs filesystem from the contents of DIRECTORY, writing the output
to IMAGE.SQSH.  Mksquashfs will use the default compressor (normally gzip), and
block size of 128 Kbytes.
.TP
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 will be combined into
a single directory.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -b 1M -comp zstd
Use a block size of 1 Mbyte and Zstandard compression to create the filesystem. 
.TP
mksquashfs DIRECTORY IMAGE.SQFS -e file1 file2
Exclude file1 and file2 from DIRECTORY when creating filesystem.  No wildcard
matching of files.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -wildcards -e "*.gz"
Exclude anything in DIRECTORY which matches the wildcard pattern "*.gz".
.TP
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.
.PP
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.

.SS Using pseudo file definitions
.TP
mksquashfs DIRECTORY IMAGE.SQFS -p "build_dir d 0644 0 0"
Create a directory called "build_dir" in the output filesystem.
.TP
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/version" was copied or hard-linked into DIRECTORY
before calling Mksquashfs.
.TP
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
the "date" command.
.TP
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 blackslashed to protect them from the shell.
.TP
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.
.TP
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.
.PP
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.

.SS Using extended attribute options
.TP
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.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -xattrs-include "^user."
Filter the extended attributes in the source files, and only store extended
attributes in the user namespace in the Squashfs filesystem.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -xattrs-exclude "^user."
Filter the extended attributes in the source files, and don't store any
extended attributes in the user namespace in the Squashfs filesystem.
.TP
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.
.TP
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 (012 octal).
.TP
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".
.TP
mksquashfs DIRECTORY IMAGE.SQFS -action "-xattrs-include(^user.) @ type(f)"
Filter the extended attributes but only in regular files (type f), and only
store extended attributes in the user namespace.
.TP
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 (012 octal).

.SS Using Actions to not compress, change attributes etc.
.TP
mksquashfs DIRECTORY IMAGE.SQSH -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 larger than 1 Gigabyte should be uncompressed too.  This shows
test operators can be combined with logical expressions.
.TP
mksquashfs DIRECTORY IMAGE.SQSH -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.
.TP
mksquashfs DIRECTORY IMAGE.SQSH -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.
.TP
mksquashfs DIRECTORY IMAGE.SQSH -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.
.TP
mksquashfs DIRECTORY IMAGE.SQSH -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.
.TP
mksquashfs DIRECTORY IMAGE.SQFS -action "-xattrs-include(^user.) @ type(f)"
Filter the extended attributes but only in regular files (type f), and only
store extended attributes in the user namespace.
.PP
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.