Debian Codegraph @

upstream/opensuse-leap-16-1/man1/mkosi.1

raw
1 '\" t
2 .\" Automatically generated by Pandoc 3.5
3 .\"
4 .TH "mkosi" "1" "" ""
5 .SH NAME
6 mkosi \[em] Build Bespoke OS Images
7 .SH SYNOPSIS
8 \f[CR]mkosi [options\&...] summary\f[R]
9 .PP
10 \f[CR]mkosi [options\&...] cat\-config\f[R]
11 .PP
12 \f[CR]mkosi [options\&...] build [command line\&...]\f[R]
13 .PP
14 \f[CR]mkosi [options\&...] shell [command line\&...]\f[R]
15 .PP
16 \f[CR]mkosi [options\&...] boot [nspawn settings\&...]\f[R]
17 .PP
18 \f[CR]mkosi [options\&...] vm [vmm parameters\&...]\f[R]
19 .PP
20 \f[CR]mkosi [options\&...] ssh [command line\&...]\f[R]
21 .PP
22 \f[CR]mkosi [options\&...] journalctl [command line\&...]\f[R]
23 .PP
24 \f[CR]mkosi [options\&...] coredumpctl [command line\&...]\f[R]
25 .PP
26 \f[CR]mkosi [options\&...] sysupdate [command line\&...]\f[R]
27 .PP
28 \f[CR]mkosi [options\&...] sandbox [command line \&...]\f[R]
29 .PP
30 \f[CR]mkosi [options\&...] clean\f[R]
31 .PP
32 \f[CR]mkosi [options\&...] serve\f[R]
33 .PP
34 \f[CR]mkosi [options\&...] burn <device>\f[R]
35 .PP
36 \f[CR]mkosi [options\&...] bump\f[R]
37 .PP
38 \f[CR]mkosi [options\&...] genkey\f[R]
39 .PP
40 \f[CR]mkosi [options\&...] documentation [manual]\f[R]
41 .PP
42 \f[CR]mkosi [options\&...] completion [shell]\f[R]
43 .PP
44 \f[CR]mkosi [options\&...] dependencies\f[R]
45 .PP
46 \f[CR]mkosi [options\&...] help\f[R]
47 .SH DESCRIPTION
48 \f[B]mkosi\f[R] is a tool for easily building customized OS images.
49 It\[cq]s a fancy wrapper around \f[B]dnf\f[R], \f[B]apt\f[R],
50 \f[B]pacman\f[R] and \f[B]zypper\f[R] that may generate disk images with
51 a number of bells and whistles.
52 .SS Command Line Verbs
53 The following command line verbs are known:
54 .TP
55 \f[CR]summary\f[R]
56 Show a human\-readable summary of all options used for building the
57 images.
58 This will parse the command line and configuration files, but only print
59 what it is configured for and not actually build or run anything.
60 .TP
61 \f[CR]cat\-config\f[R]
62 Output the names and contents of all loaded configuration files.
63 \f[B]mkosi\f[R] loads a bunch of files from different locations and this
64 command makes it easier to figure out what is configured where.
65 .TP
66 \f[CR]build\f[R]
67 Build the image\-based on the settings passed on the command line and in
68 the configuration files.
69 This command is the default if no verb is specified.
70 Any command line arguments specified after the verb will be passed
71 directly to the build script, if one is defined.
72 .TP
73 \f[CR]shell\f[R]
74 This builds the image if it is not built yet, and then invokes
75 \f[B]systemd\-nspawn\f[R] to run an interactive shell in the image.
76 This doesn\[cq]t require booting the system, it\[cq]s like a better
77 chroot.
78 An optional command line may be specified after the \f[CR]shell\f[R]
79 verb, to be invoked in place of the shell in the container.
80 Use \f[CR]\-f\f[R] in order to rebuild the image unconditionally before
81 acquiring the shell, see below.
82 This command must be executed as \f[CR]root\f[R].
83 .TP
84 \f[CR]boot\f[R]
85 Similar to \f[CR]shell\f[R], but instead of spawning a shell, it boots
86 systemd in the image using \f[B]systemd\-nspawn\f[R].
87 An optional command line may be specified after the \f[CR]boot\f[R]
88 verb, which can contain extra nspawn options as well as arguments which
89 are passed as the \f[I]kernel command line\f[R] to the init system in
90 the image.
91 .TP
92 \f[CR]vm\f[R]
93 Similar to \f[CR]boot\f[R], but uses the configured virtual machine
94 monitor (by default \f[CR]qemu\f[R]) to boot up the image, i.e.\ instead
95 of container virtualization, virtual machine virtualization is used.
96 How extra command line arguments are interpreted depends on the
97 configured virtual machine monitor.
98 See \f[CR]VirtualMachineMonitor=\f[R] for more information.
99 .TP
100 \f[CR]ssh\f[R]
101 When the image is built with the \f[CR]Ssh=yes\f[R] option, this command
102 connects to a booted virtual machine via SSH.
103 Make sure to run \f[CR]mkosi ssh\f[R] with the same config as
104 \f[CR]mkosi build\f[R] so that it has the necessary information
105 available to connect to the running virtual machine via SSH.
106 Specifically, the SSH private key from the \f[CR]SshKey=\f[R] setting is
107 used to connect to the virtual machine.
108 Use \f[CR]mkosi genkey\f[R] to automatically generate a key and
109 certificate that will be picked up by \f[B]mkosi\f[R].
110 Any arguments passed after the \f[CR]ssh\f[R] verb are passed as
111 arguments to the \f[B]ssh\f[R] invocation.
112 To connect to a container, use \f[CR]machinectl login\f[R] or
113 \f[CR]machinectl shell\f[R].
114 .RS
115 .PP
116 The \f[CR]Machine=\f[R] option can be used to give the machine a custom
117 hostname when booting it which can later be used to \f[B]ssh\f[R] into
118 the image (e.g.\ \f[CR]mkosi \-\-machine=mymachine vm\f[R] followed by
119 \f[CR]mkosi \-\-machine=mymachine ssh\f[R]).
120 .RE
121 .TP
122 \f[CR]journalctl\f[R]
123 Uses \f[B]journalctl\f[R] to inspect the journal inside the image.
124 Any arguments specified after the \f[B]journalctl\f[R] verb are appended
125 to the \f[B]journalctl\f[R] invocation.
126 .TP
127 \f[CR]coredumpctl\f[R]
128 Uses \f[B]coredumpctl\f[R] to look for coredumps inside the image.
129 Any arguments specified after the \f[B]coredumpctl\f[R] verb are
130 appended to the \f[B]coredumpctl\f[R] invocation.
131 .TP
132 \f[CR]sysupdate\f[R]
133 Invokes \f[B]systemd\-sysupdate\f[R] with the
134 \f[CR]\-\-transfer\-source=\f[R] option set to the output directory and
135 the \f[CR]\-\-definitions=\f[R] option set to the directory configured
136 with \f[CR]SysupdateDirectory=\f[R].
137 Any arguments specified after the \f[CR]sysupdate\f[R] verb are passed
138 directly to \f[B]systemd\-sysupdate\f[R] invocation.
139 .TP
140 \f[CR]sandbox\f[R]
141 Run arbitrary commands inside of the same sandbox used to execute other
142 verbs such as \f[CR]boot\f[R], \f[CR]shell\f[R], \f[CR]vm\f[R] and more.
143 This means \f[CR]/usr\f[R] will be replaced by \f[CR]/usr\f[R] from the
144 tools tree if one is used while everything else will remain in place.
145 If no command is provided, \f[CR]$SHELL\f[R] will be executed or
146 \f[B]bash\f[R] if \f[CR]$SHELL\f[R] is not set.
147 .TP
148 \f[CR]clean\f[R]
149 Remove build artifacts generated on a previous build.
150 If combined with \f[CR]\-f\f[R], also removes incremental build cache
151 images.
152 If \f[CR]\-f\f[R] is specified twice, also removes any package cache.
153 .TP
154 \f[CR]serve\f[R]
155 This builds the image if it is not built yet, and then serves the output
156 directory (i.e.\ usually \f[CR]mkosi.output/\f[R], see below) via a
157 small embedded HTTP server, listening on port 8081.
158 Combine with \f[CR]\-f\f[R] in order to rebuild the image
159 unconditionally before serving it.
160 This command is useful for testing network\-based acquisition of OS
161 images, for example via \f[CR]machinectl pull\-raw \&...\f[R] and
162 \f[CR]machinectl pull\-tar \&...\f[R].
163 .TP
164 \f[CR]burn <device>\f[R]
165 This builds the image if it is not built yet, and then writes it to the
166 specified block device.
167 The partition contents are written as\-is, but the GPT partition table
168 is corrected to match sector and disk size of the specified medium.
169 .TP
170 \f[CR]bump\f[R]
171 Bumps the image version from \f[CR]mkosi.version\f[R] and writes the
172 resulting version string to \f[CR]mkosi.version\f[R].
173 This is useful for implementing a simple versioning scheme: each time
174 this verb is called the version is bumped in preparation for the
175 subsequent build.
176 Note that \f[CR]\-\-auto\-bump\f[R]/\f[CR]\-B\f[R] may be used to
177 automatically bump the version after each successful build.
178 .TP
179 \f[CR]genkey\f[R]
180 Generate a pair of SecureBoot keys for usage with the
181 \f[CR]SecureBootKey=\f[R]/\f[CR]\-\-secure\-boot\-key=\f[R] and
182 \f[CR]SecureBootCertificate=\f[R]/\f[CR]\-\-secure\-boot\-certificate=\f[R]
183 options.
184 .TP
185 \f[CR]documentation\f[R]
186 Show \f[B]mkosi\f[R]\[cq]s documentation.
187 If no argument is given, the \f[B]mkosi\f[R] man page is shown, but the
188 arguments \f[CR]mkosi\f[R], \f[CR]mkosi\-initrd\f[R], \f[CR]initrd\f[R],
189 \f[CR]mkosi\-sandbox\f[R], \f[CR]sandbox\f[R], \f[CR]mkosi.news\f[R] and
190 \f[CR]news\f[R] are supported and respectively show the man pages for
191 \f[B]mkosi\f[R], \f[B]mkosi\-initrd\f[R], \f[B]mkosi\-sandbox\f[R] and
192 \f[B]mkosi\f[R]\[cq]s NEWS file.
193 .RS
194 .PP
195 By default this verb will try several ways to output the documentation,
196 but a specific option can be chosen with the \f[CR]\-\-doc\-format\f[R]
197 option.
198 Distro packagers are encouraged to add a file \f[CR]mkosi.1\f[R] into
199 the \f[CR]mkosi/resources\f[R] directory of the Python package, if it is
200 missing, as well as to install it in the appropriate search path for man
201 pages.
202 The man page can be generated from the markdown file
203 \f[CR]mkosi/resources/man/mkosi.1.md\f[R] e.g via
204 \f[CR]pandoc \-t man \-s \-o mkosi.1 mkosi.1.md\f[R].
205 .RE
206 .TP
207 \f[CR]completion\f[R]
208 Generate shell completion for the shell given as argument and print it
209 to stdout.
210 The arguments \f[CR]bash\f[R], \f[CR]fish\f[R], and \f[CR]zsh\f[R] are
211 understood.
212 .TP
213 \f[CR]dependencies\f[R]
214 Output the list of packages required by \f[B]mkosi\f[R] to build and
215 boot images.
216 .RS
217 .PP
218 This list can be piped directly to a package manager to install the
219 packages.
220 For example, if the host system uses the \f[B]dnf\f[R] package manager,
221 the packages could be installed as follows:
222 .IP
223 .EX
224 mkosi dependencies \f[B]|\f[R] xargs \-d \[aq]\[rs]n\[aq] dnf install
225 .EE
226 .RE
227 .TP
228 \f[CR]help\f[R]
229 This verb is equivalent to the \f[CR]\-\-help\f[R] switch documented
230 below: it shows a brief usage explanation.
231 .SS Commandline\-only Options
232 Those settings cannot be configured in the configuration files.
233 .TP
234 \f[CR]\-\-force\f[R], \f[CR]\-f\f[R]
235 Replace the output file if it already exists, when building an image.
236 By default when building an image and an output artifact already exists
237 \f[B]mkosi\f[R] will refuse operation.
238 Specify this option once to delete all build artifacts from a previous
239 run before re\-building the image.
240 If incremental builds are enabled, specifying this option twice will
241 ensure the intermediary cache files are removed, too, before the
242 re\-build is initiated.
243 If a package cache is used (also see the \f[B]Files\f[R] section below),
244 specifying this option thrice will ensure the package cache is removed
245 too, before the re\-build is initiated.
246 For the \f[CR]clean\f[R] operation this option has a slightly different
247 effect: by default the verb will only remove build artifacts from a
248 previous run, when specified once the incremental cache files are
249 deleted too, and when specified twice the package cache is also removed.
250 .TP
251 \f[CR]\-\-directory=\f[R], \f[CR]\-C\f[R]
252 Takes a path to a directory.
253 \f[B]mkosi\f[R] switches to this directory before doing anything.
254 Note that the various configuration files are searched for in this
255 directory, hence using this option is an effective way to build a
256 project located in a specific directory.
257 .TP
258 \f[CR]\-\-debug\f[R]
259 Enable additional debugging output.
260 .TP
261 \f[CR]\-\-debug\-shell\f[R]
262 When executing a command in the image fails, \f[B]mkosi\f[R] will start
263 an interactive shell in the image allowing further debugging.
264 .TP
265 \f[CR]\-\-debug\-workspace\f[R]
266 When specified, the workspace directory will not be deleted and its
267 location will be logged when \f[B]mkosi\f[R] exits.
268 .TP
269 \f[CR]\-\-debug\-sandbox\f[R]
270 Run \f[B]mkosi\-sandbox\f[R] with \f[B]strace\f[R].
271 .TP
272 \f[CR]\-\-version\f[R]
273 Show package version.
274 .TP
275 \f[CR]\-\-help\f[R], \f[CR]\-h\f[R]
276 Show brief usage information.
277 .TP
278 \f[CR]\-\-genkey\-common\-name=\f[R]
279 Common name to be used when generating keys via \f[B]mkosi\f[R]\[cq]s
280 \f[CR]genkey\f[R] command.
281 Defaults to \f[CR]mkosi of %u\f[R], where \f[CR]%u\f[R] expands to the
282 username of the user invoking \f[B]mkosi\f[R].
283 .TP
284 \f[CR]\-\-genkey\-valid\-days=\f[R]
285 Number of days that the keys should remain valid when generating keys
286 via \f[B]mkosi\f[R]\[cq]s \f[CR]genkey\f[R] command.
287 Defaults to two years (730 days).
288 .TP
289 \f[CR]\-\-auto\-bump=\f[R], \f[CR]\-B\f[R]
290 If specified, after each successful build the version is bumped in a
291 fashion equivalent to the \f[CR]bump\f[R] verb, in preparation for the
292 next build.
293 This is useful for simple, linear version management: each build in a
294 series will have a version number one higher then the previous one.
295 .TP
296 \f[CR]\-\-doc\-format\f[R]
297 The format to show the documentation in.
298 Supports the values \f[CR]markdown\f[R], \f[CR]man\f[R],
299 \f[CR]pandoc\f[R], \f[CR]system\f[R] and \f[CR]auto\f[R].
300 In the case of \f[CR]markdown\f[R] the documentation is shown in the
301 original Markdown format.
302 \f[CR]man\f[R] shows the documentation in man page format, if it is
303 available.
304 \f[B]pandoc\f[R] will generate the man page format on the fly, if
305 \f[B]pandoc\f[R] is available.
306 \f[CR]system\f[R] will show the system\-wide man page for
307 \f[B]mkosi\f[R], which may or may not correspond to the version you are
308 using, depending on how you installed \f[B]mkosi\f[R].
309 \f[CR]auto\f[R], which is the default, will try all methods in the order
310 \f[CR]man\f[R], \f[CR]pandoc\f[R], \f[CR]markdown\f[R],
311 \f[CR]system\f[R].
312 .TP
313 \f[CR]\-\-json\f[R]
314 Show the summary output as JSON\-SEQ.
315 .TP
316 \f[CR]\-\-wipe\-build\-dir\f[R], \f[CR]\-w\f[R]
317 Wipe the build directory if one is configured before building the image.
318 .SS Supported output formats
319 The following output formats are supported:
320 .IP \[bu] 2
321 Raw \f[I]GPT\f[R] disk image, created using \f[B]systemd\-repart\f[R]
322 (\f[I]disk\f[R])
323 .IP \[bu] 2
324 Plain directory, containing the OS tree (\f[I]directory\f[R])
325 .IP \[bu] 2
326 Tar archive (\f[I]tar\f[R])
327 .IP \[bu] 2
328 CPIO archive (\f[I]cpio\f[R])
329 .PP
330 The output format may also be set to \f[I]none\f[R] to have
331 \f[B]mkosi\f[R] produce no image at all.
332 This can be useful if you only want to use the image to produce another
333 output in the build scripts (e.g.\ build an RPM).
334 .PP
335 When a \f[I]GPT\f[R] disk image is created, repart partition definition
336 files may be placed in \f[CR]mkosi.repart/\f[R] to configure the
337 generated disk image.
338 .PP
339 It is highly recommended to run \f[B]mkosi\f[R] on a file system that
340 supports reflinks such as XFS and btrfs and to keep all related
341 directories on the same file system.
342 This allows \f[B]mkosi\f[R] to create images very quickly by using
343 reflinks to perform copying via copy\-on\-write operations.
344 .SS Configuration Settings
345 The following settings can be set through configuration files (the
346 syntax with \f[CR]SomeSetting=value\f[R]) and on the command line (the
347 syntax with \f[CR]\-\-some\-setting=value\f[R]).
348 For some command line parameters, a single\-letter shortcut is also
349 allowed.
350 In the configuration files, the setting must be in the appropriate
351 section, so the settings are grouped by section below.
352 .PP
353 Configuration is parsed in the following order:
354 .IP \[bu] 2
355 The command line arguments are parsed.
356 .IP \[bu] 2
357 \f[CR]mkosi.local.conf\f[R] or \f[CR]mkosi.local\f[R] is parsed if it
358 exists.
359 This file or directory should be in \f[CR].gitignore\f[R] (or
360 equivalent) and is intended for local configuration.
361 .IP \[bu] 2
362 Any default paths (depending on the option) are configured if the
363 corresponding path exists.
364 .IP \[bu] 2
365 \f[CR]mkosi.conf\f[R] is parsed if it exists in the directory configured
366 with \f[CR]\-\-directory=\f[R] or the current working directory if
367 \f[CR]\-\-directory=\f[R] is not used.
368 .IP \[bu] 2
369 \f[CR]mkosi.conf.d/\f[R] is parsed in the same directory if it exists.
370 Each directory and each file with the \f[CR].conf\f[R] extension in
371 \f[CR]mkosi.conf.d/\f[R] is parsed.
372 Any directory in \f[CR]mkosi.conf.d\f[R] is parsed as if it were a
373 regular top level directory.
374 .IP \[bu] 2
375 If any profiles are configured, their configuration is parsed from the
376 \f[CR]mkosi.profiles/\f[R] directory.
377 .IP \[bu] 2
378 Subimages are parsed from the \f[CR]mkosi.images\f[R] directory if it
379 exists.
380 .PP
381 Note that settings configured via the command line always override
382 settings configured via configuration files.
383 If the same setting is configured more than once via configuration
384 files, later assignments override earlier assignments except for
385 settings that take a collection of values.
386 Also, settings read from \f[CR]mkosi.local\f[R] or
387 \f[CR]mkosi.local.conf\f[R] will override settings from configuration
388 files that are parsed later, but not settings specified on the CLI.
389 .PP
390 For settings that take a single value, the empty assignment
391 (\f[CR]SomeSetting=\f[R] or \f[CR]\-\-some\-setting=\f[R]) can be used
392 to override a previous setting and reset to the default.
393 .PP
394 Settings that take a collection of values are merged by appending the
395 new values to the previously configured values.
396 Assigning the empty string to such a setting removes all previously
397 assigned values, and overrides any configured default values as well.
398 The values specified on the CLI are appended after all the values from
399 configuration files.
400 .PP
401 To conditionally include configuration files, the \f[CR][Match]\f[R]
402 section can be used.
403 A \f[CR][Match]\f[R] section consists of individual conditions.
404 Conditions can use a pipe symbol (\f[CR]|\f[R]) after the equals sign
405 (\f[CR]\&...=|\&...\f[R]), which causes the condition to become a
406 triggering condition.
407 The config file will be included if the logical AND of all
408 non\-triggering conditions and the logical OR of all triggering
409 conditions is satisfied.
410 To negate the result of a condition, prefix the argument with an
411 exclamation mark.
412 If an argument is prefixed with the pipe symbol and an exclamation mark,
413 the pipe symbol must be passed first, and the exclamation second.
414 .PP
415 Note that \f[CR][Match]\f[R] conditions compare against the current
416 values of specific settings, and do not take into account changes made
417 to the setting in configuration files that have not been parsed yet
418 (settings specified on the CLI are taken into account).
419 Also note that matching against a setting and then changing its value
420 afterwards in a different config file may lead to unexpected results.
421 .PP
422 The \f[CR][Match]\f[R] section of a \f[CR]mkosi.conf\f[R] file in a
423 directory applies to the entire directory.
424 If the conditions are not satisfied, the entire directory is skipped.
425 The \f[CR][Match]\f[R] sections of files in \f[CR]mkosi.conf.d/\f[R] and
426 \f[CR]mkosi.local.conf\f[R] only apply to the file itself.
427 .PP
428 If there are multiple \f[CR][Match]\f[R] sections in the same
429 configuration file, each of them has to be satisfied in order for the
430 configuration file to be included.
431 Specifically, triggering conditions only apply to the current
432 \f[CR][Match]\f[R] section and are reset between multiple
433 \f[CR][Match]\f[R] sections.
434 As an example, the following will only match if the output format is one
435 of \f[CR]disk\f[R] or \f[CR]directory\f[R] and the architecture is one
436 of \f[CR]x86\-64\f[R] or \f[CR]arm64\f[R]:
437 .IP
438 .EX
439 \f[B][Match]\f[R]
440 Format=|disk
441 Format=|directory
442
443 \f[B][Match]\f[R]
444 Architecture=|x86\-64
445 Architecture=|arm64
446 .EE
447 .PP
448 The \f[CR][TriggerMatch]\f[R] section can be used to indicate triggering
449 match sections.
450 These are identical to triggering conditions except they apply to the
451 entire match section instead of just a single condition.
452 As an example, the following will match if the distribution is
453 \f[CR]debian\f[R] and the release is \f[CR]bookworm\f[R] or if the
454 distribution is \f[CR]ubuntu\f[R] and the release is \f[CR]noble\f[R].
455 .IP
456 .EX
457 \f[B][TriggerMatch]\f[R]
458 Distribution=debian
459 Release=bookworm
460
461 \f[B][TriggerMatch]\f[R]
462 Distribution=ubuntu
463 Release=noble
464 .EE
465 .PP
466 The semantics of conditions in \f[CR][TriggerMatch]\f[R] sections is the
467 same as in \f[CR][Match]\f[R], i.e.\ all normal conditions are joined by
468 a logical AND and all triggering conditions are joined by a logical OR.
469 When mixing \f[CR][Match]\f[R] and \f[CR][TriggerMatch]\f[R] sections, a
470 match is achieved when all \f[CR][Match]\f[R] sections match and at
471 least one \f[CR][TriggerMatch]\f[R] section matches.
472 The absence of match sections is valued as true.
473 Logically this means:
474 .IP
475 .EX
476 (⋀ᵢ Matchᵢ) ∧ (⋁ᵢ TriggerMatchᵢ)
477 .EE
478 .PP
479 Command line options that take no argument are shown without
480 \f[CR]=\f[R] in their long version.
481 In the config files, they should be specified with a boolean argument:
482 either \f[CR]1\f[R], \f[CR]yes\f[R], or \f[CR]true\f[R] to enable, or
483 \f[CR]0\f[R], \f[CR]no\f[R], \f[CR]false\f[R] to disable.
484 .SS [Distribution] Section
485 .TP
486 \f[CR]Distribution=\f[R], \f[CR]\-\-distribution=\f[R], \f[CR]\-d\f[R]
487 The distribution to install in the image.
488 Takes one of the following arguments: \f[CR]fedora\f[R],
489 \f[CR]debian\f[R], \f[CR]kali\f[R], \f[CR]ubuntu\f[R], \f[CR]arch\f[R],
490 \f[CR]opensuse\f[R], \f[CR]mageia\f[R], \f[CR]centos\f[R],
491 \f[CR]rhel\f[R], \f[CR]rhel\-ubi\f[R], \f[CR]openmandriva\f[R],
492 \f[CR]rocky\f[R], \f[CR]alma\f[R], \f[CR]azure\f[R] or
493 \f[CR]custom\f[R].
494 If not specified, defaults to the distribution of the host or
495 \f[CR]custom\f[R] if the distribution of the host is not a supported
496 distribution.
497 .TP
498 \f[CR]Release=\f[R], \f[CR]\-\-release=\f[R], \f[CR]\-r\f[R]
499 The release of the distribution to install in the image.
500 The precise syntax of the argument this takes depends on the
501 distribution used, and is either a numeric string (in case of Fedora
502 Linux, CentOS, \&..., e.g.\ \f[CR]29\f[R]), or a distribution version
503 name (in case of Debian, Kali, Ubuntu, \&..., e.g.\ \f[CR]artful\f[R]).
504 Defaults to a recent version of the chosen distribution, or the version
505 of the distribution running on the host if it matches the configured
506 distribution.
507 .TP
508 \f[CR]Architecture=\f[R], \f[CR]\-\-architecture=\f[R]
509 The architecture to build the image for.
510 The architectures that are actually supported depends on the
511 distribution used and whether a bootable image is requested or not.
512 When building for a foreign architecture, you\[cq]ll also need to
513 install and register a user mode emulator for that architecture.
514 .RS
515 .PP
516 One of the following architectures can be specified per image built:
517 \f[CR]alpha\f[R], \f[CR]arc\f[R], \f[CR]arm\f[R], \f[CR]arm64\f[R],
518 \f[CR]ia64\f[R], \f[CR]loongarch64\f[R], \f[CR]mips64\-le\f[R],
519 \f[CR]mips\-le\f[R], \f[CR]parisc\f[R], \f[CR]ppc\f[R],
520 \f[CR]ppc64\f[R], \f[CR]ppc64\-le\f[R], \f[CR]riscv32\f[R],
521 \f[CR]riscv64\f[R], \f[CR]s390\f[R], \f[CR]s390x\f[R],
522 \f[CR]tilegx\f[R], \f[CR]x86\f[R], \f[CR]x86\-64\f[R].
523 .RE
524 .TP
525 \f[CR]Mirror=\f[R], \f[CR]\-\-mirror=\f[R], \f[CR]\-m\f[R]
526 The mirror to use for downloading the distribution packages.
527 Expects a mirror URL as argument.
528 If not provided, the default mirror for the distribution is used.
529 .RS
530 .PP
531 The default mirrors for each distribution are as follows (unless
532 specified, the same mirror is used for all architectures):
533 .PP
534 .TS
535 tab(@);
536 lw(13.5n) lw(29.5n) lw(27.0n).
537 T{
538 T}@T{
539 x86\-64
540 T}@T{
541 aarch64
542 T}
543 _
544 T{
545 \f[CR]debian\f[R]
546 T}@T{
547 http://deb.debian.org/debian
548 T}@T{
549 T}
550 T{
551 \f[CR]arch\f[R]
552 T}@T{
553 https://geo.mirror.pkgbuild.com
554 T}@T{
555 http://mirror.archlinuxarm.org
556 T}
557 T{
558 \f[CR]opensuse\f[R]
559 T}@T{
560 http://download.opensuse.org
561 T}@T{
562 T}
563 T{
564 \f[CR]kali\f[R]
565 T}@T{
566 http://http.kali.org/kali
567 T}@T{
568 T}
569 T{
570 \f[CR]ubuntu\f[R]
571 T}@T{
572 http://archive.ubuntu.com
573 T}@T{
574 http://ports.ubuntu.com
575 T}
576 T{
577 \f[CR]centos\f[R]
578 T}@T{
579 https://mirrors.centos.org
580 T}@T{
581 T}
582 T{
583 \f[CR]rocky\f[R]
584 T}@T{
585 https://mirrors.rockylinux.org
586 T}@T{
587 T}
588 T{
589 \f[CR]alma\f[R]
590 T}@T{
591 https://mirrors.almalinux.org
592 T}@T{
593 T}
594 T{
595 \f[CR]fedora\f[R]
596 T}@T{
597 https://mirrors.fedoraproject.org
598 T}@T{
599 T}
600 T{
601 \f[CR]rhel\-ubi\f[R]
602 T}@T{
603 https://cdn\-ubi.redhat.com
604 T}@T{
605 T}
606 T{
607 \f[CR]mageia\f[R]
608 T}@T{
609 https://www.mageia.org
610 T}@T{
611 T}
612 T{
613 \f[CR]openmandriva\f[R]
614 T}@T{
615 http://mirrors.openmandriva.org
616 T}@T{
617 T}
618 T{
619 \f[CR]azure\f[R]
620 T}@T{
621 https://packages.microsoft.com/
622 T}@T{
623 T}
624 .TE
625 .RE
626 .TP
627 \f[CR]LocalMirror=\f[R], \f[CR]\-\-local\-mirror=\f[R]
628 The mirror will be used as a local, plain and direct mirror instead of
629 using it as a prefix for the full set of repositories normally supported
630 by distributions.
631 Useful for fully offline builds with a single repository.
632 Supported on \f[B]deb\f[R]\-, \f[B]rpm\f[R]\-, and
633 \f[B]pacman\f[R]\-based distributions.
634 Overrides \f[CR]\-\-mirror=\f[R] but only for the local \f[B]mkosi\f[R]
635 build, it will not be configured inside the final image,
636 \f[CR]\-\-mirror=\f[R] (or the default repository) will be configured
637 inside the final image instead.
638 .TP
639 \f[CR]RepositoryKeyCheck=\f[R], \f[CR]\-\-repository\-key\-check=\f[R]
640 Controls signature/key checks when using repositories, enabled by
641 default.
642 Useful to disable checks when combined with
643 \f[CR]\-\-local\-mirror=\f[R] and using only a repository from a local
644 filesystem.
645 .TP
646 \f[CR]RepositoryKeyFetch=\f[R], \f[CR]\-\-repository\-key\-fetch=\f[R]
647 Controls whether \f[B]mkosi\f[R] will fetch distribution GPG keys
648 remotely.
649 Enabled by default on Ubuntu when not using a tools tree or when using
650 Ubuntu tools trees to build Arch Linux or RPM\-based distributions.
651 Disabled by default on all other distributions.
652 When disabled, the distribution GPG keys for the target distribution
653 have to be installed locally on the host system alongside the package
654 manager for that distribution.
655 .RS
656 .PP
657 This setting is only implemented for distributions using \f[B]dnf\f[R],
658 \f[B]pacman\f[R] or \f[B]zypper\f[R] as their package manager.
659 For other distributions the distribution GPG keys are always looked up
660 locally regardless of the value of this setting.
661 To make the distribution GPG keys for distributions available without
662 enabling this setting, the corresponding package has to be installed on
663 the host.
664 This is usually one of \f[CR]archlinux\-keyring\f[R],
665 \f[CR]debian\-keyring\f[R], \f[CR]kali\-archive\-keyring\f[R],
666 \f[CR]ubuntu\-keyring\f[R] or \f[CR]distribution\-gpg\-keys\f[R] (for
667 RPM\-based distributions).
668 .RE
669 .TP
670 \f[CR]Repositories=\f[R], \f[CR]\-\-repositories=\f[R]
671 Enable package repositories that are disabled by default.
672 This can be used to enable the EPEL repos for CentOS or different
673 components of the Debian/Kali/Ubuntu repositories.
674 .SS [Output] Section
675 .TP
676 \f[CR]Format=\f[R], \f[CR]\-\-format=\f[R], \f[CR]\-t\f[R]
677 The image format type to generate.
678 One of \f[CR]directory\f[R] (for generating an OS image directly in a
679 local directory), \f[CR]tar\f[R] (similar, but a tarball of the OS image
680 is generated), \f[CR]cpio\f[R] (similar, but a cpio archive is
681 generated), \f[CR]disk\f[R] (a block device OS image with a GPT
682 partition table), \f[CR]uki\f[R] (a unified kernel image with the OS
683 image in the \f[CR].initrd\f[R] PE section), \f[CR]esp\f[R]
684 (\f[CR]uki\f[R] but wrapped in a disk image with only an ESP partition),
685 \f[CR]oci\f[R] (a directory compatible with the OCI image
686 specification), \f[CR]sysext\f[R], \f[CR]confext\f[R],
687 \f[CR]portable\f[R], \f[CR]addon\f[R] or \f[CR]none\f[R] (the OS image
688 is solely intended as a build image to produce another artifact).
689 .RS
690 .PP
691 If the \f[CR]disk\f[R] output format is used, the disk image is
692 generated using \f[B]systemd\-repart\f[R].
693 The repart partition definition files to use can be configured using the
694 \f[CR]RepartDirectories=\f[R] setting or via \f[CR]mkosi.repart/\f[R].
695 When verity partitions are configured using
696 \f[B]systemd\-repart\f[R]\[cq]s \f[CR]Verity=\f[R] setting,
697 \f[B]mkosi\f[R] will automatically parse the verity hash partition\[cq]s
698 roothash from \f[B]systemd\-repart\f[R]\[cq]s JSON output and include it
699 in the kernel command line of every unified kernel image built by
700 \f[B]mkosi\f[R].
701 .PP
702 If the \f[CR]none\f[R] output format is used, the outputs from a
703 previous build are not removed, but clean scripts (see
704 \f[CR]CleanScripts=\f[R]) are still executed.
705 This allows rerunning a build script (see \f[CR]BuildScripts=\f[R])
706 without removing the results of a previous build.
707 .RE
708 .TP
709 \f[CR]ManifestFormat=\f[R], \f[CR]\-\-manifest\-format=\f[R]
710 The manifest format type or types to generate.
711 A comma\-delimited list consisting of \f[CR]json\f[R] (the standard JSON
712 output format that describes the packages installed),
713 \f[CR]changelog\f[R] (a human\-readable text format designed for
714 diffing).
715 By default no manifest is generated.
716 .TP
717 \f[CR]Output=\f[R], \f[CR]\-\-output=\f[R], \f[CR]\-o\f[R]
718 Name to use for the generated output image file or directory.
719 Defaults to \f[CR]image\f[R] or, if \f[CR]ImageId=\f[R] is specified, it
720 is used as the default output name, optionally suffixed with the version
721 set with \f[CR]ImageVersion=\f[R] or if a specific image is built from
722 \f[CR]mkosi.images\f[R], the name of the image is preferred over
723 \f[CR]ImageId\f[R].
724 Note that this option does not allow configuring the output directory,
725 use \f[CR]OutputDirectory=\f[R] for that.
726 .RS
727 .PP
728 Note that this only specifies the output prefix, depending on the
729 specific output format, compression and image version used, the full
730 output name might be \f[CR]image_7.8.raw.xz\f[R].
731 .RE
732 .TP
733 \f[CR]CompressOutput=\f[R], \f[CR]\-\-compress\-output=\f[R]
734 Configure compression for the resulting image or archive.
735 The argument can be either a boolean or a compression algorithm
736 (\f[B]xz\f[R], \f[B]zstd\f[R]).
737 \f[B]zstd\f[R] compression is used by default, except CentOS and
738 derivatives up to version 8, which default to \f[B]xz\f[R], and OCI
739 images, which default to \f[B]gzip\f[R].
740 Note that when applied to block device image types, compression means
741 the image cannot be started directly but needs to be decompressed first.
742 This also means that the \f[CR]shell\f[R], \f[CR]boot\f[R],
743 \f[CR]vm\f[R] verbs are not available when this option is used.
744 Implied for \f[CR]tar\f[R], \f[CR]cpio\f[R], \f[CR]uki\f[R],
745 \f[CR]esp\f[R], \f[CR]oci\f[R] and \f[CR]addon\f[R].
746 .TP
747 \f[CR]CompressLevel=\f[R], \f[CR]\-\-compress\-level=\f[R]
748 Configure the compression level to use.
749 Takes an integer.
750 The possible values depend on the compression being used.
751 .TP
752 \f[CR]OutputDirectory=\f[R], \f[CR]\-\-output\-directory=\f[R], \f[CR]\-O\f[R]
753 Path to a directory where to place all generated artifacts.
754 If this is not specified and the directory \f[CR]mkosi.output/\f[R]
755 exists in the local directory, it is automatically used for this
756 purpose.
757 .TP
758 \f[CR]OutputMode=\f[R], \f[CR]\-\-output\-mode=\f[R]
759 File system access mode used when creating the output image file.
760 Takes an access mode in octal notation.
761 If not set, uses the current system defaults.
762 .TP
763 \f[CR]ImageVersion=\f[R], \f[CR]\-\-image\-version=\f[R]
764 Configure the image version.
765 This accepts any string, but it is recommended to specify a series of
766 dot separated components.
767 The version may also be configured by reading a \f[CR]mkosi.version\f[R]
768 file (in which case it may be conveniently managed via the
769 \f[CR]bump\f[R] verb or the \f[CR]\-\-auto\-bump\f[R] option) or by
770 reading stdout if it is executable (see the \f[B]Scripts\f[R] section
771 below).
772 When specified the image version is included in the default output file
773 name, i.e.\ instead of \f[CR]image.raw\f[R] the default will be
774 \f[CR]image_0.1.raw\f[R] for version \f[CR]0.1\f[R] of the image, and
775 similar.
776 The version is also passed via the \f[CR]$IMAGE_VERSION\f[R] to any
777 build scripts invoked (which may be useful to patch it into
778 \f[CR]/usr/lib/os\-release\f[R] or similar, in particular the
779 \f[CR]IMAGE_VERSION=\f[R] field of it).
780 .TP
781 \f[CR]ImageId=\f[R], \f[CR]\-\-image\-id=\f[R]
782 Configure the image identifier.
783 This accepts a freeform string that shall be used to identify the image
784 with.
785 If set the default output file will be named after it (possibly suffixed
786 with the version).
787 The identifier is also passed via the \f[CR]$IMAGE_ID\f[R] to any build
788 scripts invoked.
789 The image ID is automatically added to \f[CR]/usr/lib/os\-release\f[R].
790 .TP
791 \f[CR]SplitArtifacts=\f[R], \f[CR]\-\-split\-artifacts\f[R]
792 The artifact types to split out of the final image.
793 A comma\-delimited list consisting of \f[CR]uki\f[R], \f[CR]kernel\f[R],
794 \f[CR]initrd\f[R] and \f[CR]partitions\f[R].
795 When building a bootable image \f[CR]kernel\f[R] and \f[CR]initrd\f[R]
796 correspond to their artifact found in the image (or in the UKI), while
797 \f[CR]uki\f[R] copies out the entire UKI.
798 .RS
799 .PP
800 When building a disk image and \f[CR]partitions\f[R] is specified, pass
801 \f[CR]\-\-split=yes\f[R] to \f[B]systemd\-repart\f[R] to have it write
802 out split partition files for each configured partition.
803 Read the \c
804 .UR https://www.freedesktop.org/software/systemd/man/systemd-repart.html#--split=BOOL
805 man
806 .UE \c
807 \ page for more information.
808 This is useful in A/B update scenarios where an existing disk image
809 shall be augmented with a new version of a root or \f[CR]/usr\f[R]
810 partition along with its Verity partition and unified kernel.
811 By default \f[CR]uki\f[R], \f[CR]kernel\f[R] and \f[CR]initrd\f[R] are
812 split out.
813 .RE
814 .TP
815 \f[CR]RepartDirectories=\f[R], \f[CR]\-\-repart\-directory=\f[R]
816 Paths to directories containing \f[B]systemd\-repart\f[R] partition
817 definition files that are used when \f[B]mkosi\f[R] invokes
818 \f[B]systemd\-repart\f[R] when building a disk image.
819 If \f[CR]mkosi.repart/\f[R] exists in the local directory, it will be
820 used for this purpose as well.
821 Note that \f[B]mkosi\f[R] invokes repart with \f[CR]\-\-root=\f[R] set
822 to the root of the image root, so any \f[CR]CopyFiles=\f[R] source paths
823 in partition definition files will be relative to the image root
824 directory.
825 .TP
826 \f[CR]SectorSize=\f[R], \f[CR]\-\-sector\-size=\f[R]
827 Override the default sector size that \f[B]systemd\-repart\f[R] uses
828 when building a disk image.
829 .TP
830 \f[CR]Overlay=\f[R], \f[CR]\-\-overlay\f[R]
831 When used together with \f[CR]BaseTrees=\f[R], the output will consist
832 only out of changes to the specified base trees.
833 Each base tree is attached as a lower layer in an overlayfs structure,
834 and the output becomes the upper layer, initially empty.
835 Thus files that are not modified compared to the base trees will not be
836 present in the final output.
837 .RS
838 .PP
839 This option may be used to create \c
840 .UR https://uapi-group.org/specifications/specs/extension_image
841 systemd \f[I]system extensions\f[R] or \f[I]portable services\f[R]
842 .UE \c
843 \&.
844 .RE
845 .TP
846 \f[CR]Seed=\f[R], \f[CR]\-\-seed=\f[R]
847 Takes a UUID as argument or the special value \f[CR]random\f[R].
848 Overrides the seed that \f[B]systemd\-repart\f[R] uses when building a
849 disk image.
850 This is useful to achieve reproducible builds, where deterministic UUIDs
851 and other partition metadata should be derived on each build.
852 If not specified explicitly and the file \f[CR]mkosi.seed\f[R] exists in
853 the local directory, the UUID to use is read from it.
854 Otherwise, a random UUID is used.
855 .TP
856 \f[CR]CleanScripts=\f[R], \f[CR]\-\-clean\-script=\f[R]
857 Takes a comma\-separated list of paths to executables that are used as
858 the clean scripts for this image.
859 See the \f[B]Scripts\f[R] section for more information.
860 .SS [Content] Section
861 .TP
862 \f[CR]Packages=\f[R], \f[CR]\-\-package=\f[R], \f[CR]\-p\f[R]
863 Install the specified distribution packages (i.e.\ RPM, deb, \&...)
864 in the image.
865 Takes a comma\-separated list of package specifications.
866 This option may be used multiple times in which case the specified
867 package lists are combined.
868 Use \f[CR]BuildPackages=\f[R] to specify packages that shall only be
869 installed in an overlay that is mounted when the prepare scripts are
870 executed with the \f[CR]build\f[R] argument and when the build scripts
871 are executed.
872 .RS
873 .PP
874 The types and syntax of \f[I]package specifications\f[R] that are
875 allowed depend on the package installer (e.g.\ \f[B]dnf\f[R] for
876 RPM\-based distros or \f[B]apt\f[R] for deb\-based distros), but may
877 include package names, package names with version and/or architecture,
878 package name globs, package groups, and virtual provides, including file
879 paths.
880 .PP
881 See \f[CR]PackageDirectories=\f[R] for information on how to make local
882 packages available for installation with \f[CR]Packages=\f[R].
883 .PP
884 \f[B]Example\f[R]: when using a distro that uses \f[B]dnf\f[R], the
885 following configuration would install the \f[B]meson\f[R] package (in
886 the latest version), the 32\-bit version of the
887 \f[CR]libfdisk\-devel\f[R] package, all available packages that start
888 with the \f[CR]git\-\f[R] prefix, a \f[B]systemd\f[R] RPM from the local
889 file system, one of the packages that provides \f[CR]/usr/bin/ld\f[R],
890 the packages in the \f[I]Development Tools\f[R] group, and the package
891 that contains the \f[CR]mypy\f[R] python module.
892 .IP
893 .EX
894 Packages=meson
895 libfdisk\-devel.i686
896 git\-*
897 /usr/bin/ld
898 \[at]development\-tools
899 python3dist(mypy)
900 .EE
901 .RE
902 .TP
903 \f[CR]BuildPackages=\f[R], \f[CR]\-\-build\-package=\f[R]
904 Similar to \f[CR]Packages=\f[R], but configures packages to install only
905 in an overlay that is made available on top of the image to the prepare
906 scripts when executed with the \f[CR]build\f[R] argument and the build
907 scripts.
908 This option should be used to list packages containing header files,
909 compilers, build systems, linkers and other build tools the
910 \f[CR]mkosi.build\f[R] scripts require to operate.
911 Note that packages listed here will be absent in the final image.
912 .TP
913 \f[CR]VolatilePackages=\f[R], \f[CR]\-\-volatile\-package=\f[R]
914 Similar to \f[CR]Packages=\f[R], but packages configured with this
915 setting are not cached when \f[CR]Incremental=\f[R] is enabled and are
916 installed after executing any build scripts.
917 .RS
918 .PP
919 Specifically, this setting can be used to install packages that change
920 often or which are built by a build script.
921 .RE
922 .TP
923 \f[CR]PackageDirectories=\f[R], \f[CR]\-\-package\-directory=\f[R]
924 Specify directories containing extra packages to be made available
925 during the build.
926 \f[B]mkosi\f[R] will create a local repository containing all packages
927 in these directories and make it available when installing packages or
928 running scripts.
929 If the \f[CR]mkosi.packages/\f[R] directory is found in the local
930 directory it is also used for this purpose.
931 .TP
932 \f[CR]VolatilePackageDirectories=\f[R], \f[CR]\-\-volatile\-package\-directory=\f[R]
933 Like \f[CR]PackageDirectories=\f[R], but any changes to the packages in
934 these directories will not invalidate the cached images if
935 \f[CR]Incremental=\f[R] is enabled.
936 .RS
937 .PP
938 Additionally, build scripts can add more packages to the local
939 repository by placing the built packages in \f[CR]$PACKAGEDIR\f[R].
940 The packages placed in \f[CR]$PACKAGEDIR\f[R] are shared between all
941 image builds and thus available for installation in all images using
942 \f[CR]VolatilePackages=\f[R].
943 .RE
944 .TP
945 \f[CR]WithRecommends=\f[R], \f[CR]\-\-with\-recommends=\f[R]
946 Configures whether to install recommended or weak dependencies,
947 depending on how they are named by the used package manager, or not.
948 By default, recommended packages are not installed.
949 This is only used for package managers that support the concept, which
950 are currently \f[B]apt\f[R], \f[B]dnf\f[R] and \f[B]zypper\f[R].
951 .TP
952 \f[CR]WithDocs=\f[R], \f[CR]\-\-with\-docs\f[R]
953 Include documentation in the image.
954 Enabled by default.
955 When disabled, if the underlying distribution package manager supports
956 it documentation is not included in the image.
957 The \f[CR]$WITH_DOCS\f[R] environment variable passed to the
958 \f[CR]mkosi.build\f[R] scripts is set to \f[CR]0\f[R] or \f[CR]1\f[R]
959 depending on whether this option is enabled or disabled.
960 .TP
961 \f[CR]BaseTrees=\f[R], \f[CR]\-\-base\-tree=\f[R]
962 Takes a comma\-separated list of paths to use as base trees.
963 When used, these base trees are each copied into the OS tree and form
964 the base distribution instead of installing the distribution from
965 scratch.
966 Only extra packages are installed on top of the ones already installed
967 in the base trees.
968 Note that for this to work properly, the base image still needs to
969 contain the package manager metadata by setting
970 \f[CR]CleanPackageMetadata=no\f[R] (see
971 \f[CR]CleanPackageMetadata=\f[R]).
972 .RS
973 .PP
974 Instead of a directory, a tar file or a disk image may be provided.
975 In this case it is unpacked into the OS tree.
976 This mode of operation allows setting permissions and file ownership
977 explicitly, in particular for projects stored in a version control
978 system such as \f[B]git\f[R] which retain full file ownership and access
979 mode metadata for committed files.
980 .RE
981 .TP
982 \f[CR]SkeletonTrees=\f[R], \f[CR]\-\-skeleton\-tree=\f[R]
983 Takes a comma\-separated list of colon\-separated path pairs.
984 The first path of each pair refers to a directory to copy into the OS
985 tree before invoking the package manager.
986 The second path of each pair refers to the target directory inside the
987 image.
988 If the second path is not provided, the directory is copied on top of
989 the root directory of the image.
990 The second path is always interpreted as an absolute path.
991 Use this to insert files and directories into the OS tree before the
992 package manager installs any packages.
993 If the \f[CR]mkosi.skeleton/\f[R] directory is found in the local
994 directory it is also used for this purpose with the root directory as
995 target (also see the \f[B]Files\f[R] section below).
996 .RS
997 .PP
998 Note that skeleton trees are cached and any changes to skeleton trees
999 after a cached image has been built (when using \f[CR]Incremental=\f[R])
1000 are only applied when the cached image is rebuilt (by using
1001 \f[CR]\-ff\f[R] or running \f[CR]mkosi \-f clean\f[R]).
1002 .PP
1003 As with the base tree logic above, instead of a directory, a tar file
1004 may be provided too.
1005 \f[CR]mkosi.skeleton.tar\f[R] will be automatically used if found in the
1006 local directory.
1007 .PP
1008 To add extra package manager configuration files such as extra
1009 repositories, use \f[CR]SandboxTrees=\f[R] as \f[B]mkosi\f[R] invokes
1010 the package managers from outside the image and not inside so any
1011 package manager configuration files provided via
1012 \f[CR]SkeletonTrees=\f[R] won\[cq]t take effect when \f[B]mkosi\f[R]
1013 invokes a package manager to install packages.
1014 .RE
1015 .TP
1016 \f[CR]ExtraTrees=\f[R], \f[CR]\-\-extra\-tree=\f[R]
1017 Takes a comma\-separated list of colon\-separated path pairs.
1018 The first path of each pair refers to a directory to copy from the host
1019 into the image.
1020 The second path of each pair refers to the target directory inside the
1021 image.
1022 If the second path is not provided, the directory is copied on top of
1023 the root directory of the image.
1024 The second path is always interpreted as an absolute path.
1025 Use this to override any default configuration files shipped with the
1026 distribution.
1027 If the \f[CR]mkosi.extra/\f[R] directory is found in the local directory
1028 it is also used for this purpose with the root directory as target (also
1029 see the \f[B]Files\f[R] section below).
1030 .RS
1031 .PP
1032 As with the base tree logic above, instead of a directory, a tar file
1033 may be provided too.
1034 \f[CR]mkosi.extra.tar\f[R] will be automatically used if found in the
1035 local directory.
1036 .RE
1037 .TP
1038 \f[CR]RemovePackages=\f[R], \f[CR]\-\-remove\-package=\f[R]
1039 Takes a comma\-separated list of package specifications for removal, in
1040 the same format as \f[CR]Packages=\f[R].
1041 The removal will be performed as one of the last steps.
1042 This step is skipped if \f[CR]CleanPackageMetadata=no\f[R] is used.
1043 .TP
1044 \f[CR]RemoveFiles=\f[R], \f[CR]\-\-remove\-files=\f[R]
1045 Takes a comma\-separated list of globs.
1046 Files in the image matching the globs will be purged at the end.
1047 .TP
1048 \f[CR]CleanPackageMetadata=\f[R], \f[CR]\-\-clean\-package\-metadata=\f[R]
1049 Enable/disable removal of package manager databases and repository
1050 metadata at the end of installation.
1051 Can be specified as \f[CR]true\f[R], \f[CR]false\f[R], or
1052 \f[CR]auto\f[R] (the default).
1053 With \f[CR]auto\f[R], package manager databases and repository metadata
1054 will be removed if the respective package manager executable is
1055 \f[I]not\f[R] present at the end of the installation.
1056 .TP
1057 \f[CR]SourceDateEpoch=\f[R], \f[CR]\-\-source\-date\-epoch=\f[R]
1058 Takes a timestamp in seconds since the UNIX epoch as argument.
1059 File modification times of all files will be clamped to this value.
1060 The variable is also propagated to \f[B]systemd\-repart\f[R] and scripts
1061 executed by \f[B]mkosi\f[R].
1062 If not set explicitly, \f[CR]SOURCE_DATE_EPOCH\f[R] from
1063 \f[CR]\-\-environment\f[R] and from the host environment are tried in
1064 that order.
1065 This is useful to make builds reproducible.
1066 See \c
1067 .UR https://reproducible-builds.org/specs/source-date-epoch/
1068 SOURCE_DATE_EPOCH
1069 .UE \c
1070 \ for more information.
1071 .TP
1072 \f[CR]SyncScripts=\f[R], \f[CR]\-\-sync\-script=\f[R]
1073 Takes a comma\-separated list of paths to executables that are used as
1074 the sync scripts for this image.
1075 See the \f[B]Scripts\f[R] section for more information.
1076 .TP
1077 \f[CR]PrepareScripts=\f[R], \f[CR]\-\-prepare\-script=\f[R]
1078 Takes a comma\-separated list of paths to executables that are used as
1079 the prepare scripts for this image.
1080 See the \f[B]Scripts\f[R] section for more information.
1081 .TP
1082 \f[CR]BuildScripts=\f[R], \f[CR]\-\-build\-script=\f[R]
1083 Takes a comma\-separated list of paths to executables that are used as
1084 the build scripts for this image.
1085 See the \f[B]Scripts\f[R] section for more information.
1086 .TP
1087 \f[CR]PostInstallationScripts=\f[R], \f[CR]\-\-postinst\-script=\f[R]
1088 Takes a comma\-separated list of paths to executables that are used as
1089 the post\-installation scripts for this image.
1090 See the \f[B]Scripts\f[R] section for more information.
1091 .TP
1092 \f[CR]FinalizeScripts=\f[R], \f[CR]\-\-finalize\-script=\f[R]
1093 Takes a comma\-separated list of paths to executables that are used as
1094 the finalize scripts for this image.
1095 See the \f[B]Scripts\f[R] section for more information.
1096 .TP
1097 \f[CR]PostOutputScripts=\f[R], \f[CR]\-\-postoutput\-script\f[R]
1098 Takes a comma\-separated list of paths to executables that are used as
1099 the post output scripts for this image.
1100 See the \f[B]Scripts\f[R] section for more information.
1101 .TP
1102 \f[CR]Bootable=\f[R], \f[CR]\-\-bootable=\f[R]
1103 Takes a boolean or \f[CR]auto\f[R].
1104 Enables or disables generation of a bootable image.
1105 If enabled, \f[B]mkosi\f[R] will install an EFI bootloader, and add an
1106 ESP partition when the disk image output is used.
1107 If the selected EFI bootloader (see \f[CR]Bootloader=\f[R]) is not
1108 installed or no kernel images can be found, the build will fail.
1109 \f[CR]auto\f[R] behaves as if the option was enabled, but the build
1110 won\[cq]t fail if either no kernel images or the selected EFI bootloader
1111 can\[cq]t be found.
1112 If disabled, no bootloader will be installed even if found inside the
1113 image, no unified kernel images will be generated and no ESP partition
1114 will be added to the image if the disk output format is used.
1115 .TP
1116 \f[CR]Bootloader=\f[R], \f[CR]\-\-bootloader=\f[R]
1117 Takes one of \f[CR]none\f[R], \f[CR]systemd\-boot\f[R], \f[CR]uki\f[R],
1118 \f[CR]grub\f[R], \f[CR]systemd\-boot\-signed\f[R],
1119 \f[CR]uki\-signed\f[R] or \f[CR]grub\-signed\f[R].
1120 Defaults to \f[CR]systemd\-boot\f[R].
1121 If set to \f[CR]none\f[R], no EFI bootloader will be installed into the
1122 image.
1123 If set to \f[CR]systemd\-boot\f[R], \f[B]systemd\-boot\f[R] will be
1124 installed and for each installed kernel, a UKI will be generated and
1125 stored in \f[CR]EFI/Linux\f[R] in the ESP.
1126 If set to \f[CR]uki\f[R], a single UKI will be generated for the latest
1127 installed kernel (the one with the highest version) which is installed
1128 to \f[CR]EFI/BOOT/BOOTX64.EFI\f[R] in the ESP.
1129 If set to \f[CR]grub\f[R], for each installed kernel, a UKI will be
1130 generated and stored in \f[CR]EFI/Linux\f[R] in the ESP.
1131 For each generated UKI, a menu entry is appended to the grub
1132 configuration in \f[CR]grub/grub.cfg\f[R] in the ESP which chainloads
1133 into the UKI.
1134 A shim grub.cfg is also written to
1135 \f[CR]EFI/<distribution>/grub.cfg\f[R] in the ESP which loads
1136 \f[CR]grub/grub.cfg\f[R] in the ESP for compatibility with signed
1137 versions of grub which load the grub configuration from this location.
1138 .RS
1139 .PP
1140 The \f[CR]signed\f[R] variants will only install pre\-signed EFI
1141 binaries shipped by the distribution.
1142 .PP
1143 Kernels need to be placed into the root filesystem (for example using
1144 \f[CR]ExtraTrees=\f[R]) under \f[CR]/usr/lib/modules/$version\f[R],
1145 named \f[CR]vmlinux\f[R] or \f[CR]vmlinuz\f[R].
1146 The \f[CR]$version\f[R] is as produced by Kbuild\[cq]s
1147 \f[CR]kernelversion\f[R] make target.
1148 .RE
1149 .TP
1150 \f[CR]BiosBootloader=\f[R], \f[CR]\-\-bios\-bootloader=\f[R]
1151 Takes one of \f[CR]none\f[R] or \f[CR]grub\f[R].
1152 Defaults to \f[CR]none\f[R].
1153 If set to \f[CR]none\f[R], no BIOS bootloader will be installed.
1154 If set to \f[CR]grub\f[R], grub is installed as the BIOS boot loader if
1155 a bootable image is requested with the \f[CR]Bootable=\f[R] option.
1156 If no repart partition definition files are configured, \f[B]mkosi\f[R]
1157 will add a grub BIOS boot partition and an EFI system partition to the
1158 default partition definition files.
1159 .RS
1160 .PP
1161 Note that this option is not mutually exclusive with
1162 \f[CR]Bootloader=\f[R].
1163 It is possible to have an image that is both bootable on UEFI and BIOS
1164 by configuring both \f[CR]Bootloader=\f[R] and
1165 \f[CR]BiosBootloader=\f[R].
1166 .PP
1167 The grub BIOS boot partition should have UUID
1168 \f[CR]21686148\-6449\-6e6f\-744e\-656564454649\f[R] and should be at
1169 least 1MB.
1170 .PP
1171 Even if no EFI bootloader is installed, we still need an ESP for BIOS
1172 boot as that\[cq]s where we store the kernel, initrd and grub modules.
1173 .RE
1174 .TP
1175 \f[CR]ShimBootloader=\f[R], \f[CR]\-\-shim\-bootloader=\f[R]
1176 Takes one of \f[CR]none\f[R], \f[CR]unsigned\f[R], or \f[CR]signed\f[R].
1177 Defaults to \f[CR]none\f[R].
1178 If set to \f[CR]none\f[R], shim and MokManager will not be installed to
1179 the ESP.
1180 If set to \f[CR]unsigned\f[R], \f[B]mkosi\f[R] will search for unsigned
1181 shim and MokManager EFI binaries and install them.
1182 If \f[CR]SecureBoot=\f[R] is enabled, \f[B]mkosi\f[R] will sign the
1183 unsigned EFI binaries before installing them.
1184 If set to \f[CR]signed\f[R], \f[B]mkosi\f[R] will search for signed EFI
1185 binaries and install those.
1186 Even if \f[CR]SecureBoot=\f[R] is enabled, \f[B]mkosi\f[R] won\[cq]t
1187 sign these binaries again.
1188 .RS
1189 .PP
1190 Note that this option only takes effect when an image that is bootable
1191 on UEFI firmware is requested using other options (\f[CR]Bootable=\f[R],
1192 \f[CR]Bootloader=\f[R]).
1193 .PP
1194 Note that when this option is enabled, \f[B]mkosi\f[R] will only install
1195 already signed bootloader binaries, kernel image files and unified
1196 kernel images as self\-signed binaries would not be accepted by the
1197 signed version of shim.
1198 .RE
1199 .TP
1200 \f[CR]UnifiedKernelImages=\f[R], \f[CR]\-\-unified\-kernel\-images=\f[R]
1201 Specifies whether to use unified kernel images or not when
1202 \f[CR]Bootloader=\f[R] is set to \f[CR]systemd\-boot\f[R] or
1203 \f[CR]grub\f[R].
1204 Takes a boolean value or \f[CR]auto\f[R].
1205 Defaults to \f[CR]auto\f[R].
1206 If enabled, unified kernel images are always used and the build will
1207 fail if any components required to build unified kernel images are
1208 missing.
1209 If set to \f[CR]auto\f[R], unified kernel images will be used if all
1210 necessary components are available.
1211 Otherwise Type 1 entries as defined by the Boot Loader Specification
1212 will be used instead.
1213 If disabled, Type 1 entries will always be used.
1214 .TP
1215 \f[CR]UnifiedKernelImageFormat=\f[R], \f[CR]\-\-unified\-kernel\-image\-format=\f[R]
1216 Takes a filename without any path components to specify the format that
1217 unified kernel images should be installed as.
1218 This may include both the regular specifiers (see \f[B]Specifiers\f[R])
1219 and special delayed specifiers, that are expanded during the
1220 installation of the files, which are described below.
1221 The default format for this parameter is \f[CR]&e\-&k\f[R] with
1222 \f[CR]\-&h\f[R] being appended if \f[CR]roothash=\f[R] or
1223 \f[CR]usrhash=\f[R] is found on the kernel command line and
1224 \f[CR]+&c\f[R] if \f[CR]/etc/kernel/tries\f[R] is found in the image.
1225 .RS
1226 .PP
1227 The following specifiers may be used:
1228 .PP
1229 .TS
1230 tab(@);
1231 l l.
1232 T{
1233 Specifier
1234 T}@T{
1235 Value
1236 T}
1237 _
1238 T{
1239 \f[CR]&&\f[R]
1240 T}@T{
1241 \f[CR]&\f[R] character
1242 T}
1243 T{
1244 \f[CR]&e\f[R]
1245 T}@T{
1246 Entry Token
1247 T}
1248 T{
1249 \f[CR]&k\f[R]
1250 T}@T{
1251 Kernel version
1252 T}
1253 T{
1254 \f[CR]&h\f[R]
1255 T}@T{
1256 \f[CR]roothash=\f[R] or \f[CR]usrhash=\f[R] value of kernel argument
1257 T}
1258 T{
1259 \f[CR]&c\f[R]
1260 T}@T{
1261 Number of tries used for boot attempt counting
1262 T}
1263 .TE
1264 .RE
1265 .TP
1266 \f[CR]UnifiedKernelImageProfiles=\f[R], \f[CR]\-\-uki\-profile=\f[R]
1267 Build additional UKI profiles.
1268 Takes a comma\-separated list of paths to UKI profile config files.
1269 This option may be used multiple times in which case each config gets
1270 built into a corresponding UKI profile.
1271 Config files in the \f[CR]mkosi.uki\-profiles/\f[R] directory are
1272 automatically picked up.
1273 All configured UKI profiles are added as additional UKI profiles to each
1274 UKI built by \f[B]mkosi\f[R].
1275 .RS
1276 .PP
1277 See the documentation for the \f[CR]UKIProfile\f[R] section for
1278 information on which settings can be configured in UKI profile config
1279 files.
1280 .RE
1281 .TP
1282 \f[CR]Initrds=\f[R], \f[CR]\-\-initrd\f[R]
1283 Use user\-provided initrd(s).
1284 Takes a comma\-separated list of paths to initrd files.
1285 This option may be used multiple times in which case the initrd lists
1286 are combined.
1287 If no initrds are specified and a bootable image is requested,
1288 \f[B]mkosi\f[R] will look for initrds in a subdirectory
1289 \f[CR]io.mkosi.initrd\f[R] of the artifact directory (see
1290 \f[CR]$ARTIFACTDIR\f[R] in the section \f[B]ENVIRONMENT VARIABLES\f[R]),
1291 if none are found there \f[B]mkosi\f[R] will automatically build a
1292 default initrd.
1293 .TP
1294 \f[CR]InitrdPackages=\f[R], \f[CR]\-\-initrd\-package=\f[R]
1295 Extra packages to install into the default initrd.
1296 Takes a comma separated list of package specifications.
1297 This option may be used multiple times in which case the specified
1298 package lists are combined.
1299 .TP
1300 \f[CR]InitrdVolatilePackages=\f[R], \f[CR]\-\-initrd\-volatile\-package=\f[R]
1301 Similar to \f[CR]VolatilePackages=\f[R], except it applies to the
1302 default initrd.
1303 .TP
1304 \f[CR]Devicetree=\f[R], \f[CR]\-\-devicetree=\f[R]
1305 When set, specifies a Devicetree blob to be used by the booting system,
1306 instead of the one provided by firmware.
1307 \f[B]mkosi\f[R] will search for the specified file relative to common
1308 paths where Linux distributions install Devicetree files.
1309 It should typically have the format \f[CR]<vendor>/<board>.dtb\f[R].
1310 .TP
1311 \f[CR]MicrocodeHost=\f[R], \f[CR]\-\-microcode\-host=\f[R]
1312 When set to true only include microcode for the host\[cq]s CPU in the
1313 image.
1314 .TP
1315 \f[CR]KernelCommandLine=\f[R], \f[CR]\-\-kernel\-command\-line=\f[R]
1316 Use the specified kernel command line when building images.
1317 .RS
1318 .PP
1319 If the root or usr partition are created with verity enabled,
1320 \f[CR]roothash=\f[R] or \f[CR]usrhash=\f[R] respectively are
1321 automatically added to the kernel command line and \f[CR]root=\f[R] or
1322 \f[CR]mount.usr=\f[R] should not be added.
1323 Otherwise, if the value of this setting contains the literals
1324 \f[CR]root=PARTUUID\f[R] or \f[CR]mount.usr=PARTUUID\f[R], these are
1325 replaced with the partition UUID of the root or usr partition
1326 respectively.
1327 For example, \f[CR]root=PARTUUID\f[R] would be replaced with
1328 \f[CR]root=PARTUUID=58c7d0b2\-d224\-4834\-a16f\-e036322e88f7\f[R] where
1329 \f[CR]58c7d0b2\-d224\-4834\-a16f\-e036322e88f7\f[R] is the partition
1330 UUID of the root partition.
1331 .RE
1332 .TP
1333 \f[CR]KernelModulesInclude=\f[R], \f[CR]\-\-kernel\-modules\-include=\f[R]
1334 Takes a list of regex patterns that specify kernel modules to include in
1335 the image.
1336 Patterns should be relative to
1337 \f[CR]/usr/lib/modules/<kver>/<subdir>\f[R] paths.
1338 \f[B]mkosi\f[R] checks for a match anywhere in the module path
1339 (e.g.\ \f[CR]i915\f[R] will match against
1340 \f[CR]drivers/gpu/drm/i915.ko\f[R]).
1341 All modules that match any of the specified patterns are included in the
1342 image.
1343 All module and firmware dependencies of the matched modules are included
1344 in the image as well.
1345 .RS
1346 .PP
1347 If the special value \f[CR]default\f[R] is used, the default kernel
1348 modules defined in the \f[B]mkosi\-initrd\f[R] configuration are
1349 included as well.
1350 .PP
1351 If the special value \f[CR]host\f[R] is used, the currently loaded
1352 modules on the host system are included as well.
1353 .PP
1354 This setting takes priority over \f[CR]KernelModulesExclude=\f[R] and
1355 only makes sense when used in combination with it because all kernel
1356 modules are included in the image by default.
1357 .RE
1358 .TP
1359 \f[CR]KernelModulesExclude=\f[R], \f[CR]\-\-kernel\-modules\-exclude=\f[R]
1360 Takes a list of regex patterns that specify modules to exclude from the
1361 image.
1362 Behaves the same as \f[CR]KernelModulesInclude=\f[R] except that all
1363 modules that match any of the specified patterns are excluded from the
1364 image.
1365 .TP
1366 \f[CR]KernelModulesInitrd=\f[R], \f[CR]\-\-kernel\-modules\-initrd=\f[R]
1367 Boolean value, enabled (true) by default.
1368 If enabled, when building a bootable image, \f[B]mkosi\f[R] will
1369 generate an extra initrd for each unified kernel image it assembles.
1370 This initrd contains only modules for the specific kernel version, and
1371 will be appended to the prebuilt initrd.
1372 This allows generating kernel independent initrds which are augmented
1373 with the necessary modules when the UKI is assembled.
1374 .TP
1375 \f[CR]KernelModulesInitrdInclude=\f[R], \f[CR]\-\-kernel\-modules\-initrd\-include=\f[R]
1376 Like \f[CR]KernelModulesInclude=\f[R], but applies to the kernel modules
1377 included in the kernel modules initrd.
1378 .TP
1379 \f[CR]KernelModulesInitrdExclude=\f[R], \f[CR]\-\-kernel\-modules\-initrd\-exclude=\f[R]
1380 Like \f[CR]KernelModulesExclude=\f[R], but applies to the kernel modules
1381 included in the kernel modules initrd.
1382 .TP
1383 \f[CR]Locale=\f[R], \f[CR]\-\-locale=\f[R], \f[CR]LocaleMessages=\f[R], \f[CR]\-\-locale\-messages=\f[R], \f[CR]Keymap=\f[R], \f[CR]\-\-keymap=\f[R], \f[CR]Timezone=\f[R], \f[CR]\-\-timezone=\f[R], \f[CR]Hostname=\f[R], \f[CR]\-\-hostname=\f[R], \f[CR]RootShell=\f[R], \f[CR]\-\-root\-shell=\f[R]
1384 The settings \f[CR]Locale=\f[R], \f[CR]\-\-locale=\f[R],
1385 \f[CR]LocaleMessages=\f[R], \f[CR]\-\-locale\-messages=\f[R],
1386 \f[CR]Keymap=\f[R], \f[CR]\-\-keymap=\f[R], \f[CR]Timezone=\f[R],
1387 \f[CR]\-\-timezone=\f[R], \f[CR]Hostname=\f[R],
1388 \f[CR]\-\-hostname=\f[R], \f[CR]RootShell=\f[R],
1389 \f[CR]\-\-root\-shell=\f[R] correspond to the identically named
1390 systemd\-firstboot options.
1391 See \f[B]systemd\-firstboot\f[R](1) for more information.
1392 Additionally, where applicable, the corresponding systemd credentials
1393 for these settings are written to \f[CR]/usr/lib/credstore\f[R], so that
1394 they apply even if only \f[CR]/usr\f[R] is shipped in the image.
1395 .TP
1396 \f[CR]RootPassword=\f[R], \f[CR]\-\-root\-password=\f[R],
1397 Set the system root password.
1398 If this option is not used, but a \f[CR]mkosi.rootpw\f[R] file is found
1399 in the local directory, the password is automatically read from it or if
1400 the file is executable it is run as a script and stdout is read instead
1401 (see the \f[B]Scripts\f[R] section below).
1402 If the password starts with \f[CR]hashed:\f[R], it is treated as an
1403 already hashed root password.
1404 The root password is also stored in \f[CR]/usr/lib/credstore\f[R] under
1405 the appropriate systemd credential so that it applies even if only
1406 \f[CR]/usr\f[R] is shipped in the image.
1407 To create an unlocked account without any password use
1408 \f[CR]hashed:\f[R] without a hash.
1409 .TP
1410 \f[CR]Autologin=\f[R], \f[CR]\-\-autologin\f[R]
1411 Enable autologin for the \f[CR]root\f[R] user on \f[CR]/dev/pts/0\f[R]
1412 (nspawn), \f[CR]/dev/tty1\f[R] and \f[CR]/dev/hvc0\f[R].
1413 .TP
1414 \f[CR]MakeInitrd=\f[R], \f[CR]\-\-make\-initrd\f[R]
1415 Add \f[CR]/etc/initrd\-release\f[R] and \f[CR]/init\f[R] to the image so
1416 that it can be used as an initramfs.
1417 .TP
1418 \f[CR]Ssh=\f[R], \f[CR]\-\-ssh\f[R]
1419 If specified, an \f[B]sshd\f[R] socket unit and matching service are
1420 installed in the final image that expose SSH over VSock.
1421 When building with this option and running the image using
1422 \f[CR]mkosi vm\f[R], the \f[CR]mkosi ssh\f[R] command can be used to
1423 connect to the container/VM via SSH.
1424 Note that you still have to make sure openssh is installed in the image
1425 to make this option behave correctly.
1426 Run \f[CR]mkosi genkey\f[R] to automatically generate an X.509
1427 certificate and private key to be used by \f[B]mkosi\f[R] to enable SSH
1428 access to any virtual machines via \f[CR]mkosi ssh\f[R].
1429 To access images booted using \f[CR]mkosi boot\f[R], use
1430 \f[B]machinectl\f[R].
1431 .TP
1432 \f[CR]SELinuxRelabel=\f[R], \f[CR]\-\-selinux\-relabel=\f[R]
1433 Specifies whether to relabel files to match the image\[cq]s SELinux
1434 policy.
1435 Takes a boolean value or \f[CR]auto\f[R].
1436 Defaults to \f[CR]auto\f[R].
1437 If disabled, files will not relabeled.
1438 If enabled, an SELinux policy has to be installed in the image and
1439 \f[B]setfiles\f[R] has to be available to relabel files.
1440 If any errors occur during \f[B]setfiles\f[R], the build will fail.
1441 If set to \f[CR]auto\f[R], files will be relabeled if an SELinux policy
1442 is installed in the image and if \f[B]setfiles\f[R] is available.
1443 Any errors occurred during \f[B]setfiles\f[R] will be ignored.
1444 .RS
1445 .PP
1446 Note that when running unprivileged, \f[B]setfiles\f[R] will fail to set
1447 any labels that are not in the host\[cq]s SELinux policy.
1448 To ensure \f[B]setfiles\f[R] succeeds without errors, make sure to run
1449 \f[B]mkosi\f[R] as root or build from a host system with the same
1450 SELinux policy as the image you\[cq]re building.
1451 .RE
1452 .TP
1453 \f[CR]MachineId=\f[R], \f[CR]\-\-machine\-id=\f[R]
1454 Takes a UUID or the special value \f[CR]random\f[R].
1455 Sets the machine ID of the image to the specified UUID.
1456 If set to \f[CR]random\f[R], a random UUID will be written to
1457 \f[CR]/etc/machine\-id\f[R].
1458 If not specified explicitly and the file \f[CR]mkosi.machine\-id\f[R]
1459 exists in the local directory, the UUID to use is read from it.
1460 Otherwise, \f[CR]uninitialized\f[R] will be written to
1461 \f[CR]/etc/machine\-id\f[R].
1462 .SS [Validation] Section
1463 .TP
1464 \f[CR]SecureBoot=\f[R], \f[CR]\-\-secure\-boot\f[R]
1465 Sign \f[B]systemd\-boot\f[R] (if it is not signed yet) and any generated
1466 unified kernel images for UEFI SecureBoot.
1467 .TP
1468 \f[CR]SecureBootAutoEnroll=\f[R], \f[CR]\-\-secure\-boot\-auto\-enroll=\f[R]
1469 Set up automatic enrollment of the secure boot keys in virtual machines
1470 as documented in \f[B]systemd\-boot\f[R](7) if \f[CR]SecureBoot=\f[R] is
1471 used.
1472 Note that \f[B]systemd\-boot\f[R] will only do automatic secure boot key
1473 enrollment in virtual machines starting from systemd v253.
1474 To do auto enrollment on systemd v252 or on bare metal machines, write a
1475 \f[B]systemd\-boot\f[R] configuration file to
1476 \f[CR]/efi/loader/loader.conf\f[R] using an extra tree with
1477 \f[CR]secure\-boot\-enroll force\f[R] or
1478 \f[CR]secure\-boot\-enroll manual\f[R] in it.
1479 Auto enrollment is not supported on systemd versions older than v252.
1480 Defaults to \f[CR]yes\f[R].
1481 .TP
1482 \f[CR]SecureBootKey=\f[R], \f[CR]\-\-secure\-boot\-key=\f[R]
1483 Path to the PEM file containing the secret key for signing the UEFI
1484 kernel image if \f[CR]SecureBoot=\f[R] is used and PCR signatures when
1485 \f[CR]SignExpectedPcr=\f[R] is also used.
1486 When \f[CR]SecureBootKeySource=\f[R] is specified, the input type
1487 depends on the source.
1488 .TP
1489 \f[CR]SecureBootCertificate=\f[R], \f[CR]\-\-secure\-boot\-certificate=\f[R]
1490 Path to the X.509 file containing the certificate for the signed UEFI
1491 kernel image, if \f[CR]SecureBoot=\f[R] is used.
1492 .TP
1493 \f[CR]SecureBootSignTool=\f[R], \f[CR]\-\-secure\-boot\-sign\-tool\f[R]
1494 Tool to use to sign secure boot PE binaries.
1495 Takes one of \f[CR]systemd\-sbsign\f[R], \f[CR]sbsign\f[R] or
1496 \f[CR]auto\f[R].
1497 Defaults to \f[CR]auto\f[R].
1498 If set to \f[CR]auto\f[R], either \f[B]systemd\-sbsign\f[R] or
1499 \f[B]sbsign\f[R] are used if available, with \f[B]systemd\-sbsign\f[R]
1500 being preferred.
1501 .TP
1502 \f[CR]Verity=\f[R], \f[CR]\-\-verity=\f[R]
1503 Whether to enforce or disable signed verity for extension images.
1504 Takes a boolean value or \f[CR]auto\f[R].
1505 If enabled, a verity key and certificate must be present and the build
1506 will fail if we don\[cq]t detect any verity partitions in the disk image
1507 produced by \f[B]systemd\-repart\f[R].
1508 If disabled, verity partitions will be excluded from the extension
1509 images produced by \f[B]systemd\-repart\f[R].
1510 If set to \f[CR]auto\f[R] and a verity key and certificate are present,
1511 \f[B]mkosi\f[R] will pass them to systemd\-repart and expects the
1512 generated disk image to contain verity partitions, but the build
1513 won\[cq]t fail if no verity partitions are found in the disk image
1514 produced by \f[B]systemd\-repart\f[R].
1515 .RS
1516 .PP
1517 Note that explicitly disabling signed verity is not yet implemented for
1518 the \f[CR]disk\f[R] output and only works for extension images at the
1519 moment.
1520 .RE
1521 .TP
1522 \f[CR]VerityKey=\f[R], \f[CR]\-\-verity\-key=\f[R]
1523 Path to the PEM file containing the secret key for signing the verity
1524 signature, if a verity signature partition is added with
1525 \f[B]systemd\-repart\f[R].
1526 When \f[CR]VerityKeySource=\f[R] is specified, the input type depends on
1527 the source.
1528 .TP
1529 \f[CR]VerityCertificate=\f[R], \f[CR]\-\-verity\-certificate=\f[R]
1530 Path to the X.509 file containing the certificate for signing the verity
1531 signature, if a verity signature partition is added with
1532 \f[B]systemd\-repart\f[R].
1533 .TP
1534 \f[CR]SignExpectedPcr=\f[R], \f[CR]\-\-sign\-expected\-pcr\f[R]
1535 Measure the components of the unified kernel image (UKI) using
1536 \f[B]systemd\-measure\f[R] and embed the PCR signature into the unified
1537 kernel image.
1538 This option takes a boolean value or the special value \f[CR]auto\f[R],
1539 which is the default, which is equal to a true value if the
1540 \f[B]systemd\-measure\f[R] binary is in \f[CR]PATH\f[R].
1541 Depends on \f[CR]SecureBoot=\f[R] being enabled and key from
1542 \f[CR]SecureBootKey=\f[R].
1543 .TP
1544 \f[CR]SignExpectedPcrKey=\f[R], \f[CR]\-\-sign\-expected\-pcr\-key=\f[R]
1545 Path to the PEM file containing the secret key for signing the expected
1546 PCR signatures.
1547 When \f[CR]SignExpectedPcrKeySource=\f[R] is specified, the input type
1548 depends on the source.
1549 .TP
1550 \f[CR]SignExpectedPcrCertificate=\f[R], \f[CR]\-\-sign\-expected\-pcr\-certificate=\f[R]
1551 Path to the X.509 file containing the certificate for signing the
1552 expected PCR signatures.
1553 .TP
1554 \f[CR]SecureBootKeySource=\f[R], \f[CR]\-\-secure\-boot\-key\-source=\f[R], \f[CR]VerityKeySource=\f[R], \f[CR]\-\-verity\-key\-source=\f[R], \f[CR]SignExpectedPcrKeySource=\f[R], \f[CR]\-\-sign\-expected\-key\-source=\f[R]
1555 The source of the corresponding private key, to support OpenSSL engines
1556 and providers,
1557 e.g.\ \f[CR]\-\-secure\-boot\-key\-source=engine:pkcs11\f[R] or
1558 \f[CR]\-\-secure\-boot\-key\-source=provider:pkcs11\f[R].
1559 .TP
1560 \f[CR]SecureBootCertificateSource=\f[R], \f[CR]\-\-secure\-boot\-certificate\-source=\f[R], \f[CR]VerityCertificateSource=\f[R], \f[CR]\-\-verity\-certificate\-source=\f[R], \f[CR]SignExpectedPcrCertificateSource=\f[R], \f[CR]\-\-sign\-expected\-certificate\-source=\f[R]
1561 The source of the corresponding certificate, to support OpenSSL
1562 providers,
1563 e.g.\ \f[CR]\-\-secure\-boot\-certificate\-source=provider:pkcs11\f[R].
1564 Note that engines are not supported.
1565 .TP
1566 \f[CR]Passphrase=\f[R], \f[CR]\-\-passphrase\f[R]
1567 Specify the path to a file containing the passphrase to use for LUKS
1568 encryption.
1569 It should contain the passphrase literally, and not end in a newline
1570 character (i.e.\ in the same format as \f[B]cryptsetup\f[R] and
1571 \f[CR]/etc/crypttab\f[R] expect the passphrase files).
1572 The file must have an access mode of 0600 or less.
1573 .TP
1574 \f[CR]Checksum=\f[R], \f[CR]\-\-checksum\f[R]
1575 Generate a \f[CR]<output>.SHA256SUMS\f[R] file of all generated
1576 artifacts after the build is complete.
1577 .TP
1578 \f[CR]Sign=\f[R], \f[CR]\-\-sign\f[R]
1579 Sign the generated \f[CR]SHA256SUMS\f[R] using \f[B]gpg\f[R] after
1580 completion.
1581 .TP
1582 \f[CR]OpenPGPTool=\f[R], \f[CR]\-\-openpgp\-tool\f[R]
1583 OpenPGP implementation to use for signing.
1584 \f[CR]gpg\f[R] is the default.
1585 Selecting a value different than the default will use the given
1586 Stateless OpenPGP (SOP) tool for signing the \f[CR]SHA256SUMS\f[R] file.
1587 .RS
1588 .PP
1589 Exemplary choices are \f[CR]sqop\f[R] and \f[CR]rsop\f[R], but any
1590 implementation from https://www.openpgp.org/about/sop/ that can be
1591 installed locally will work.
1592 .RE
1593 .TP
1594 \f[CR]Key=\f[R], \f[CR]\-\-key=\f[R]
1595 Select the \f[B]gpg\f[R] key to use for signing \f[CR]SHA256SUMS\f[R].
1596 This key must be already present in the \f[B]gpg\f[R] keyring.
1597 .SS [Build] Section
1598 .TP
1599 \f[CR]ToolsTree=\f[R], \f[CR]\-\-tools\-tree=\f[R]
1600 If specified, programs executed by \f[B]mkosi\f[R] to build and boot an
1601 image are looked up inside the given tree instead of in the host system.
1602 Use this option to make image builds more reproducible by always using
1603 the same versions of programs to build the final image instead of
1604 whatever version is installed on the host system.
1605 If this option is not used, but the \f[CR]mkosi.tools/\f[R] directory is
1606 found in the local directory it is automatically used for this purpose
1607 with the root directory as target.
1608 .RS
1609 .PP
1610 Note that binaries found in any of the paths configured with
1611 \f[CR]ExtraSearchPaths=\f[R] will be executed with \f[CR]/usr/\f[R] from
1612 the tools tree instead of from the host.
1613 If the host distribution or release does not match the tools tree
1614 distribution or release respectively, this might result in failures when
1615 trying to execute binaries from any of the extra search paths.
1616 .PP
1617 If set to \f[CR]default\f[R], \f[B]mkosi\f[R] will automatically add an
1618 extra tools tree image and use it as the tools tree.
1619 .PP
1620 The following table shows for which distributions default tools tree
1621 packages are defined and which packages are included in those default
1622 tools trees:
1623 .PP
1624 .TS
1625 tab(@);
1626 lw(22.2n) cw(7.1n) cw(7.1n) cw(7.1n) cw(5.3n) cw(7.1n) cw(5.3n) cw(8.9n).
1627 T{
1628 T}@T{
1629 Fedora
1630 T}@T{
1631 CentOS
1632 T}@T{
1633 Debian
1634 T}@T{
1635 Kali
1636 T}@T{
1637 Ubuntu
1638 T}@T{
1639 Arch
1640 T}@T{
1641 openSUSE
1642 T}
1643 _
1644 T{
1645 \f[CR]acl\f[R]
1646 T}@T{
1647 ✓
1648 T}@T{
1649 ✓
1650 T}@T{
1651 ✓
1652 T}@T{
1653 ✓
1654 T}@T{
1655 ✓
1656 T}@T{
1657 ✓
1658 T}@T{
1659 ✓
1660 T}
1661 T{
1662 \f[CR]apt\f[R]
1663 T}@T{
1664 ✓
1665 T}@T{
1666 ✓
1667 T}@T{
1668 ✓
1669 T}@T{
1670 ✓
1671 T}@T{
1672 ✓
1673 T}@T{
1674 ✓
1675 T}@T{
1676 T}
1677 T{
1678 \f[CR]archlinux\-keyring\f[R]
1679 T}@T{
1680 ✓
1681 T}@T{
1682 ✓
1683 T}@T{
1684 ✓
1685 T}@T{
1686 ✓
1687 T}@T{
1688 ✓
1689 T}@T{
1690 ✓
1691 T}@T{
1692 T}
1693 T{
1694 \f[CR]attr\f[R]
1695 T}@T{
1696 ✓
1697 T}@T{
1698 ✓
1699 T}@T{
1700 ✓
1701 T}@T{
1702 ✓
1703 T}@T{
1704 ✓
1705 T}@T{
1706 ✓
1707 T}@T{
1708 ✓
1709 T}
1710 T{
1711 \f[CR]bash\f[R]
1712 T}@T{
1713 ✓
1714 T}@T{
1715 ✓
1716 T}@T{
1717 ✓
1718 T}@T{
1719 ✓
1720 T}@T{
1721 ✓
1722 T}@T{
1723 ✓
1724 T}@T{
1725 ✓
1726 T}
1727 T{
1728 \f[CR]btrfs\-progs\f[R]
1729 T}@T{
1730 ✓
1731 T}@T{
1732 ✓
1733 T}@T{
1734 ✓
1735 T}@T{
1736 ✓
1737 T}@T{
1738 ✓
1739 T}@T{
1740 ✓
1741 T}@T{
1742 ✓
1743 T}
1744 T{
1745 \f[CR]ca\-certificates\f[R]
1746 T}@T{
1747 ✓
1748 T}@T{
1749 ✓
1750 T}@T{
1751 ✓
1752 T}@T{
1753 ✓
1754 T}@T{
1755 ✓
1756 T}@T{
1757 ✓
1758 T}@T{
1759 ✓
1760 T}
1761 T{
1762 \f[CR]coreutils\f[R]
1763 T}@T{
1764 ✓
1765 T}@T{
1766 ✓
1767 T}@T{
1768 ✓
1769 T}@T{
1770 ✓
1771 T}@T{
1772 ✓
1773 T}@T{
1774 ✓
1775 T}@T{
1776 ✓
1777 T}
1778 T{
1779 \f[CR]cpio\f[R]
1780 T}@T{
1781 ✓
1782 T}@T{
1783 ✓
1784 T}@T{
1785 ✓
1786 T}@T{
1787 ✓
1788 T}@T{
1789 ✓
1790 T}@T{
1791 ✓
1792 T}@T{
1793 ✓
1794 T}
1795 T{
1796 \f[CR]createrepo_c\f[R]
1797 T}@T{
1798 ✓
1799 T}@T{
1800 ✓
1801 T}@T{
1802 ✓
1803 T}@T{
1804 ✓
1805 T}@T{
1806 ✓
1807 T}@T{
1808 ✓
1809 T}@T{
1810 ✓
1811 T}
1812 T{
1813 \f[CR]curl\f[R]
1814 T}@T{
1815 ✓
1816 T}@T{
1817 ✓
1818 T}@T{
1819 ✓
1820 T}@T{
1821 ✓
1822 T}@T{
1823 ✓
1824 T}@T{
1825 ✓
1826 T}@T{
1827 ✓
1828 T}
1829 T{
1830 \f[CR]debian\-keyring\f[R]
1831 T}@T{
1832 ✓
1833 T}@T{
1834 ✓
1835 T}@T{
1836 ✓
1837 T}@T{
1838 ✓
1839 T}@T{
1840 ✓
1841 T}@T{
1842 ✓
1843 T}@T{
1844 T}
1845 T{
1846 \f[CR]diffutils\f[R]
1847 T}@T{
1848 ✓
1849 T}@T{
1850 ✓
1851 T}@T{
1852 ✓
1853 T}@T{
1854 ✓
1855 T}@T{
1856 ✓
1857 T}@T{
1858 ✓
1859 T}@T{
1860 ✓
1861 T}
1862 T{
1863 \f[CR]distribution\-gpg\-keys\f[R]
1864 T}@T{
1865 ✓
1866 T}@T{
1867 ✓
1868 T}@T{
1869 ✓
1870 T}@T{
1871 ✓
1872 T}@T{
1873 T}@T{
1874 ✓
1875 T}@T{
1876 ✓
1877 T}
1878 T{
1879 \f[CR]dnf\f[R]
1880 T}@T{
1881 ✓
1882 T}@T{
1883 ✓
1884 T}@T{
1885 ✓
1886 T}@T{
1887 ✓
1888 T}@T{
1889 ✓
1890 T}@T{
1891 ✓
1892 T}@T{
1893 ✓
1894 T}
1895 T{
1896 \f[CR]dosfstools\f[R]
1897 T}@T{
1898 ✓
1899 T}@T{
1900 ✓
1901 T}@T{
1902 ✓
1903 T}@T{
1904 ✓
1905 T}@T{
1906 ✓
1907 T}@T{
1908 ✓
1909 T}@T{
1910 ✓
1911 T}
1912 T{
1913 \f[CR]e2fsprogs\f[R]
1914 T}@T{
1915 ✓
1916 T}@T{
1917 ✓
1918 T}@T{
1919 ✓
1920 T}@T{
1921 ✓
1922 T}@T{
1923 ✓
1924 T}@T{
1925 ✓
1926 T}@T{
1927 ✓
1928 T}
1929 T{
1930 \f[CR]edk2\-ovmf\f[R]
1931 T}@T{
1932 ✓
1933 T}@T{
1934 ✓
1935 T}@T{
1936 ✓
1937 T}@T{
1938 ✓
1939 T}@T{
1940 ✓
1941 T}@T{
1942 ✓
1943 T}@T{
1944 ✓
1945 T}
1946 T{
1947 \f[CR]erofs\-utils\f[R]
1948 T}@T{
1949 ✓
1950 T}@T{
1951 ✓
1952 T}@T{
1953 ✓
1954 T}@T{
1955 ✓
1956 T}@T{
1957 ✓
1958 T}@T{
1959 ✓
1960 T}@T{
1961 ✓
1962 T}
1963 T{
1964 \f[CR]findutils\f[R]
1965 T}@T{
1966 ✓
1967 T}@T{
1968 ✓
1969 T}@T{
1970 ✓
1971 T}@T{
1972 ✓
1973 T}@T{
1974 ✓
1975 T}@T{
1976 ✓
1977 T}@T{
1978 ✓
1979 T}
1980 T{
1981 \f[CR]git\f[R]
1982 T}@T{
1983 ✓
1984 T}@T{
1985 ✓
1986 T}@T{
1987 ✓
1988 T}@T{
1989 ✓
1990 T}@T{
1991 ✓
1992 T}@T{
1993 ✓
1994 T}@T{
1995 ✓
1996 T}
1997 T{
1998 \f[CR]grep\f[R]
1999 T}@T{
2000 ✓
2001 T}@T{
2002 ✓
2003 T}@T{
2004 ✓
2005 T}@T{
2006 ✓
2007 T}@T{
2008 ✓
2009 T}@T{
2010 ✓
2011 T}@T{
2012 ✓
2013 T}
2014 T{
2015 \f[CR]grub\-tools\f[R]
2016 T}@T{
2017 ✓
2018 T}@T{
2019 ✓
2020 T}@T{
2021 ✓
2022 T}@T{
2023 ✓
2024 T}@T{
2025 ✓
2026 T}@T{
2027 ✓
2028 T}@T{
2029 T}
2030 T{
2031 \f[CR]jq\f[R]
2032 T}@T{
2033 ✓
2034 T}@T{
2035 ✓
2036 T}@T{
2037 ✓
2038 T}@T{
2039 ✓
2040 T}@T{
2041 ✓
2042 T}@T{
2043 ✓
2044 T}@T{
2045 ✓
2046 T}
2047 T{
2048 \f[CR]kali\-archive\-keyring\f[R]
2049 T}@T{
2050 T}@T{
2051 T}@T{
2052 T}@T{
2053 ✓
2054 T}@T{
2055 T}@T{
2056 T}@T{
2057 T}
2058 T{
2059 \f[CR]kmod\f[R]
2060 T}@T{
2061 ✓
2062 T}@T{
2063 ✓
2064 T}@T{
2065 ✓
2066 T}@T{
2067 ✓
2068 T}@T{
2069 ✓
2070 T}@T{
2071 ✓
2072 T}@T{
2073 ✓
2074 T}
2075 T{
2076 \f[CR]less\f[R]
2077 T}@T{
2078 ✓
2079 T}@T{
2080 ✓
2081 T}@T{
2082 ✓
2083 T}@T{
2084 ✓
2085 T}@T{
2086 ✓
2087 T}@T{
2088 ✓
2089 T}@T{
2090 ✓
2091 T}
2092 T{
2093 \f[CR]mtools\f[R]
2094 T}@T{
2095 ✓
2096 T}@T{
2097 ✓
2098 T}@T{
2099 ✓
2100 T}@T{
2101 ✓
2102 T}@T{
2103 ✓
2104 T}@T{
2105 ✓
2106 T}@T{
2107 ✓
2108 T}
2109 T{
2110 \f[CR]nano\f[R]
2111 T}@T{
2112 ✓
2113 T}@T{
2114 ✓
2115 T}@T{
2116 ✓
2117 T}@T{
2118 ✓
2119 T}@T{
2120 ✓
2121 T}@T{
2122 ✓
2123 T}@T{
2124 ✓
2125 T}
2126 T{
2127 \f[CR]opensc\f[R]
2128 T}@T{
2129 ✓
2130 T}@T{
2131 ✓
2132 T}@T{
2133 ✓
2134 T}@T{
2135 ✓
2136 T}@T{
2137 ✓
2138 T}@T{
2139 ✓
2140 T}@T{
2141 ✓
2142 T}
2143 T{
2144 \f[CR]openssh\f[R]
2145 T}@T{
2146 ✓
2147 T}@T{
2148 ✓
2149 T}@T{
2150 ✓
2151 T}@T{
2152 ✓
2153 T}@T{
2154 ✓
2155 T}@T{
2156 ✓
2157 T}@T{
2158 ✓
2159 T}
2160 T{
2161 \f[CR]openssl\f[R]
2162 T}@T{
2163 ✓
2164 T}@T{
2165 ✓
2166 T}@T{
2167 ✓
2168 T}@T{
2169 ✓
2170 T}@T{
2171 ✓
2172 T}@T{
2173 ✓
2174 T}@T{
2175 ✓
2176 T}
2177 T{
2178 \f[CR]pkcs11\-provider\f[R]
2179 T}@T{
2180 ✓
2181 T}@T{
2182 ✓
2183 T}@T{
2184 ✓
2185 T}@T{
2186 ✓
2187 T}@T{
2188 ✓
2189 T}@T{
2190 ✓
2191 T}@T{
2192 ✓
2193 T}
2194 T{
2195 \f[CR]perf\f[R]
2196 T}@T{
2197 ✓
2198 T}@T{
2199 ✓
2200 T}@T{
2201 ✓
2202 T}@T{
2203 ✓
2204 T}@T{
2205 T}@T{
2206 ✓
2207 T}@T{
2208 ✓
2209 T}
2210 T{
2211 \f[CR]sed\f[R]
2212 T}@T{
2213 ✓
2214 T}@T{
2215 ✓
2216 T}@T{
2217 ✓
2218 T}@T{
2219 ✓
2220 T}@T{
2221 ✓
2222 T}@T{
2223 ✓
2224 T}@T{
2225 ✓
2226 T}
2227 T{
2228 \f[CR]pacman\f[R]
2229 T}@T{
2230 ✓
2231 T}@T{
2232 ✓
2233 T}@T{
2234 ✓
2235 T}@T{
2236 ✓
2237 T}@T{
2238 ✓
2239 T}@T{
2240 ✓
2241 T}@T{
2242 T}
2243 T{
2244 \f[CR]policycoreutils\f[R]
2245 T}@T{
2246 ✓
2247 T}@T{
2248 ✓
2249 T}@T{
2250 ✓
2251 T}@T{
2252 ✓
2253 T}@T{
2254 ✓
2255 T}@T{
2256 T}@T{
2257 ✓
2258 T}
2259 T{
2260 \f[CR]qemu\f[R]
2261 T}@T{
2262 ✓
2263 T}@T{
2264 ✓
2265 T}@T{
2266 ✓
2267 T}@T{
2268 ✓
2269 T}@T{
2270 ✓
2271 T}@T{
2272 ✓
2273 T}@T{
2274 ✓
2275 T}
2276 T{
2277 \f[CR]sbsigntools\f[R]
2278 T}@T{
2279 ✓
2280 T}@T{
2281 ✓
2282 T}@T{
2283 ✓
2284 T}@T{
2285 ✓
2286 T}@T{
2287 ✓
2288 T}@T{
2289 ✓
2290 T}@T{
2291 ✓
2292 T}
2293 T{
2294 \f[CR]socat\f[R]
2295 T}@T{
2296 ✓
2297 T}@T{
2298 ✓
2299 T}@T{
2300 ✓
2301 T}@T{
2302 ✓
2303 T}@T{
2304 ✓
2305 T}@T{
2306 ✓
2307 T}@T{
2308 ✓
2309 T}
2310 T{
2311 \f[CR]squashfs\-tools\f[R]
2312 T}@T{
2313 ✓
2314 T}@T{
2315 ✓
2316 T}@T{
2317 ✓
2318 T}@T{
2319 ✓
2320 T}@T{
2321 ✓
2322 T}@T{
2323 ✓
2324 T}@T{
2325 ✓
2326 T}
2327 T{
2328 \f[CR]strace\f[R]
2329 T}@T{
2330 ✓
2331 T}@T{
2332 ✓
2333 T}@T{
2334 ✓
2335 T}@T{
2336 ✓
2337 T}@T{
2338 ✓
2339 T}@T{
2340 ✓
2341 T}@T{
2342 ✓
2343 T}
2344 T{
2345 \f[CR]swtpm\f[R]
2346 T}@T{
2347 ✓
2348 T}@T{
2349 ✓
2350 T}@T{
2351 ✓
2352 T}@T{
2353 ✓
2354 T}@T{
2355 ✓
2356 T}@T{
2357 ✓
2358 T}@T{
2359 ✓
2360 T}
2361 T{
2362 \f[CR]systemd\f[R]
2363 T}@T{
2364 ✓
2365 T}@T{
2366 ✓
2367 T}@T{
2368 ✓
2369 T}@T{
2370 ✓
2371 T}@T{
2372 ✓
2373 T}@T{
2374 ✓
2375 T}@T{
2376 ✓
2377 T}
2378 T{
2379 \f[CR]ukify\f[R]
2380 T}@T{
2381 ✓
2382 T}@T{
2383 ✓
2384 T}@T{
2385 ✓
2386 T}@T{
2387 ✓
2388 T}@T{
2389 ✓
2390 T}@T{
2391 ✓
2392 T}@T{
2393 ✓
2394 T}
2395 T{
2396 \f[CR]tar\f[R]
2397 T}@T{
2398 ✓
2399 T}@T{
2400 ✓
2401 T}@T{
2402 ✓
2403 T}@T{
2404 ✓
2405 T}@T{
2406 ✓
2407 T}@T{
2408 ✓
2409 T}@T{
2410 ✓
2411 T}
2412 T{
2413 \f[CR]ubuntu\-keyring\f[R]
2414 T}@T{
2415 ✓
2416 T}@T{
2417 ✓
2418 T}@T{
2419 ✓
2420 T}@T{
2421 ✓
2422 T}@T{
2423 ✓
2424 T}@T{
2425 ✓
2426 T}@T{
2427 T}
2428 T{
2429 \f[CR]util\-linux\f[R]
2430 T}@T{
2431 ✓
2432 T}@T{
2433 ✓
2434 T}@T{
2435 ✓
2436 T}@T{
2437 ✓
2438 T}@T{
2439 ✓
2440 T}@T{
2441 ✓
2442 T}@T{
2443 ✓
2444 T}
2445 T{
2446 \f[CR]virtiofsd\f[R]
2447 T}@T{
2448 ✓
2449 T}@T{
2450 ✓
2451 T}@T{
2452 ✓
2453 T}@T{
2454 ✓
2455 T}@T{
2456 ✓
2457 T}@T{
2458 ✓
2459 T}@T{
2460 ✓
2461 T}
2462 T{
2463 \f[CR]virt\-firmware\f[R]
2464 T}@T{
2465 ✓
2466 T}@T{
2467 ✓
2468 T}@T{
2469 ✓
2470 T}@T{
2471 ✓
2472 T}@T{
2473 ✓
2474 T}@T{
2475 ✓
2476 T}@T{
2477 ✓
2478 T}
2479 T{
2480 \f[CR]xfsprogs\f[R]
2481 T}@T{
2482 ✓
2483 T}@T{
2484 ✓
2485 T}@T{
2486 ✓
2487 T}@T{
2488 ✓
2489 T}@T{
2490 ✓
2491 T}@T{
2492 ✓
2493 T}@T{
2494 ✓
2495 T}
2496 T{
2497 \f[CR]xz\f[R]
2498 T}@T{
2499 ✓
2500 T}@T{
2501 ✓
2502 T}@T{
2503 ✓
2504 T}@T{
2505 ✓
2506 T}@T{
2507 ✓
2508 T}@T{
2509 ✓
2510 T}@T{
2511 ✓
2512 T}
2513 T{
2514 \f[CR]zstd\f[R]
2515 T}@T{
2516 ✓
2517 T}@T{
2518 ✓
2519 T}@T{
2520 ✓
2521 T}@T{
2522 ✓
2523 T}@T{
2524 ✓
2525 T}@T{
2526 ✓
2527 T}@T{
2528 ✓
2529 T}
2530 T{
2531 \f[CR]zypper\f[R]
2532 T}@T{
2533 ✓
2534 T}@T{
2535 T}@T{
2536 ✓
2537 T}@T{
2538 ✓
2539 T}@T{
2540 ✓
2541 T}@T{
2542 T}@T{
2543 ✓
2544 T}
2545 .TE
2546 .RE
2547 .TP
2548 \f[CR]ToolsTreeDistribution=\f[R], \f[CR]\-\-tools\-tree\-distribution=\f[R]
2549 Set the distribution to use for the default tools tree.
2550 Defaults to the host distribution except for Ubuntu, which defaults to
2551 Debian, and RHEL, CentOS, Alma and Rocky, which default to Fedora, or
2552 \f[CR]custom\f[R] if the distribution of the host is not a supported
2553 distribution.
2554 .TP
2555 \f[CR]ToolsTreeRelease=\f[R], \f[CR]\-\-tools\-tree\-release=\f[R]
2556 Set the distribution release to use for the default tools tree.
2557 By default, the hardcoded default release in \f[B]mkosi\f[R] for the
2558 distribution is used.
2559 .TP
2560 \f[CR]ToolsTreeMirror=\f[R], \f[CR]\-\-tools\-tree\-mirror=\f[R]
2561 Set the mirror to use for the default tools tree.
2562 By default, the default mirror for the tools tree distribution is used.
2563 .TP
2564 \f[CR]ToolsTreeRepositories=\f[R], \f[CR]\-\-tools\-tree\-repository\f[R]
2565 Same as \f[CR]Repositories=\f[R] but for the default tools tree.
2566 .TP
2567 \f[CR]ToolsTreeSandboxTrees=\f[R], \f[CR]\-\-tools\-tree\-sandbox\-tree\f[R]
2568 Same as \f[CR]SandboxTrees=\f[R] but for the default tools tree.
2569 .TP
2570 \f[CR]ToolsTreePackages=\f[R], \f[CR]\-\-tools\-tree\-package=\f[R]
2571 Extra packages to install into the default tools tree.
2572 Takes a comma separated list of package specifications.
2573 This option may be used multiple times in which case the specified
2574 package lists are combined.
2575 .TP
2576 \f[CR]ToolsTreePackageDirectories=\f[R], \f[CR]\-\-tools\-tree\-package\-directory=\f[R]
2577 Same as \f[CR]PackageDirectories=\f[R], but for the default tools tree.
2578 .TP
2579 \f[CR]ToolsTreeCertificates=\f[R], \f[CR]\-\-tools\-tree\-certificates=\f[R]
2580 Specify whether to use certificates and keys from the tools tree.
2581 Enabled by default.
2582 If enabled, \f[CR]/etc/pki\f[R], \f[CR]/etc/ssl\f[R],
2583 \f[CR]/etc/ca\-certificates\f[R], and
2584 \f[CR]/var/lib/ca\-certificates\f[R] from the tools tree are used.
2585 Otherwise, these directories are picked up from the host.
2586 .TP
2587 \f[CR]ExtraSearchPaths=\f[R], \f[CR]\-\-extra\-search\-path=\f[R]
2588 List of colon\-separated paths to look for tools in, before using the
2589 regular \f[CR]$PATH\f[R] search path.
2590 .TP
2591 \f[CR]Incremental=\f[R], \f[CR]\-\-incremental=\f[R], \f[CR]\-i\f[R]
2592 Takes either \f[CR]strict\f[R] or a boolean value as its argument.
2593 Enables incremental build mode.
2594 In this mode, a copy of the OS image is created immediately after all OS
2595 packages are installed and the prepare scripts have executed but before
2596 the \f[CR]mkosi.build\f[R] scripts are invoked (or anything that happens
2597 after it).
2598 On subsequent invocations of \f[B]mkosi\f[R] with the \f[CR]\-i\f[R]
2599 switch this cached image may be used to skip the OS package
2600 installation, thus drastically speeding up repetitive build times.
2601 Note that while there is some rudimentary cache invalidation, it is
2602 definitely not perfect.
2603 In order to force a rebuild of the cached image, combine \f[CR]\-i\f[R]
2604 with \f[CR]\-ff\f[R] to ensure the cached image is first removed and
2605 then re\-created.
2606 .RS
2607 .PP
2608 If set to \f[CR]strict\f[R], the build fails if previously built cached
2609 image does not exist.
2610 .RE
2611 .TP
2612 \f[CR]CacheOnly=\f[R], \f[CR]\-\-cache\-only=\f[R]
2613 Takes one of \f[CR]auto\f[R], \f[CR]metadata\f[R], \f[CR]always\f[R] or
2614 \f[CR]never\f[R].
2615 Defaults to \f[CR]auto\f[R].
2616 If \f[CR]always\f[R], the package manager is instructed not to contact
2617 the network.
2618 This provides a minimal level of reproducibility, as long as the package
2619 cache is already fully populated.
2620 If set to \f[CR]metadata\f[R], the package manager can still download
2621 packages, but we won\[cq]t sync the repository metadata.
2622 If set to \f[CR]auto\f[R], the repository metadata is synced unless we
2623 have a cached image (see \f[CR]Incremental=\f[R]) and packages can be
2624 downloaded during the build.
2625 If set to \f[CR]never\f[R], repository metadata is always synced and
2626 packages can be downloaded during the build.
2627 .TP
2628 \f[CR]SandboxTrees=\f[R], \f[CR]\-\-sandbox\-tree=\f[R]
2629 Takes a comma\-separated list of colon\-separated path pairs.
2630 The first path of each pair refers to a directory to copy into the mkosi
2631 sandbox before executing a tool.
2632 If the \f[CR]mkosi.sandbox/\f[R] directory is found in the local
2633 directory it is used for this purpose with the root directory as target
2634 (also see the \f[B]Files\f[R] section below).
2635 .RS
2636 .PP
2637 \f[B]mkosi\f[R] will look for the package manager configuration and
2638 related files in the configured sandbox trees.
2639 Unless specified otherwise, it will use the configuration files from
2640 their canonical locations in \f[CR]/usr\f[R] or \f[CR]/etc\f[R] in the
2641 sandbox trees.
2642 For example, it will look for \f[CR]/etc/dnf/dnf.conf\f[R] in the
2643 sandbox trees if \f[B]dnf\f[R] is used to install packages.
2644 .RE
2645 .TP
2646 \f[CR]WorkspaceDirectory=\f[R], \f[CR]\-\-workspace\-directory=\f[R]
2647 Path to a directory where to store data required temporarily while
2648 building the image.
2649 This directory should have enough space to store the full OS image,
2650 though in most modes the actually used disk space is smaller.
2651 If not specified, a subdirectory of \f[CR]$XDG_CACHE_HOME\f[R] (if set),
2652 \f[CR]$HOME/.cache\f[R] (if set) or \f[CR]/var/tmp\f[R] is used.
2653 .RS
2654 .PP
2655 The data in this directory is removed automatically after each build.
2656 It\[cq]s safe to manually remove the contents of this directory should
2657 an \f[B]mkosi\f[R] invocation be aborted abnormally (for example, due to
2658 reboot/power failure).
2659 .RE
2660 .TP
2661 \f[CR]CacheDirectory=\f[R], \f[CR]\-\-cache\-directory=\f[R]
2662 Takes a path to a directory to use as the incremental cache directory
2663 for the incremental images produced when the \f[CR]Incremental=\f[R]
2664 option is enabled.
2665 If this option is not used, but a \f[CR]mkosi.cache/\f[R] directory is
2666 found in the local directory it is automatically used for this purpose.
2667 .TP
2668 \f[CR]PackageCacheDirectory=\f[R], \f[CR]\-\-package\-cache\-dir\f[R]
2669 Takes a path to a directory to use as the package cache directory for
2670 the distribution package manager used.
2671 If unset, but a \f[CR]mkosi.pkgcache/\f[R] directory is found in the
2672 local directory it is automatically used for this purpose, otherwise a
2673 suitable directory in the user\[cq]s home directory or system is used.
2674 .TP
2675 \f[CR]BuildDirectory=\f[R], \f[CR]\-\-build\-directory=\f[R]
2676 Takes a path to a directory to use as the build directory for build
2677 systems that support out\-of\-tree builds (such as Meson).
2678 The directory used this way is shared between repeated builds, and
2679 allows the build system to reuse artifacts (such as object files,
2680 executable, \&...)
2681 generated on previous invocations.
2682 The build scripts can find the path to this directory in the
2683 \f[CR]$BUILDDIR\f[R] environment variable.
2684 This directory is mounted into the image\[cq]s root directory when
2685 \f[B]mkosi\-chroot\f[R] is invoked during execution of the build
2686 scripts.
2687 If this option is not specified, but a directory
2688 \f[CR]mkosi.builddir/\f[R] exists in the local directory it is
2689 automatically used for this purpose (also see the \f[B]Files\f[R]
2690 section below).
2691 .TP
2692 \f[CR]UseSubvolumes=\f[R], \f[CR]\-\-use\-subvolumes=\f[R]
2693 Takes a boolean or \f[CR]auto\f[R].
2694 Enables or disables use of btrfs subvolumes for directory tree outputs.
2695 If enabled, \f[B]mkosi\f[R] will create the root directory as a btrfs
2696 subvolume and use btrfs subvolume snapshots where possible to copy base
2697 or cached trees which is much faster than doing a recursive copy.
2698 If explicitly enabled and \f[CR]btrfs\f[R] is not installed or
2699 subvolumes cannot be created, an error is raised.
2700 If \f[CR]auto\f[R], missing \f[B]btrfs\f[R] or failures to create
2701 subvolumes are ignored.
2702 .TP
2703 \f[CR]RepartOffline=\f[R], \f[CR]\-\-repart\-offline=\f[R]
2704 Specifies whether to build disk images using loopback devices.
2705 Enabled by default.
2706 When enabled, \f[B]systemd\-repart\f[R] will not use loopback devices to
2707 build disk images.
2708 When disabled, \f[B]systemd\-repart\f[R] will always use loopback
2709 devices to build disk images.
2710 .RS
2711 .PP
2712 Note that when using \f[CR]RepartOffline=no\f[R]\f[B]mkosi\f[R] cannot
2713 run unprivileged and the image build has to be done as the root user
2714 outside of any containers and with loopback devices available on the
2715 host system.
2716 .PP
2717 There are currently two known scenarios where
2718 \f[CR]RepartOffline=no\f[R] has to be used.
2719 The first is when using \f[CR]Subvolumes=\f[R] in a repart partition
2720 definition file, as subvolumes cannot be created without using loopback
2721 devices.
2722 The second is when creating a system with SELinux and an XFS root
2723 partition.
2724 Because \f[B]mkfs.xfs\f[R] does not support populating an XFS filesystem
2725 with extended attributes, loopback devices have to be used to ensure the
2726 SELinux extended attributes end up in the generated XFS filesystem.
2727 .RE
2728 .TP
2729 \f[CR]History=\f[R], \f[CR]\-\-history=\f[R]
2730 Takes a boolean.
2731 If enabled, \f[B]mkosi\f[R] will write information about the latest
2732 build to the \f[CR].mkosi\-private\f[R] subdirectory in the directory
2733 from which it was invoked.
2734 This information is then used to restore the config of the latest build
2735 when running any verb that needs a build without specifying
2736 \f[CR]\-\-force\f[R].
2737 .RS
2738 .PP
2739 To give an example of why this is useful, if you run
2740 \f[CR]mkosi \-O my\-custom\-output\-dir \-f\f[R] followed by
2741 \f[CR]mkosi vm\f[R], \f[B]mkosi\f[R] will fail saying the image
2742 hasn\[cq]t been built yet.
2743 If you run
2744 \f[CR]mkosi \-O my\-custom\-output\-dir \-\-history=yes \-f\f[R]
2745 followed by \f[CR]mkosi vm\f[R], it will boot the image built in the
2746 previous step as expected.
2747 .RE
2748 .TP
2749 \f[CR]BuildSources=\f[R], \f[CR]\-\-build\-sources=\f[R]
2750 Takes a comma\-separated list of colon\-separated path pairs.
2751 The first path of each pair refers to a directory to mount from the
2752 host.
2753 The second path of each pair refers to the directory where the source
2754 directory should be mounted when running scripts.
2755 Every target path is prefixed with \f[CR]/work/src\f[R] and all build
2756 sources are sorted lexicographically by their target before mounting, so
2757 that top level paths are mounted first.
2758 If not configured explicitly, the current working directory is mounted
2759 to \f[CR]/work/src\f[R].
2760 .TP
2761 \f[CR]BuildSourcesEphemeral=\f[R], \f[CR]\-\-build\-sources\-ephemeral=\f[R]
2762 Takes a boolean or the special value \f[CR]buildcache\f[R].
2763 Disabled by default.
2764 Configures whether changes to source directories, the working directory
2765 and configured using \f[CR]BuildSources=\f[R], are persisted.
2766 If enabled, all source directories will be reset to their original state
2767 every time after running all scripts of a specific type (except sync
2768 scripts).
2769 .RS
2770 .PP
2771 💥💣💥 If set to \f[CR]buildcache\f[R] the overlay is not discarded when
2772 running build scripts, but saved to the build directory, configured via
2773 \f[CR]BuildDirectory=\f[R], and will be reused on subsequent runs.
2774 The overlay is still discarded for all other scripts.
2775 This option can be used to implement more advanced caching of builds,
2776 but can lead to unexpected states of the source directory.
2777 When using this option, a build directory must be configured.
2778 💥💣💥
2779 .RE
2780 .TP
2781 \f[CR]Environment=\f[R], \f[CR]\-\-environment=\f[R]
2782 Adds variables to the environment that package managers and the
2783 prepare/build/postinstall/finalize scripts are executed with.
2784 Takes a space\-separated list of variable assignments or just variable
2785 names.
2786 In the latter case, the values of those variables will be passed through
2787 from the environment in which \f[B]mkosi\f[R] was invoked.
2788 This option may be specified more than once, in which case all listed
2789 variables will be set.
2790 If the same variable is set twice, the later setting overrides the
2791 earlier one.
2792 .TP
2793 \f[CR]EnvironmentFiles=\f[R], \f[CR]\-\-env\-file=\f[R]
2794 Takes a comma\-separated list of paths to files that contain environment
2795 variable definitions to be added to the scripting environment.
2796 Uses \f[CR]mkosi.env\f[R] if it is found in the local directory.
2797 The variables are first read from \f[CR]mkosi.env\f[R] if it exists,
2798 then from the given list of files and then from the
2799 \f[CR]Environment=\f[R] settings.
2800 .TP
2801 \f[CR]WithTests=\f[R], \f[CR]\-\-without\-tests\f[R], \f[CR]\-T\f[R]
2802 If set to false (or when the command\-line option is used), the
2803 \f[CR]$WITH_TESTS\f[R] environment variable is set to \f[CR]0\f[R] when
2804 the \f[CR]mkosi.build\f[R] scripts are invoked.
2805 This is supposed to be used by the build scripts to bypass any unit or
2806 integration tests that are normally run during the source build process.
2807 Note that this option has no effect unless the \f[CR]mkosi.build\f[R]
2808 build scripts honor it.
2809 .TP
2810 \f[CR]WithNetwork=\f[R], \f[CR]\-\-with\-network=\f[R]
2811 When true, enables network connectivity while the build scripts
2812 \f[CR]mkosi.build\f[R] are invoked.
2813 By default, the build scripts run with networking turned off.
2814 The \f[CR]$WITH_NETWORK\f[R] environment variable is passed to the
2815 \f[CR]mkosi.build\f[R] build scripts indicating whether the build is
2816 done with or without network.
2817 .TP
2818 \f[CR]ProxyUrl=\f[R], \f[CR]\-\-proxy\-url=\f[R]
2819 Configure a proxy to be used for all outgoing network connections.
2820 Various tools that \f[B]mkosi\f[R] invokes and for which the proxy can
2821 be configured are configured to use this proxy.
2822 \f[B]mkosi\f[R] also sets various well\-known environment variables to
2823 specify the proxy to use for any programs it invokes that may need
2824 internet access.
2825 .TP
2826 \f[CR]ProxyExclude=\f[R], \f[CR]\-\-proxy\-exclude=\f[R]
2827 Configure hostnames for which requests should not go through the proxy.
2828 Takes a comma\-separated list of hostnames.
2829 .TP
2830 \f[CR]ProxyPeerCertificate=\f[R], \f[CR]\-\-proxy\-peer\-certificate=\f[R]
2831 Configure a file containing certificates used to verify the proxy.
2832 Defaults to the system\-wide certificate store.
2833 .RS
2834 .PP
2835 Currently, setting a proxy peer certificate is only supported when
2836 \f[B]dnf\f[R] or \f[B]dnf5\f[R] is used to build the image.
2837 .RE
2838 .TP
2839 \f[CR]ProxyClientCertificate=\f[R], \f[CR]\-\-proxy\-client\-certificate=\f[R]
2840 Configure a file containing the certificate used to authenticate the
2841 client with the proxy.
2842 .RS
2843 .PP
2844 Currently, setting a proxy client certificate is only supported when
2845 \f[B]dnf\f[R] or \f[B]dnf5\f[R] is used to build the image.
2846 .RE
2847 .TP
2848 \f[CR]ProxyClientKey=\f[R], \f[CR]\-\-proxy\-client\-key=\f[R]
2849 Configure a file containing the private key used to authenticate the
2850 client with the proxy.
2851 Defaults to the proxy client certificate if one is provided.
2852 .RS
2853 .PP
2854 Currently, setting a proxy client key is only supported when
2855 \f[B]dnf\f[R] or \f[B]dnf5\f[R] is used to build the image.
2856 .RE
2857 .SS [Runtime] Section (previously known as the [Host] section)
2858 .TP
2859 \f[CR]NSpawnSettings=\f[R], \f[CR]\-\-settings=\f[R]
2860 Specifies a \f[CR].nspawn\f[R] settings file for
2861 \f[B]systemd\-nspawn\f[R] to use in the \f[CR]boot\f[R] and
2862 \f[CR]shell\f[R] verbs, and to place next to the generated image file.
2863 This is useful to configure the \f[B]systemd\-nspawn\f[R] environment
2864 when the image is run.
2865 If this setting is not used but an \f[CR]mkosi.nspawn\f[R] file found in
2866 the local directory it is automatically used for this purpose.
2867 .TP
2868 \f[CR]VirtualMachineMonitor=\f[R], \f[CR]\-\-vmm=\f[R]
2869 Configures the virtual machine monitor to use.
2870 Takes one of \f[CR]qemu\f[R] or \f[CR]vmspawn\f[R].
2871 Defaults to \f[CR]qemu\f[R].
2872 .RS
2873 .PP
2874 When set to \f[CR]qemu\f[R], the image is booted with \f[B]qemu\f[R].
2875 Most output formats can be booted in \f[B]qemu\f[R].
2876 Any arguments specified after the verb are appended to the
2877 \f[B]qemu\f[R] invocation and are interpreted as extra \f[B]qemu\f[R]
2878 command line arguments.
2879 .PP
2880 When set to \f[CR]vmspawn\f[R], \f[B]systemd\-vmspawn\f[R] is used to
2881 boot up the image, \f[CR]vmspawn\f[R] only supports disk and directory
2882 type images.
2883 Any arguments specified after the verb are appended to the
2884 \f[B]systemd\-vmspawn\f[R] invocation and are interpreted as extra
2885 vmspawn options and extra kernel command line arguments.
2886 .RE
2887 .TP
2888 \f[CR]Console=\f[R], \f[CR]\-\-console=\f[R]
2889 Configures how to set up the console of the VM.
2890 Takes one of \f[CR]interactive\f[R], \f[CR]read\-only\f[R],
2891 \f[CR]native\f[R], or \f[CR]gui\f[R].
2892 Defaults to \f[CR]interactive\f[R].
2893 \f[CR]interactive\f[R] provides an interactive terminal interface to the
2894 VM.
2895 \f[CR]read\-only\f[R] is similar, but is strictly read\-only, i.e.\ does
2896 not accept any input from the user.
2897 \f[CR]native\f[R] also provides a TTY\-based interface, but uses
2898 \f[B]qemu\f[R]\[cq]s native implementation (which means the
2899 \f[B]qemu\f[R] monitor is available).
2900 \f[CR]gui\f[R] shows the \f[B]qemu\f[R] graphical UI.
2901 .TP
2902 \f[CR]CPUs=\f[R], \f[CR]\-\-cpus=\f[R]
2903 Configures the number of CPU cores to assign to the guest when booting a
2904 virtual machine.
2905 Defaults to \f[CR]2\f[R].
2906 .RS
2907 .PP
2908 When set to \f[CR]0\f[R], the number of CPUs available to the
2909 \f[B]mkosi\f[R] process will be used.
2910 .RE
2911 .TP
2912 \f[CR]RAM=\f[R], \f[CR]\-\-ram=\f[R]
2913 Configures the amount of RAM assigned to the guest when booting a
2914 virtual machine.
2915 Defaults to \f[CR]2G\f[R].
2916 .TP
2917 \f[CR]KVM=\f[R], \f[CR]\-\-kvm=\f[R]
2918 Configures whether KVM acceleration should be used when booting a
2919 virtual machine.
2920 Takes a boolean value or \f[CR]auto\f[R].
2921 Defaults to \f[CR]auto\f[R].
2922 .TP
2923 \f[CR]Vsock=\f[R], \f[CR]\-\-vsock=\f[R]
2924 Configures whether to provision a vsock when booting a virtual machine.
2925 Takes a boolean value or \f[CR]auto\f[R].
2926 Defaults to \f[CR]auto\f[R].
2927 .TP
2928 \f[CR]VsockConnectionId=\f[R], \f[CR]vsock\-cid=\f[R]
2929 Configures the vsock connection ID to use when booting a virtual
2930 machine.
2931 Takes a number in the interval \f[CR][3, 0xFFFFFFFF)\f[R] or
2932 \f[CR]hash\f[R] or \f[CR]auto\f[R].
2933 Defaults to \f[CR]auto\f[R].
2934 When set to \f[CR]hash\f[R], the connection ID will be derived from the
2935 full path to the image.
2936 When set to \f[CR]auto\f[R], \f[B]mkosi\f[R] will try to find a free
2937 connection ID automatically.
2938 Otherwise, the provided number will be used as is.
2939 .TP
2940 \f[CR]TPM=\f[R], \f[CR]\-\-tpm=\f[R]
2941 Configure whether to use a virtual TPM when booting a virtual machine.
2942 Takes a boolean value or \f[CR]auto\f[R].
2943 Defaults to \f[CR]auto\f[R].
2944 .TP
2945 \f[CR]CDROM=\f[R], \f[CR]\-\-cdrom=\f[R]
2946 Configures whether to attach the image as a CD\-ROM device when booting
2947 a virtual machine.
2948 Takes a boolean.
2949 Defaults to \f[CR]no\f[R].
2950 .TP
2951 \f[CR]Removable=\f[R], \f[CR]\-\-removable=\f[R]
2952 Configures whether to attach the image as a removable device when
2953 booting a virtual machine.
2954 Takes a boolean.
2955 Defaults to \f[CR]no\f[R].
2956 .TP
2957 \f[CR]Firmware=\f[R], \f[CR]\-\-firmware=\f[R]
2958 Configures the virtual machine firmware to use.
2959 Takes one of \f[CR]uefi\f[R], \f[CR]uefi\-secure\-boot\f[R],
2960 \f[CR]bios\f[R], \f[CR]linux\f[R], or \f[CR]auto\f[R].
2961 Defaults to \f[CR]auto\f[R].
2962 When set to \f[CR]uefi\f[R], the OVMF firmware without secure boot
2963 support is used.
2964 When set to \f[CR]uefi\-secure\-boot\f[R], the OVMF firmware with secure
2965 boot support is used.
2966 When set to \f[CR]bios\f[R], the default SeaBIOS firmware is used.
2967 When set to \f[CR]linux\f[R], direct kernel boot is used.
2968 See the \f[CR]Linux=\f[R] option for more details on which kernel image
2969 is used with direct kernel boot.
2970 When set to \f[CR]auto\f[R], \f[CR]uefi\-secure\-boot\f[R] is used if
2971 possible and \f[CR]linux\f[R] otherwise.
2972 .TP
2973 \f[CR]FirmwareVariables=\f[R], \f[CR]\-\-firmware\-variables=\f[R]
2974 Configures the path to the the virtual machine firmware variables file
2975 to use.
2976 Currently, this option is only taken into account when the
2977 \f[CR]uefi\f[R] or \f[CR]uefi\-secure\-boot\f[R] firmware is used.
2978 If not specified, \f[B]mkosi\f[R] will search for the default variables
2979 file and use that instead.
2980 .RS
2981 .PP
2982 When set to \f[CR]microsoft\f[R], a firmware variables file with the
2983 Microsoft secure boot certificates already enrolled will be used.
2984 .PP
2985 When set to \f[CR]microsoft\-mok\f[R], a firmware variables file with
2986 the Microsoft secure boot certificates already enrolled will be extended
2987 with a \f[CR]MokList\f[R] variable containing the secure boot
2988 certificate from \f[CR]SecureBootCertificate=\f[R].
2989 This is intended to be used together with shim binaries signed by the
2990 distribution and locally signed EFI binaries.
2991 .PP
2992 When set to \f[CR]custom\f[R], the secure boot certificate from
2993 \f[CR]SecureBootCertificate=\f[R] will be enrolled into the default
2994 firmware variables file.
2995 .PP
2996 \f[CR]virt\-fw\-vars\f[R] from the \c
2997 .UR https://gitlab.com/kraxel/virt-firmware
2998 virt\-firmware
2999 .UE \c
3000 \ project can be used to customize OVMF variable files.
3001 .RE
3002 .TP
3003 \f[CR]Linux=\f[R], \f[CR]\-\-linux=\f[R]
3004 Set the kernel image to use for \f[B]qemu\f[R] direct kernel boot.
3005 If not specified, \f[B]mkosi\f[R] will use the kernel provided via the
3006 command line (\f[CR]\-kernel\f[R] option) or latest the kernel that was
3007 installed into the image (or fail if no kernel was installed into the
3008 image).
3009 .RS
3010 .PP
3011 Note that when the \f[CR]cpio\f[R] output format is used, direct kernel
3012 boot is used regardless of the configured firmware.
3013 Depending on the configured firmware, \f[B]qemu\f[R] might boot the
3014 kernel itself or using the configured firmware.
3015 .RE
3016 .TP
3017 \f[CR]Drives=\f[R], \f[CR]\-\-drive=\f[R]
3018 Add a drive.
3019 Takes a colon\-delimited string of format
3020 \f[CR]<id>:<size>[:<directory>[:<options>[:<file\-id>]]]\f[R].
3021 \f[CR]id\f[R] specifies the ID assigned to the drive.
3022 This can be used as the \f[CR]drive=\f[R] property in various
3023 \f[B]qemu\f[R] devices.
3024 \f[CR]size\f[R] specifies the size of the drive.
3025 This takes a size in bytes.
3026 Additionally, the suffixes \f[CR]K\f[R], \f[CR]M\f[R] and \f[CR]G\f[R]
3027 can be used to specify a size in kilobytes, megabytes and gigabytes
3028 respectively.
3029 \f[CR]directory\f[R] optionally specifies the directory in which to
3030 create the file backing the drive.
3031 \f[CR]options\f[R] optionally specifies extra comma\-delimited
3032 properties which are passed verbatim to \f[B]qemu\f[R]\[cq]s
3033 \f[CR]\-drive\f[R] option.
3034 \f[CR]file\-id\f[R] specifies the ID of the file backing the drive.
3035 Drives with the same file ID will share the backing file.
3036 The directory and size of the file will be determined from the first
3037 drive with a given file ID.
3038 .RS
3039 .PP
3040 \f[B]Example usage:\f[R]
3041 .IP
3042 .EX
3043 \f[B][Runtime]\f[R]
3044 Drives=btrfs:10G
3045 ext4:20G
3046 QemuArgs=\-device nvme,serial=btrfs,drive=btrfs
3047 \-device nvme,serial=ext4,drive=ext4
3048 .EE
3049 .RE
3050 .TP
3051 \f[CR]QemuArgs=\f[R]
3052 Space\-delimited list of additional arguments to pass when invoking
3053 \f[B]qemu\f[R].
3054 .TP
3055 \f[CR]Ephemeral=\f[R], \f[CR]\-\-ephemeral\f[R]
3056 When used with the \f[CR]shell\f[R], \f[CR]boot\f[R], or \f[CR]vm\f[R]
3057 verbs, this option runs the specified verb on a temporary snapshot of
3058 the output image that is removed immediately when the container
3059 terminates.
3060 Taking the temporary snapshot is more efficient on file systems that
3061 support reflinks natively (\f[B]btrfs\f[R] or \f[B]xfs\f[R]) than on
3062 more traditional file systems that do not (ext4).
3063 .TP
3064 \f[CR]Credentials=\f[R], \f[CR]\-\-credential=\f[R]
3065 Set credentials to be passed to \f[B]systemd\-nspawn\f[R] or the virtual
3066 machine respectively when \f[CR]mkosi shell/boot\f[R] or
3067 \f[CR]mkosi vm\f[R] are used.
3068 This option takes a space separated list of values which can be either
3069 key=value pairs or paths.
3070 If a path is provided, if it is a file, the credential name will be the
3071 name of the file.
3072 If the file is executable, the credential value will be the output of
3073 executing the file.
3074 Otherwise, the credential value will be the contents of the file.
3075 If the path is a directory, the same logic applies to each file in the
3076 directory.
3077 .RS
3078 .PP
3079 Note that values will only be treated as paths if they do not contain
3080 the delimiter (\f[CR]=\f[R]).
3081 .RE
3082 .TP
3083 \f[CR]KernelCommandLineExtra=\f[R], \f[CR]\-\-kernel\-command\-line\-extra=\f[R]
3084 Set extra kernel command line entries that are appended to the kernel
3085 command line at runtime when booting the image.
3086 When booting in a container, these are passed as extra arguments to
3087 systemd.
3088 When booting in a VM, these are appended to the kernel command line via
3089 the SMBIOS io.systemd.stub.kernel\-cmdline\-extra OEM string.
3090 This will only be picked up by \f[B]systemd\-boot\f[R] and
3091 \f[B]systemd\-stub\f[R] versions newer than or equal to v254.
3092 .TP
3093 \f[CR]RuntimeTrees=\f[R], \f[CR]\-\-runtime\-tree=\f[R]
3094 Takes a colon\-separated pair of paths.
3095 The first path refers to a directory to mount into any machine
3096 (container or VM) started by mkosi.
3097 The second path refers to the target directory inside the machine.
3098 If the second path is not provided, the directory is mounted at
3099 \f[CR]/root/src\f[R] in the machine.
3100 If the second path is relative, it is interpreted relative to
3101 \f[CR]/root/src\f[R] in the machine.
3102 .RS
3103 .PP
3104 For each mounted directory, the uid and gid of the user running mkosi
3105 are mapped to the root user in the machine.
3106 This means that all the files and directories will appear as if
3107 they\[cq]re owned by root in the machine, and all new files and
3108 directories created by root in the machine in these directories will be
3109 owned by the user running mkosi on the host.
3110 .PP
3111 Note that when using \f[CR]mkosi vm\f[R] with this feature systemd v254
3112 or newer has to be installed in the image.
3113 .RE
3114 .TP
3115 \f[CR]RuntimeSize=\f[R], \f[CR]\-\-runtime\-size=\f[R]
3116 If specified, disk images are grown to the specified size when
3117 they\[cq]re booted with \f[CR]mkosi boot\f[R] or \f[CR]mkosi vm\f[R].
3118 Takes a size in bytes.
3119 Additionally, the suffixes \f[CR]K\f[R], \f[CR]M\f[R] and \f[CR]G\f[R]
3120 can be used to specify a size in kilobytes, megabytes and gigabytes
3121 respectively.
3122 .TP
3123 \f[CR]RuntimeScratch=\f[R], \f[CR]\-\-runtime\-scratch=\f[R]
3124 Takes a boolean value or \f[CR]auto\f[R].
3125 Specifies whether to mount extra scratch space to \f[CR]/var/tmp\f[R].
3126 If enabled, practically unlimited scratch space is made available under
3127 \f[CR]/var/tmp\f[R] when booting the image with \f[CR]mkosi vm\f[R],
3128 \f[CR]mkosi boot\f[R] or \f[CR]mkosi shell\f[R].
3129 .RS
3130 .PP
3131 Note that using this feature with \f[CR]mkosi vm\f[R] requires systemd
3132 v254 or newer in the guest.
3133 .RE
3134 .TP
3135 \f[CR]RuntimeNetwork=\f[R], \f[CR]\-\-runtime\-network=\f[R]
3136 Takes one of \f[CR]user\f[R], \f[CR]interface\f[R] or \f[CR]none\f[R].
3137 Defaults to \f[CR]user\f[R].
3138 Specifies the networking to set up when booting the image.
3139 \f[CR]user\f[R] sets up usermode networking.
3140 \f[CR]interface\f[R] sets up a virtual network connection between the
3141 host and the image.
3142 This translates to a veth interface for \f[CR]mkosi shell\f[R] and
3143 \f[CR]mkosi boot\f[R] and a tap interface for \f[CR]mkosi vm\f[R] and
3144 \f[CR]mkosi vmspawn\f[R].
3145 .RS
3146 .PP
3147 Note that when using \f[CR]interface\f[R], \f[B]mkosi\f[R] does not
3148 automatically configure the host interface.
3149 It is expected that a recent version of \f[B]systemd\-networkd\f[R] is
3150 running on the host which will automatically configure the host
3151 interface of the link.
3152 .RE
3153 .TP
3154 \f[CR]RuntimeBuildSources=\f[R], \f[CR]\-\-runtime\-build\-sources=\f[R]
3155 Mount the build sources configured with \f[CR]BuildSources=\f[R] and the
3156 build directory (if one is configured) to the same locations in
3157 \f[CR]/work\f[R] that they were mounted to when running the build script
3158 when using \f[CR]mkosi boot\f[R] or \f[CR]mkosi vm\f[R].
3159 .TP
3160 \f[CR]RuntimeHome=\f[R], \f[CR]\-\-runtime\-home=\f[R]
3161 Mount the current home directory from which \f[B]mkosi\f[R] is running
3162 to \f[CR]/root\f[R] when using \f[CR]mkosi boot\f[R] or
3163 \f[CR]mkosi vm\f[R].
3164 .TP
3165 \f[CR]UnitProperties=\f[R], \f[CR]\-\-unit\-property=\f[R]
3166 Configure systemd unit properties to add to the systemd scopes allocated
3167 when using \f[CR]mkosi boot\f[R] or \f[CR]mkosi vm\f[R].
3168 These are passed directly to the \f[CR]\-\-property\f[R] options of
3169 \f[B]systemd\-nspawn\f[R] and \f[B]systemd\-run\f[R] respectively.
3170 .TP
3171 \f[CR]SshKey=\f[R], \f[CR]\-\-ssh\-key=\f[R]
3172 Path to the X.509 private key in PEM format to use to connect to a
3173 virtual machine started with \f[CR]mkosi vm\f[R] and built with the
3174 \f[CR]Ssh=\f[R] option enabled via the \f[CR]mkosi ssh\f[R] command.
3175 If not configured and \f[CR]mkosi.key\f[R] exists in the working
3176 directory, it will automatically be used for this purpose.
3177 Run \f[CR]mkosi genkey\f[R] to automatically generate a key in
3178 \f[CR]mkosi.key\f[R].
3179 .TP
3180 \f[CR]SshCertificate=\f[R], \f[CR]\-\-ssh\-certificate=\f[R]
3181 Path to the X.509 certificate in PEM format to provision as the SSH
3182 public key in virtual machines started with \f[CR]mkosi vm\f[R].
3183 If not configured and \f[CR]mkosi.crt\f[R] exists in the working
3184 directory, it will automatically be used for this purpose.
3185 Run \f[CR]mkosi genkey\f[R] to automatically generate a certificate in
3186 \f[CR]mkosi.crt\f[R].
3187 .TP
3188 \f[CR]Machine=\f[R], \f[CR]\-\-machine=\f[R]
3189 Specify the machine name to use when booting the image.
3190 Can also be used to refer to a specific image when SSH\-ing into an
3191 image (e.g.
3192 \f[CR]mkosi \-\-image=myimage ssh\f[R]).
3193 .RS
3194 .PP
3195 Note that \f[CR]Ephemeral=\f[R] has to be enabled to start multiple
3196 instances of the same image.
3197 .RE
3198 .TP
3199 \f[CR]Register=\f[R], \f[CR]\-\-register=\f[R]
3200 Takes a boolean value or \f[CR]auto\f[R].
3201 Specifies whether to register the vm/container with systemd\-machined.
3202 If enabled, mkosi will fail if it can\[cq]t register the vm/container
3203 with systemd\-machined.
3204 If disabled, mkosi will not register the vm/container with
3205 systemd\-machined.
3206 If \f[CR]auto\f[R], mkosi will register the vm/container with
3207 systemd\-machined if it is available.
3208 Defaults to \f[CR]auto\f[R].
3209 .TP
3210 \f[CR]ForwardJournal=\f[R], \f[CR]\-\-forward\-journal=\f[R]
3211 Specify the path to which journal logs from containers and virtual
3212 machines should be forwarded.
3213 If the path has the \f[CR].journal\f[R] extension, it is interpreted as
3214 a file to which the journal should be written.
3215 Otherwise, the path is interpreted as a directory to which the journal
3216 should be written.
3217 .RS
3218 .PP
3219 Note that systemd v256 or newer is required in the virtual machine for
3220 log forwarding to work.
3221 .PP
3222 Note that if a path with the \f[CR].journal\f[R] extension is given, the
3223 journal size is limited to \f[CR]4G\f[R].
3224 Configure an output directory instead of file if your workload produces
3225 more than \f[CR]4G\f[R] worth of journal data.
3226 .RE
3227 .TP
3228 \f[CR]SysupdateDirectory=\f[R], \f[CR]\-\-sysupdate\-directory=\f[R]
3229 Path to a directory containing systemd\-sysupdate transfer definition
3230 files that are used by \f[CR]mkosi sysupdate\f[R].
3231 If \f[CR]mkosi.sysupdate/\f[R] exists in the local directory, it will be
3232 used for this purpose as well.
3233 .RS
3234 .PP
3235 Note that \f[CR]mkosi sysupdate\f[R] invokes
3236 \f[CR]systemd\-sysupdate\f[R] with \f[CR]\-\-transfer\-source=\f[R] set
3237 to the \f[B]mkosi\f[R] output directory.
3238 To make use of this in a transfer definition file, set
3239 \f[CR]PathRelativeTo=explicit\f[R] to have the \f[CR]Path=\f[R] setting
3240 for the transfer source be interpreted relative to the \f[B]mkosi\f[R]
3241 output directory.
3242 Generally, configuring \f[CR]PathRelativeTo=explicit\f[R] and
3243 \f[CR]Path=/\f[R] for the transfer source is sufficient for the match
3244 pattern to be interpreted relative to the \f[B]mkosi\f[R] output
3245 directory.
3246 .RE
3247 .SS [Match] Section
3248 .TP
3249 \f[CR]Profiles=\f[R]
3250 Matches against the configured profiles.
3251 .TP
3252 \f[CR]Distribution=\f[R]
3253 Matches against the configured distribution.
3254 .TP
3255 \f[CR]Release=\f[R]
3256 Matches against the configured distribution release.
3257 If this condition is used and no distribution has been explicitly
3258 configured yet, the host distribution and release are used.
3259 .TP
3260 \f[CR]Architecture=\f[R]
3261 Matches against the configured architecture.
3262 If this condition is used and no architecture has been explicitly
3263 configured yet, the host architecture is used.
3264 .TP
3265 \f[CR]Repositories=\f[R]
3266 Matches against repositories enabled with the \f[CR]Repositories=\f[R]
3267 setting.
3268 Takes a single repository name.
3269 .TP
3270 \f[CR]PathExists=\f[R]
3271 This condition is satisfied if the given path exists.
3272 Relative paths are interpreted relative to the parent directory of the
3273 config file that the condition is read from.
3274 .TP
3275 \f[CR]ImageId=\f[R]
3276 Matches against the configured image ID, supporting globs.
3277 If this condition is used and no image ID has been explicitly configured
3278 yet, this condition fails.
3279 .TP
3280 \f[CR]ImageVersion=\f[R]
3281 Matches against the configured image version.
3282 Image versions can be prepended by the operators \f[CR]==\f[R],
3283 \f[CR]!=\f[R], \f[CR]>=\f[R], \f[CR]<=\f[R], \f[CR]<\f[R], \f[CR]>\f[R]
3284 for rich version comparisons according to the UAPI group version format
3285 specification.
3286 If no operator is prepended, the equality operator is assumed by
3287 default.
3288 If this condition is used and no image version has been explicitly
3289 configured yet, this condition fails.
3290 .TP
3291 \f[CR]Bootable=\f[R]
3292 Matches against the configured value for the \f[CR]Bootable=\f[R]
3293 feature.
3294 Takes a boolean value or \f[CR]auto\f[R].
3295 .TP
3296 \f[CR]Format=\f[R]
3297 Matches against the configured value for the \f[CR]Format=\f[R] option.
3298 Takes an output format (see the \f[CR]Format=\f[R] option).
3299 .TP
3300 \f[CR]SystemdVersion=\f[R]
3301 Matches against the systemd version on the host (as reported by
3302 \f[CR]systemctl \-\-version\f[R]).
3303 Values can be prepended by the operators \f[CR]==\f[R], \f[CR]!=\f[R],
3304 \f[CR]>=\f[R], \f[CR]<=\f[R], \f[CR]<\f[R], \f[CR]>\f[R] for rich
3305 version comparisons according to the UAPI group version format
3306 specification.
3307 If no operator is prepended, the equality operator is assumed by
3308 default.
3309 .TP
3310 \f[CR]BuildSources=\f[R]
3311 Takes a build source target path (see \f[CR]BuildSources=\f[R]).
3312 This match is satisfied if any of the configured build sources uses this
3313 target path.
3314 For example, if we have a \f[CR]mkosi.conf\f[R] file containing:
3315 .RS
3316 .IP
3317 .EX
3318 \f[B][Build]\f[R]
3319 BuildSources=../abc/qed:kernel
3320 .EE
3321 .PP
3322 and a drop\-in containing:
3323 .IP
3324 .EX
3325 \f[B][Match]\f[R]
3326 BuildSources=kernel
3327 .EE
3328 .PP
3329 The drop\-in will be included.
3330 .PP
3331 Any absolute paths passed to this setting are interpreted relative to
3332 the current working directory.
3333 .RE
3334 .TP
3335 \f[CR]HostArchitecture=\f[R]
3336 Matches against the host\[cq]s native architecture.
3337 See the \f[CR]Architecture=\f[R] setting for a list of possible values.
3338 .TP
3339 \f[CR]ToolsTreeDistribution=\f[R]
3340 Matches against the configured tools tree distribution.
3341 .TP
3342 \f[CR]ToolsTreeRelease=\f[R]
3343 Matches against the configured tools tree release.
3344 .TP
3345 \f[CR]Environment=\f[R]
3346 Matches against a specific key/value pair configured with
3347 \f[CR]Environment=\f[R].
3348 If no value is provided, check if the given key is in the environment
3349 regardless of which value it has.
3350 .PP
3351 This table shows which matchers support globs, rich comparisons and the
3352 default value that is matched against if no value has been configured at
3353 the time the config file is read:
3354 .PP
3355 .TS
3356 tab(@);
3357 lw(13.1n) lw(3.5n) lw(9.1n) lw(44.3n).
3358 T{
3359 Matcher
3360 T}@T{
3361 Globs
3362 T}@T{
3363 Rich Comparisons
3364 T}@T{
3365 Default
3366 T}
3367 _
3368 T{
3369 \f[CR]Profiles=\f[R]
3370 T}@T{
3371 no
3372 T}@T{
3373 no
3374 T}@T{
3375 match fails
3376 T}
3377 T{
3378 \f[CR]Distribution=\f[R]
3379 T}@T{
3380 no
3381 T}@T{
3382 no
3383 T}@T{
3384 match host distribution
3385 T}
3386 T{
3387 \f[CR]Release=\f[R]
3388 T}@T{
3389 no
3390 T}@T{
3391 no
3392 T}@T{
3393 match host release
3394 T}
3395 T{
3396 \f[CR]Architecture=\f[R]
3397 T}@T{
3398 no
3399 T}@T{
3400 no
3401 T}@T{
3402 match host architecture
3403 T}
3404 T{
3405 \f[CR]PathExists=\f[R]
3406 T}@T{
3407 no
3408 T}@T{
3409 no
3410 T}@T{
3411 n/a
3412 T}
3413 T{
3414 \f[CR]ImageId=\f[R]
3415 T}@T{
3416 yes
3417 T}@T{
3418 no
3419 T}@T{
3420 match fails
3421 T}
3422 T{
3423 \f[CR]ImageVersion=\f[R]
3424 T}@T{
3425 no
3426 T}@T{
3427 yes
3428 T}@T{
3429 match fails
3430 T}
3431 T{
3432 \f[CR]Bootable=\f[R]
3433 T}@T{
3434 no
3435 T}@T{
3436 no
3437 T}@T{
3438 match auto feature
3439 T}
3440 T{
3441 \f[CR]Format=\f[R]
3442 T}@T{
3443 no
3444 T}@T{
3445 no
3446 T}@T{
3447 match default format
3448 T}
3449 T{
3450 \f[CR]SystemdVersion=\f[R]
3451 T}@T{
3452 no
3453 T}@T{
3454 yes
3455 T}@T{
3456 n/a
3457 T}
3458 T{
3459 \f[CR]BuildSources=\f[R]
3460 T}@T{
3461 no
3462 T}@T{
3463 no
3464 T}@T{
3465 match fails
3466 T}
3467 T{
3468 \f[CR]HostArchitecture=\f[R]
3469 T}@T{
3470 no
3471 T}@T{
3472 no
3473 T}@T{
3474 n/a
3475 T}
3476 T{
3477 \f[CR]ToolsTreeDistribution=\f[R]
3478 T}@T{
3479 no
3480 T}@T{
3481 no
3482 T}@T{
3483 match the fallback tools tree distribution (see
3484 \f[CR]ToolsTreeDistribution=\f[R] in \f[CR][Build]\f[R])
3485 T}
3486 T{
3487 \f[CR]ToolsTreeRelease=\f[R]
3488 T}@T{
3489 no
3490 T}@T{
3491 no
3492 T}@T{
3493 match default tools tree release
3494 T}
3495 T{
3496 \f[CR]Environment=\f[R]
3497 T}@T{
3498 no
3499 T}@T{
3500 no
3501 T}@T{
3502 n/a
3503 T}
3504 .TE
3505 .SS [Include]
3506 .TP
3507 \f[CR]Include=\f[R], \f[CR]\-\-include=\f[R], \f[CR]\-I\f[R]
3508 Include extra configuration from the given file or directory.
3509 The extra configuration is included immediately after parsing the
3510 setting, except when used on the command line, in which case the extra
3511 configuration is included after parsing all command line arguments.
3512 .RS
3513 .PP
3514 Note that each path containing extra configuration is only parsed once,
3515 even if included more than once with \f[CR]Include=\f[R].
3516 .PP
3517 The builtin configs for the \f[B]mkosi\f[R] default initrd, default
3518 tools tree and default virtual machine image can be included by
3519 including the literal value \f[CR]mkosi\-initrd\f[R],
3520 \f[CR]mkosi\-tools\f[R] or \f[CR]mkosi\-vm\f[R] respectively.
3521 .PP
3522 Note: Include names starting with either of the literals
3523 \f[CR]mkosi\-\f[R] or \f[CR]contrib\-\f[R] are reserved for use by
3524 \f[B]mkosi\f[R] itself.
3525 .RE
3526 .SS [Config] Section
3527 .TP
3528 \f[CR]Profiles=\f[R], \f[CR]\-\-profile=\f[R]
3529 Select the given profiles.
3530 A profile is a configuration file or directory in the
3531 \f[CR]mkosi.profiles/\f[R] directory.
3532 The configuration files and directories of each profile are included
3533 after parsing the \f[CR]mkosi.conf.d/*.conf\f[R] drop in configuration.
3534 .TP
3535 \f[CR]Dependencies=\f[R], \f[CR]\-\-dependency=\f[R]
3536 The images that this image depends on specified as a comma\-separated
3537 list.
3538 All images configured in this option will be built before this image.
3539 .RS
3540 .PP
3541 When this setting is specified for the \[lq]main\[rq] image, it
3542 specifies which subimages should be built.
3543 See the \f[B]Building multiple images\f[R] section for more information.
3544 .RE
3545 .TP
3546 \f[CR]MinimumVersion=\f[R], \f[CR]\-\-minimum\-version=\f[R]
3547 The minimum \f[B]mkosi\f[R] version required to build this
3548 configuration.
3549 If specified multiple times, the highest specified version is used.
3550 .TP
3551 \f[CR]ConfigureScripts=\f[R], \f[CR]\-\-configure\-script=\f[R]
3552 Takes a comma\-separated list of paths to executables that are used as
3553 the configure scripts for this image.
3554 See the \f[B]Scripts\f[R] section for more information.
3555 .TP
3556 \f[CR]PassEnvironment=\f[R], \f[CR]\-\-pass\-environment=\f[R]
3557 Takes a list of environment variable names separated by spaces.
3558 When building multiple images, pass the listed environment variables to
3559 each individual subimage as if they were \[lq]universal\[rq] settings.
3560 See the \f[B]Building multiple images\f[R] section for more information.
3561 .SS [UKIProfile] Section
3562 The \f[CR]UKIProfile\f[R] section can be used in UKI profile config
3563 files which are passed to the \f[CR]UnifiedKernelImageProfiles=\f[R]
3564 setting.
3565 The following settings can be specified in the \f[CR]UKIProfile\f[R]
3566 section:
3567 .TP
3568 \f[CR]Profile=\f[R]
3569 The contents of the \f[CR].profile\f[R] section of the UKI profile.
3570 Takes a list of key/value pairs separated by \f[CR]=\f[R].
3571 The \f[CR]ID=\f[R] key must be specified.
3572 See the UKI \c
3573 .UR https://uapi-group.org/specifications/specs/unified_kernel_image/#multi-profile-ukis
3574 specification
3575 .UE \c
3576 \ for a full list of possible keys.
3577 .TP
3578 \f[CR]Cmdline=\f[R]
3579 Extra kernel command line options for the UKI profile.
3580 Takes a space delimited list of extra kernel command line arguments.
3581 Note that the final \f[CR].cmdline\f[R] section will the combination of
3582 the base \f[CR].cmdline\f[R] section and the extra kernel command line
3583 arguments specified with this setting.
3584 .SS Specifiers
3585 The current value of various settings can be accessed when parsing
3586 configuration files by using specifiers.
3587 To write a literal \f[CR]%\f[R] character in a configuration file
3588 without treating it as a specifier, use \f[CR]%%\f[R].
3589 The following specifiers are understood:
3590 .PP
3591 .TS
3592 tab(@);
3593 l l.
3594 T{
3595 Setting
3596 T}@T{
3597 Specifier
3598 T}
3599 _
3600 T{
3601 \f[CR]Distribution=\f[R]
3602 T}@T{
3603 \f[CR]%d\f[R]
3604 T}
3605 T{
3606 \f[CR]Release=\f[R]
3607 T}@T{
3608 \f[CR]%r\f[R]
3609 T}
3610 T{
3611 \f[CR]Architecture=\f[R]
3612 T}@T{
3613 \f[CR]%a\f[R]
3614 T}
3615 T{
3616 \f[CR]Format=\f[R]
3617 T}@T{
3618 \f[CR]%t\f[R]
3619 T}
3620 T{
3621 \f[CR]Output=\f[R]
3622 T}@T{
3623 \f[CR]%o\f[R]
3624 T}
3625 T{
3626 \f[CR]OutputDirectory=\f[R]
3627 T}@T{
3628 \f[CR]%O\f[R]
3629 T}
3630 T{
3631 \f[CR]ImageId=\f[R]
3632 T}@T{
3633 \f[CR]%i\f[R]
3634 T}
3635 T{
3636 \f[CR]ImageVersion=\f[R]
3637 T}@T{
3638 \f[CR]%v\f[R]
3639 T}
3640 .TE
3641 .PP
3642 There are also specifiers that are independent of settings:
3643 .PP
3644 .TS
3645 tab(@);
3646 l l.
3647 T{
3648 Specifier
3649 T}@T{
3650 Value
3651 T}
3652 _
3653 T{
3654 \f[CR]%C\f[R]
3655 T}@T{
3656 Parent directory of current config file
3657 T}
3658 T{
3659 \f[CR]%P\f[R]
3660 T}@T{
3661 Current working directory
3662 T}
3663 T{
3664 \f[CR]%D\f[R]
3665 T}@T{
3666 Directory that \f[B]mkosi\f[R] was invoked in
3667 T}
3668 T{
3669 \f[CR]%I\f[R]
3670 T}@T{
3671 Name of the current subimage in \f[CR]mkosi.images\f[R]
3672 T}
3673 .TE
3674 .PP
3675 Finally, there are specifiers that are derived from a setting:
3676 .PP
3677 .TS
3678 tab(@);
3679 l l.
3680 T{
3681 Specifier
3682 T}@T{
3683 Value
3684 T}
3685 _
3686 T{
3687 \f[CR]%F\f[R]
3688 T}@T{
3689 The default filesystem of the configured distribution
3690 T}
3691 .TE
3692 .PP
3693 Note that the current working directory changes as \f[B]mkosi\f[R]
3694 parses its configuration.
3695 Specifically, each time \f[B]mkosi\f[R] parses a directory containing a
3696 \f[CR]mkosi.conf\f[R] file, \f[B]mkosi\f[R] changes its working
3697 directory to that directory.
3698 .PP
3699 Note that the directory that \f[B]mkosi\f[R] was invoked in is
3700 influenced by the \f[CR]\-\-directory=\f[R] command line argument.
3701 .PP
3702 The following table shows example values for the directory specifiers
3703 listed above:
3704 .PP
3705 .TS
3706 tab(@);
3707 lw(4.7n) lw(13.4n) lw(25.2n) lw(26.7n).
3708 T{
3709 T}@T{
3710 \f[CR]$D/mkosi.conf\f[R]
3711 T}@T{
3712 \f[CR]$D/mkosi.conf.d/abc/abc.conf\f[R]
3713 T}@T{
3714 \f[CR]$D/mkosi.conf.d/abc/mkosi.conf\f[R]
3715 T}
3716 _
3717 T{
3718 \f[CR]%C\f[R]
3719 T}@T{
3720 \f[CR]$D\f[R]
3721 T}@T{
3722 \f[CR]$D/mkosi.conf.d\f[R]
3723 T}@T{
3724 \f[CR]$D/mkosi.conf.d/abc\f[R]
3725 T}
3726 T{
3727 \f[CR]%P\f[R]
3728 T}@T{
3729 \f[CR]$D\f[R]
3730 T}@T{
3731 \f[CR]$D\f[R]
3732 T}@T{
3733 \f[CR]$D/mkosi.conf.d/abc\f[R]
3734 T}
3735 T{
3736 \f[CR]%D\f[R]
3737 T}@T{
3738 \f[CR]$D\f[R]
3739 T}@T{
3740 \f[CR]$D\f[R]
3741 T}@T{
3742 \f[CR]$D\f[R]
3743 T}
3744 .TE
3745 .SS Supported distributions
3746 Images may be created containing installations of the following
3747 distributions:
3748 .IP \[bu] 2
3749 \f[I]Fedora Linux\f[R]
3750 .IP \[bu] 2
3751 \f[I]Debian\f[R]
3752 .IP \[bu] 2
3753 \f[I]Kali Linux\f[R]
3754 .IP \[bu] 2
3755 \f[I]Ubuntu\f[R]
3756 .IP \[bu] 2
3757 \f[I]Arch Linux\f[R]
3758 .IP \[bu] 2
3759 \f[I]openSUSE\f[R]
3760 .IP \[bu] 2
3761 \f[I]Mageia\f[R]
3762 .IP \[bu] 2
3763 \f[I]CentOS\f[R]
3764 .IP \[bu] 2
3765 \f[I]RHEL\f[R]
3766 .IP \[bu] 2
3767 \f[I]RHEL UBI\f[R]
3768 .IP \[bu] 2
3769 \f[I]OpenMandriva\f[R]
3770 .IP \[bu] 2
3771 \f[I]Rocky Linux\f[R]
3772 .IP \[bu] 2
3773 \f[I]Alma Linux\f[R]
3774 .IP \[bu] 2
3775 \f[I]Azure Linux\f[R]
3776 .IP \[bu] 2
3777 \f[I]None\f[R] (\f[B]Requires the user to provide a pre\-built
3778 rootfs\f[R])
3779 .PP
3780 In theory, any distribution may be used on the host for building images
3781 containing any other distribution, as long as the necessary tools are
3782 available.
3783 Specifically, any distribution that packages \f[B]apt\f[R] may be used
3784 to build \f[I]Debian\f[R], \f[I]Kali\f[R] or \f[I]Ubuntu\f[R] images.
3785 Any distribution that packages \f[B]dnf\f[R] may be used to build images
3786 for any of the RPM\-based distributions.
3787 Any distro that packages \f[B]pacman\f[R] may be used to build \f[I]Arch
3788 Linux\f[R] images.
3789 Any distribution that packages \f[B]zypper\f[R] may be used to build
3790 \f[I]openSUSE\f[R] images.
3791 Other distributions and build automation tools for embedded Linux
3792 systems such as Buildroot, OpenEmbedded and Yocto Project may be used by
3793 selecting the \f[CR]custom\f[R] distribution, and populating the rootfs
3794 via a combination of base trees, skeleton trees, and prepare scripts.
3795 .PP
3796 Currently, \f[I]Fedora Linux\f[R] packages all relevant tools as of
3797 Fedora 28.
3798 .PP
3799 Note that when not using a custom mirror, \f[CR]RHEL\f[R] images can
3800 only be built from a host system with a \f[CR]RHEL\f[R] subscription
3801 (established using e.g.\ \f[CR]subscription\-manager\f[R]).
3802 .SH Execution Flow
3803 Execution flow for \f[CR]mkosi build\f[R].
3804 Default values/calls are shown in parentheses.
3805 When building with \f[CR]\-\-incremental\f[R] \f[B]mkosi\f[R] creates a
3806 cache of the distribution installation if not already existing and
3807 replaces the distribution installation in consecutive runs with data
3808 from the cached one.
3809 .IP "1." 3
3810 Parse CLI options
3811 .IP "2." 3
3812 Parse configuration files
3813 .IP "3." 3
3814 Run configure scripts (\f[CR]mkosi.configure\f[R])
3815 .IP "4." 3
3816 If we\[cq]re not running as root, unshare the user namespace and map the
3817 subuid range configured in \f[CR]/etc/subuid\f[R] and
3818 \f[CR]/etc/subgid\f[R] into it.
3819 .IP "5." 3
3820 Unshare the mount namespace
3821 .IP "6." 3
3822 Remount the following directories read\-only if they exist:
3823 .RS 4
3824 .IP \[bu] 2
3825 \f[CR]/usr\f[R]
3826 .IP \[bu] 2
3827 \f[CR]/etc\f[R]
3828 .IP \[bu] 2
3829 \f[CR]/opt\f[R]
3830 .IP \[bu] 2
3831 \f[CR]/srv\f[R]
3832 .IP \[bu] 2
3833 \f[CR]/boot\f[R]
3834 .IP \[bu] 2
3835 \f[CR]/efi\f[R]
3836 .IP \[bu] 2
3837 \f[CR]/media\f[R]
3838 .IP \[bu] 2
3839 \f[CR]/mnt\f[R]
3840 .RE
3841 .PP
3842 Then, for each image, we execute the following steps:
3843 .IP " 1." 4
3844 Copy sandbox trees into the workspace
3845 .IP " 2." 4
3846 Sync the package manager repository metadata
3847 .IP " 3." 4
3848 Run sync scripts (\f[CR]mkosi.sync\f[R])
3849 .IP " 4." 4
3850 Copy base trees (\f[CR]\-\-base\-tree=\f[R]) into the image
3851 .IP " 5." 4
3852 Reuse a cached image if one is available
3853 .IP " 6." 4
3854 Copy a snapshot of the package manager repository metadata into the
3855 image
3856 .IP " 7." 4
3857 Copy skeleton trees (\f[CR]mkosi.skeleton\f[R]) into image
3858 .IP " 8." 4
3859 Install distribution and packages into image
3860 .IP " 9." 4
3861 Run prepare scripts on image with the \f[CR]final\f[R] argument
3862 (\f[CR]mkosi.prepare\f[R])
3863 .IP "10." 4
3864 Install build packages in overlay if any build scripts are configured
3865 .IP "11." 4
3866 Run prepare scripts on overlay with the \f[CR]build\f[R] argument if any
3867 build scripts are configured (\f[CR]mkosi.prepare\f[R])
3868 .IP "12." 4
3869 Cache the image if configured (\f[CR]\-\-incremental\f[R])
3870 .IP "13." 4
3871 Run build scripts on image + overlay if any build scripts are configured
3872 (\f[CR]mkosi.build\f[R])
3873 .IP "14." 4
3874 Finalize the build if the output format \f[CR]none\f[R] is configured
3875 .IP "15." 4
3876 Copy the build scripts outputs into the image
3877 .IP "16." 4
3878 Copy the extra trees into the image (\f[CR]mkosi.extra\f[R])
3879 .IP "17." 4
3880 Run post\-install scripts (\f[CR]mkosi.postinst\f[R])
3881 .IP "18." 4
3882 Write config files required for \f[CR]Ssh=\f[R], \f[CR]Autologin=\f[R]
3883 and \f[CR]MakeInitrd=\f[R]
3884 .IP "19." 4
3885 Install systemd\-boot and configure secure boot if configured
3886 (\f[CR]\-\-secure\-boot\f[R])
3887 .IP "20." 4
3888 Run \f[B]systemd\-sysusers\f[R]
3889 .IP "21." 4
3890 Run \f[B]systemd\-tmpfiles\f[R]
3891 .IP "22." 4
3892 Run \f[CR]systemctl preset\-all\f[R]
3893 .IP "23." 4
3894 Run \f[B]depmod\f[R]
3895 .IP "24." 4
3896 Run \f[B]systemd\-firstboot\f[R]
3897 .IP "25." 4
3898 Run \f[B]systemd\-hwdb\f[R]
3899 .IP "26." 4
3900 Remove packages and files (\f[CR]RemovePackages=\f[R],
3901 \f[CR]RemoveFiles=\f[R])
3902 .IP "27." 4
3903 Run SELinux relabel is a SELinux policy is installed
3904 .IP "28." 4
3905 Run finalize scripts (\f[CR]mkosi.finalize\f[R])
3906 .IP "29." 4
3907 Generate unified kernel image if configured to do so
3908 .IP "30." 4
3909 Generate final output format
3910 .IP "31." 4
3911 Run post\-output scripts (\f[CR]mkosi.postoutput\f[R])
3912 .SH Scripts
3913 To allow for image customization that cannot be implemented using
3914 \f[B]mkosi\f[R]\[cq]s builtin features, \f[B]mkosi\f[R] supports running
3915 scripts at various points during the image build process that can
3916 customize the image as needed.
3917 Scripts are executed on the host system as root (either real root or
3918 root within the user namespace that \f[B]mkosi\f[R] created when running
3919 unprivileged) with a customized environment to simplify modifying the
3920 image.
3921 For each script, the configured build sources (\f[CR]BuildSources=\f[R])
3922 are mounted into the current working directory before running the script
3923 in the current working directory.
3924 \f[CR]$SRCDIR\f[R] is set to point to the current working directory.
3925 The following scripts are supported:
3926 .IP \[bu] 2
3927 If \f[B]\f[CB]mkosi.configure\f[B]\f[R] (\f[CR]ConfigureScripts=\f[R])
3928 exists, it is executed before building the image.
3929 This script may be used to dynamically modify the configuration.
3930 It receives the configuration serialized as JSON on stdin and should
3931 output the modified configuration serialized as JSON on stdout.
3932 Note that this script only runs when building or booting the image
3933 (\f[CR]build\f[R], \f[CR]vm\f[R], \f[CR]boot\f[R] and \f[CR]shell\f[R]
3934 verbs).
3935 If a default tools tree is configured, it will be built before running
3936 the configure scripts and the configure scripts will run with the tools
3937 tree available.
3938 This also means that the modifications made by configure scripts will
3939 not be visible in the \f[CR]summary\f[R] output.
3940 .IP \[bu] 2
3941 If \f[B]\f[CB]mkosi.sync\f[B]\f[R] (\f[CR]SyncScripts=\f[R]) exists, it
3942 is executed before the image is built.
3943 This script may be used to update various sources that are used to build
3944 the image.
3945 One use case is to run \f[CR]git pull\f[R] on various source
3946 repositories before building the image.
3947 Specifically, the \f[CR]BuildSourcesEphemeral=\f[R] setting does not
3948 apply to sync scripts, which means sync scripts can be used to update
3949 build sources even if \f[CR]BuildSourcesEphemeral=\f[R] is enabled.
3950 .IP \[bu] 2
3951 If \f[B]\f[CB]mkosi.prepare\f[B]\f[R] (\f[CR]PrepareScripts=\f[R])
3952 exists, it is first called with the \f[CR]final\f[R] argument, right
3953 after the software packages are installed.
3954 It is called a second time with the \f[CR]build\f[R] command line
3955 parameter, right after the build packages are installed and the build
3956 overlay mounted on top of the image\[cq]s root directory .
3957 This script has network access and may be used to install packages from
3958 other sources than the distro\[cq]s package manager
3959 (e.g.\ \f[B]pip\f[R], \f[B]npm\f[R], \&...), after all software packages
3960 are installed but before the image is cached (if incremental mode is
3961 enabled).
3962 In contrast to a general purpose installation, it is safe to install
3963 packages to the system (\f[CR]pip install\f[R],
3964 \f[CR]npm install \-g\f[R]) instead of in \f[CR]$SRCDIR\f[R] itself
3965 because the build image is only used for a single project and can easily
3966 be thrown away and rebuilt so there\[cq]s no risk of conflicting
3967 dependencies and no risk of polluting the host system.
3968 .IP \[bu] 2
3969 If \f[B]\f[CB]mkosi.build\f[B]\f[R] (\f[CR]BuildScripts=\f[R]) exists,
3970 it is executed with the build overlay mounted on top of the image\[cq]s
3971 root directory.
3972 When running the build script, \f[CR]$DESTDIR\f[R] points to a directory
3973 where the script should place any files generated it would like to end
3974 up in the image.
3975 Note that \f[B]make\f[R]\-, \f[B]automake\f[R]\-, and
3976 \f[B]meson\f[R]\-based build systems generally honor
3977 \f[CR]$DESTDIR\f[R], thus making it very natural to build
3978 \f[I]source\f[R] trees from the build script.
3979 After running the build script, the contents of \f[CR]$DESTDIR\f[R] are
3980 copied into the image.
3981 .IP \[bu] 2
3982 If \f[B]\f[CB]mkosi.postinst\f[B]\f[R]
3983 (\f[CR]PostInstallationScripts=\f[R]) exists, it is executed after the
3984 (optional) build tree and extra trees have been installed.
3985 This script may be used to alter the images without any restrictions,
3986 after all software packages and built sources have been installed.
3987 .IP \[bu] 2
3988 If \f[B]\f[CB]mkosi.finalize\f[B]\f[R] (\f[CR]FinalizeScripts=\f[R])
3989 exists, it is executed as the last step of preparing an image.
3990 .IP \[bu] 2
3991 If \f[B]\f[CB]mkosi.postoutput\f[B]\f[R] (\f[CR]PostOutputScripts=\f[R])
3992 exists, it is executed right after all the output files have been
3993 generated, before they are finally moved into the output directory.
3994 This can be used to generate additional or alternative outputs,
3995 e.g.\ \f[CR]SHA256FILES\f[R] or SBOM manifests.
3996 .IP \[bu] 2
3997 If \f[B]\f[CB]mkosi.clean\f[B]\f[R] (\f[CR]CleanScripts=\f[R]) exists,
3998 it is executed right after the outputs of a previous build have been
3999 cleaned up.
4000 A clean script can clean up any outputs that \f[B]mkosi\f[R] does not
4001 know about (e.g.
4002 artifacts from \f[CR]SplitArtifacts=partitions\f[R] or RPMs built in a
4003 build script).
4004 Note that this script does not use the tools tree even if one is
4005 configured.
4006 .IP \[bu] 2
4007 If \f[B]\f[CB]mkosi.version\f[B]\f[R] exists and is executable, it is
4008 run during configuration parsing and populates \f[CR]ImageVersion=\f[R]
4009 with the output on stdout.
4010 This can be used for external version tracking, e.g.\ with
4011 \f[CR]git describe\f[R] or \f[CR]date \[aq]+%Y\-%m\-%d\[aq]\f[R].
4012 Note that this script is executed on the host system without any
4013 sandboxing.
4014 .IP \[bu] 2
4015 If \f[B]\f[CB]mkosi.rootpw\f[B]\f[R] exists and is executable, it is run
4016 during configuration parsing and populates \f[CR]RootPassword=\f[R] with
4017 the output on stdout.
4018 This can be used to randomly generate a password and can be remembered
4019 by outputting it to stderr or by reading \f[CR]$MKOSI_CONFIG\f[R] in
4020 another script (e.g.\ \f[CR]mkosi.postoutput\f[R]).
4021 Note that this script is executed on the host system without any
4022 sandboxing.
4023 .PP
4024 If a script uses the \f[CR].chroot\f[R] extension, \f[B]mkosi\f[R] will
4025 chroot into the image using \f[B]mkosi\-chroot\f[R] (see below) before
4026 executing the script.
4027 For example, if \f[CR]mkosi.postinst.chroot\f[R] exists, \f[B]mkosi\f[R]
4028 will chroot into the image and execute it as the post\-installation
4029 script.
4030 .PP
4031 Instead of a single file script, \f[B]mkosi\f[R] will also read all
4032 files in lexicographical order from appropriately named \f[CR].d\f[R]
4033 directories, e.g.\ all files in a \f[CR]mkosi.build.d\f[R] would be used
4034 as build scripts.
4035 This is supported by
4036 .IP \[bu] 2
4037 \f[CR]mkosi.sync.d\f[R],
4038 .IP \[bu] 2
4039 \f[CR]mkosi.prepare.d\f[R],
4040 .IP \[bu] 2
4041 \f[CR]mkosi.build.d\f[R],
4042 .IP \[bu] 2
4043 \f[CR]mkosi.postinst.d\f[R],
4044 .IP \[bu] 2
4045 \f[CR]mkosi.finalize.d\f[R],
4046 .IP \[bu] 2
4047 \f[CR]mkosi.postoutput.d\f[R], and
4048 .IP \[bu] 2
4049 \f[CR]mkosi.clean.d\f[R].
4050 .PP
4051 This can be combined with the \f[CR].chroot\f[R] extension,
4052 e.g.\ \f[CR]mkosi.build.d/01\-foo.sh\f[R] would be run without chrooting
4053 into the image and \f[CR]mkosi.build.d/02\-bar.sh.chroot\f[R] would be
4054 run after chrooting into the image first.
4055 .PP
4056 Scripts executed by \f[B]mkosi\f[R] receive the following environment
4057 variables:
4058 .IP \[bu] 2
4059 \f[CR]$ARCHITECTURE\f[R] contains the architecture from the
4060 \f[CR]Architecture=\f[R] setting.
4061 If \f[CR]Architecture=\f[R] is not set, it will contain the native
4062 architecture of the host machine.
4063 See the documentation of \f[CR]Architecture=\f[R] for possible values
4064 for this variable.
4065 .IP \[bu] 2
4066 \f[CR]$QEMU_ARCHITECTURE\f[R] contains the architecture from
4067 \f[CR]$ARCHITECTURE\f[R] in the format used by \f[B]qemu\f[R].
4068 Useful for finding the qemu binary (
4069 \f[CR]qemu\-system\-$QEMU_ARCHITECTURE\f[R]).
4070 .IP \[bu] 2
4071 \f[CR]$DISTRIBUTION\f[R] contains the distribution from the
4072 \f[CR]Distribution=\f[R] setting.
4073 .IP \[bu] 2
4074 \f[CR]$RELEASE\f[R] contains the release from the \f[CR]Release=\f[R]
4075 setting.
4076 .IP \[bu] 2
4077 \f[CR]$DISTRIBUTION_ARCHITECTURE\f[R] contains the architecture from
4078 \f[CR]$ARCHITECTURE\f[R] in the format used by the configured
4079 distribution.
4080 .IP \[bu] 2
4081 \f[CR]$PROFILES\f[R] contains the profiles from the \f[CR]Profiles=\f[R]
4082 setting as a comma\-delimited string.
4083 .IP \[bu] 2
4084 \f[CR]$CACHED=\f[R] is set to \f[CR]1\f[R] if a cached image is
4085 available, \f[CR]0\f[R] otherwise.
4086 .IP \[bu] 2
4087 \f[CR]$CHROOT_SCRIPT\f[R] contains the path to the running script
4088 relative to the image root directory.
4089 The primary usecase for this variable is in combination with the
4090 \f[B]mkosi\-chroot\f[R] script.
4091 See the description of \f[B]mkosi\-chroot\f[R] below for more
4092 information.
4093 .IP \[bu] 2
4094 \f[CR]$SRCDIR\f[R] contains the path to the directory \f[B]mkosi\f[R]
4095 was invoked from, with any configured build sources mounted on top.
4096 \f[CR]$CHROOT_SRCDIR\f[R] contains the value that \f[CR]$SRCDIR\f[R]
4097 will have after invoking \f[B]mkosi\-chroot\f[R].
4098 .IP \[bu] 2
4099 \f[CR]$BUILDDIR\f[R] is only defined if \f[CR]mkosi.builddir\f[R] exists
4100 and points to the build directory to use.
4101 This is useful for all build systems that support out\-of\-tree builds
4102 to reuse already built artifacts from previous runs.
4103 \f[CR]$CHROOT_BUILDDIR\f[R] contains the value that \f[CR]$BUILDDIR\f[R]
4104 will have after invoking \f[B]mkosi\-chroot\f[R].
4105 .IP \[bu] 2
4106 \f[CR]$DESTDIR\f[R] is a directory into which any installed software
4107 generated by a build script may be placed.
4108 This variable is only set when executing a build script.
4109 \f[CR]$CHROOT_DESTDIR\f[R] contains the value that \f[CR]$DESTDIR\f[R]
4110 will have after invoking \f[B]mkosi\-chroot\f[R].
4111 .IP \[bu] 2
4112 \f[CR]$OUTPUTDIR\f[R] points to the staging directory used to store
4113 build artifacts generated during the build.
4114 \f[CR]$CHROOT_OUTPUTDIR\f[R] contains the value that
4115 \f[CR]$OUTPUTDIR\f[R] will have after invoking \f[B]mkosi\-chroot\f[R].
4116 .IP \[bu] 2
4117 \f[CR]$PACKAGEDIR\f[R] points to the directory containing the local
4118 package repository.
4119 Build scripts can add more packages to the local repository by writing
4120 the packages to \f[CR]$PACKAGEDIR\f[R].
4121 .IP \[bu] 2
4122 \f[CR]$ARTIFACTDIR\f[R] points to the directory that is used to pass
4123 around build artifacts generated during the build and make them
4124 available for use by mkosi.
4125 This is similar to \f[CR]PACKAGEDIR\f[R], but is meant for artifacts
4126 that may not be packages understood by the package manager,
4127 e.g.\ initrds created by other initrd generators than mkosi.
4128 Build scripts can add more artifacts to the directory by placing them in
4129 \f[CR]$ARTIFACTDIR\f[R].
4130 Files in this directory are only available for the current build and are
4131 not copied out like the contents of \f[CR]$OUTPUTDIR\f[R].
4132 .RS 2
4133 .PP
4134 \f[B]mkosi\f[R] will also use certain subdirectories of an artifacts
4135 directory to automatically use their contents at certain steps.
4136 Currently the following two subdirectories in the artifact directory are
4137 used by mkosi:
4138 .IP \[bu] 2
4139 \f[CR]io.mkosi.microcode\f[R]: All files in this directory are used as
4140 microcode files, i.e.\ they are prepended to the initrds in
4141 lexicographical order.
4142 .IP \[bu] 2
4143 \f[CR]io.mkosi.initrd\f[R]: All files in this directory are used as
4144 initrds and joined in lexicographical order.
4145 .PP
4146 It is recommended, that users of \f[CR]$ARTIFACTDIR\f[R] put things for
4147 their own use in a similar namespaced directory,
4148 e.g.\ \f[CR]local.my.namespace\f[R].
4149 .RE
4150 .IP \[bu] 2
4151 \f[CR]$BUILDROOT\f[R] is the root directory of the image being built,
4152 optionally with the build overlay mounted on top depending on the script
4153 that\[cq]s being executed.
4154 .IP \[bu] 2
4155 \f[CR]$WITH_DOCS\f[R] is either \f[CR]0\f[R] or \f[CR]1\f[R] depending
4156 on whether a build without or with installed documentation was requested
4157 (\f[CR]WithDocs=yes\f[R]).
4158 A build script should suppress installation of any package documentation
4159 to \f[CR]$DESTDIR\f[R] in case \f[CR]$WITH_DOCS\f[R] is set to
4160 \f[CR]0\f[R].
4161 .IP \[bu] 2
4162 \f[CR]$WITH_TESTS\f[R] is either \f[CR]0\f[R] or \f[CR]1\f[R] depending
4163 on whether a build without or with running the test suite was requested
4164 (\f[CR]WithTests=no\f[R]).
4165 A build script should avoid running any unit or integration tests in
4166 case \f[CR]$WITH_TESTS\f[R] is \f[CR]0\f[R].
4167 .IP \[bu] 2
4168 \f[CR]$WITH_NETWORK\f[R] is either \f[CR]0\f[R] or \f[CR]1\f[R]
4169 depending on whether a build without or with networking is being
4170 executed (\f[CR]WithNetwork=no\f[R]).
4171 A build script should avoid any network communication in case
4172 \f[CR]$WITH_NETWORK\f[R] is \f[CR]0\f[R].
4173 .IP \[bu] 2
4174 \f[CR]$SOURCE_DATE_EPOCH\f[R] is defined if requested
4175 (\f[CR]SourceDateEpoch=TIMESTAMP\f[R],
4176 \f[CR]Environment=SOURCE_DATE_EPOCH=TIMESTAMP\f[R] or the host
4177 environment variable \f[CR]$SOURCE_DATE_EPOCH\f[R]).
4178 This is useful to make builds reproducible.
4179 See \c
4180 .UR https://reproducible-builds.org/specs/source-date-epoch/
4181 SOURCE_DATE_EPOCH
4182 .UE \c
4183 \ for more information.
4184 .IP \[bu] 2
4185 \f[CR]$MKOSI_UID\f[R] and \f[CR]$MKOSI_GID\f[R] respectively are the
4186 uid, gid of the user that invoked mkosi.
4187 .IP \[bu] 2
4188 \f[CR]$MKOSI_CONFIG\f[R] is a file containing a json summary of the
4189 settings of the current image.
4190 This file can be parsed inside scripts to gain access to all settings
4191 for the current image.
4192 .IP \[bu] 2
4193 \f[CR]$IMAGE_ID\f[R] contains the identifier from the
4194 \f[CR]ImageId=\f[R] or \f[CR]\-\-image\-id=\f[R] setting.
4195 .IP \[bu] 2
4196 \f[CR]$IMAGE_VERSION\f[R] contains the version from the
4197 \f[CR]ImageVersion=\f[R] or \f[CR]\-\-image\-version=\f[R] setting.
4198 .PP
4199 Consult this table for which script receives which environment
4200 variables:
4201 .PP
4202 .TS
4203 tab(@);
4204 lw(17.4n) cw(7.8n) cw(4.8n) cw(6.6n) cw(5.4n) cw(7.2n) cw(7.2n) cw(8.4n) cw(5.4n).
4205 T{
4206 Variable
4207 T}@T{
4208 \f[CR]configure\f[R]
4209 T}@T{
4210 \f[CR]sync\f[R]
4211 T}@T{
4212 \f[CR]prepare\f[R]
4213 T}@T{
4214 \f[CR]build\f[R]
4215 T}@T{
4216 \f[CR]postinst\f[R]
4217 T}@T{
4218 \f[CR]finalize\f[R]
4219 T}@T{
4220 \f[CR]postoutput\f[R]
4221 T}@T{
4222 \f[CR]clean\f[R]
4223 T}
4224 _
4225 T{
4226 \f[CR]ARCHITECTURE\f[R]
4227 T}@T{
4228 ✓
4229 T}@T{
4230 ✓
4231 T}@T{
4232 ✓
4233 T}@T{
4234 ✓
4235 T}@T{
4236 ✓
4237 T}@T{
4238 ✓
4239 T}@T{
4240 ✓
4241 T}@T{
4242 ✓
4243 T}
4244 T{
4245 \f[CR]QEMU_ARCHITECTURE\f[R]
4246 T}@T{
4247 ✓
4248 T}@T{
4249 T}@T{
4250 T}@T{
4251 T}@T{
4252 T}@T{
4253 T}@T{
4254 T}@T{
4255 T}
4256 T{
4257 \f[CR]DISTRIBUTION\f[R]
4258 T}@T{
4259 ✓
4260 T}@T{
4261 ✓
4262 T}@T{
4263 ✓
4264 T}@T{
4265 ✓
4266 T}@T{
4267 ✓
4268 T}@T{
4269 ✓
4270 T}@T{
4271 ✓
4272 T}@T{
4273 ✓
4274 T}
4275 T{
4276 \f[CR]DISTRIBUTION_ARCHITECTURE\f[R]
4277 T}@T{
4278 ✓
4279 T}@T{
4280 ✓
4281 T}@T{
4282 ✓
4283 T}@T{
4284 ✓
4285 T}@T{
4286 ✓
4287 T}@T{
4288 ✓
4289 T}@T{
4290 ✓
4291 T}@T{
4292 ✓
4293 T}
4294 T{
4295 \f[CR]RELEASE\f[R]
4296 T}@T{
4297 ✓
4298 T}@T{
4299 ✓
4300 T}@T{
4301 ✓
4302 T}@T{
4303 ✓
4304 T}@T{
4305 ✓
4306 T}@T{
4307 ✓
4308 T}@T{
4309 ✓
4310 T}@T{
4311 ✓
4312 T}
4313 T{
4314 \f[CR]PROFILES\f[R]
4315 T}@T{
4316 ✓
4317 T}@T{
4318 ✓
4319 T}@T{
4320 ✓
4321 T}@T{
4322 ✓
4323 T}@T{
4324 ✓
4325 T}@T{
4326 ✓
4327 T}@T{
4328 T}@T{
4329 ✓
4330 T}
4331 T{
4332 \f[CR]CACHED\f[R]
4333 T}@T{
4334 T}@T{
4335 ✓
4336 T}@T{
4337 T}@T{
4338 T}@T{
4339 T}@T{
4340 T}@T{
4341 T}@T{
4342 T}
4343 T{
4344 \f[CR]CHROOT_SCRIPT\f[R]
4345 T}@T{
4346 T}@T{
4347 T}@T{
4348 ✓
4349 T}@T{
4350 ✓
4351 T}@T{
4352 ✓
4353 T}@T{
4354 ✓
4355 T}@T{
4356 T}@T{
4357 T}
4358 T{
4359 \f[CR]SRCDIR\f[R]
4360 T}@T{
4361 ✓
4362 T}@T{
4363 ✓
4364 T}@T{
4365 ✓
4366 T}@T{
4367 ✓
4368 T}@T{
4369 ✓
4370 T}@T{
4371 ✓
4372 T}@T{
4373 ✓
4374 T}@T{
4375 ✓
4376 T}
4377 T{
4378 \f[CR]CHROOT_SRCDIR\f[R]
4379 T}@T{
4380 T}@T{
4381 T}@T{
4382 ✓
4383 T}@T{
4384 ✓
4385 T}@T{
4386 ✓
4387 T}@T{
4388 ✓
4389 T}@T{
4390 T}@T{
4391 T}
4392 T{
4393 \f[CR]BUILDDIR\f[R]
4394 T}@T{
4395 T}@T{
4396 T}@T{
4397 T}@T{
4398 ✓
4399 T}@T{
4400 ✓
4401 T}@T{
4402 ✓
4403 T}@T{
4404 T}@T{
4405 T}
4406 T{
4407 \f[CR]CHROOT_BUILDDIR\f[R]
4408 T}@T{
4409 T}@T{
4410 T}@T{
4411 T}@T{
4412 ✓
4413 T}@T{
4414 T}@T{
4415 T}@T{
4416 T}@T{
4417 T}
4418 T{
4419 \f[CR]DESTDIR\f[R]
4420 T}@T{
4421 T}@T{
4422 T}@T{
4423 T}@T{
4424 ✓
4425 T}@T{
4426 T}@T{
4427 T}@T{
4428 T}@T{
4429 T}
4430 T{
4431 \f[CR]CHROOT_DESTDIR\f[R]
4432 T}@T{
4433 T}@T{
4434 T}@T{
4435 T}@T{
4436 ✓
4437 T}@T{
4438 T}@T{
4439 T}@T{
4440 T}@T{
4441 T}
4442 T{
4443 \f[CR]OUTPUTDIR\f[R]
4444 T}@T{
4445 T}@T{
4446 T}@T{
4447 T}@T{
4448 T}@T{
4449 ✓
4450 T}@T{
4451 ✓
4452 T}@T{
4453 ✓
4454 T}@T{
4455 ✓
4456 T}
4457 T{
4458 \f[CR]CHROOT_OUTPUTDIR\f[R]
4459 T}@T{
4460 T}@T{
4461 T}@T{
4462 T}@T{
4463 T}@T{
4464 ✓
4465 T}@T{
4466 ✓
4467 T}@T{
4468 T}@T{
4469 T}
4470 T{
4471 \f[CR]BUILDROOT\f[R]
4472 T}@T{
4473 T}@T{
4474 T}@T{
4475 ✓
4476 T}@T{
4477 ✓
4478 T}@T{
4479 ✓
4480 T}@T{
4481 ✓
4482 T}@T{
4483 T}@T{
4484 T}
4485 T{
4486 \f[CR]PACKAGEDIR\f[R]
4487 T}@T{
4488 T}@T{
4489 T}@T{
4490 ✓
4491 T}@T{
4492 ✓
4493 T}@T{
4494 ✓
4495 T}@T{
4496 ✓
4497 T}@T{
4498 T}@T{
4499 T}
4500 T{
4501 \f[CR]ARTIFACTDIR\f[R]
4502 T}@T{
4503 T}@T{
4504 T}@T{
4505 ✓
4506 T}@T{
4507 ✓
4508 T}@T{
4509 ✓
4510 T}@T{
4511 ✓
4512 T}@T{
4513 T}@T{
4514 T}
4515 T{
4516 \f[CR]WITH_DOCS\f[R]
4517 T}@T{
4518 T}@T{
4519 T}@T{
4520 ✓
4521 T}@T{
4522 ✓
4523 T}@T{
4524 T}@T{
4525 T}@T{
4526 T}@T{
4527 T}
4528 T{
4529 \f[CR]WITH_TESTS\f[R]
4530 T}@T{
4531 T}@T{
4532 T}@T{
4533 ✓
4534 T}@T{
4535 ✓
4536 T}@T{
4537 T}@T{
4538 T}@T{
4539 T}@T{
4540 T}
4541 T{
4542 \f[CR]WITH_NETWORK\f[R]
4543 T}@T{
4544 T}@T{
4545 T}@T{
4546 ✓
4547 T}@T{
4548 ✓
4549 T}@T{
4550 ✓
4551 T}@T{
4552 ✓
4553 T}@T{
4554 T}@T{
4555 T}
4556 T{
4557 \f[CR]SOURCE_DATE_EPOCH\f[R]
4558 T}@T{
4559 T}@T{
4560 T}@T{
4561 ✓
4562 T}@T{
4563 ✓
4564 T}@T{
4565 ✓
4566 T}@T{
4567 ✓
4568 T}@T{
4569 T}@T{
4570 ✓
4571 T}
4572 T{
4573 \f[CR]MKOSI_UID\f[R]
4574 T}@T{
4575 ✓
4576 T}@T{
4577 ✓
4578 T}@T{
4579 ✓
4580 T}@T{
4581 ✓
4582 T}@T{
4583 ✓
4584 T}@T{
4585 ✓
4586 T}@T{
4587 ✓
4588 T}@T{
4589 ✓
4590 T}
4591 T{
4592 \f[CR]MKOSI_GID\f[R]
4593 T}@T{
4594 ✓
4595 T}@T{
4596 ✓
4597 T}@T{
4598 ✓
4599 T}@T{
4600 ✓
4601 T}@T{
4602 ✓
4603 T}@T{
4604 ✓
4605 T}@T{
4606 ✓
4607 T}@T{
4608 ✓
4609 T}
4610 T{
4611 \f[CR]MKOSI_CONFIG\f[R]
4612 T}@T{
4613 T}@T{
4614 ✓
4615 T}@T{
4616 ✓
4617 T}@T{
4618 ✓
4619 T}@T{
4620 ✓
4621 T}@T{
4622 ✓
4623 T}@T{
4624 ✓
4625 T}@T{
4626 ✓
4627 T}
4628 T{
4629 \f[CR]IMAGE_ID\f[R]
4630 T}@T{
4631 ✓
4632 T}@T{
4633 ✓
4634 T}@T{
4635 ✓
4636 T}@T{
4637 ✓
4638 T}@T{
4639 ✓
4640 T}@T{
4641 ✓
4642 T}@T{
4643 ✓
4644 T}@T{
4645 ✓
4646 T}
4647 T{
4648 \f[CR]IMAGE_VERSION\f[R]
4649 T}@T{
4650 ✓
4651 T}@T{
4652 ✓
4653 T}@T{
4654 ✓
4655 T}@T{
4656 ✓
4657 T}@T{
4658 ✓
4659 T}@T{
4660 ✓
4661 T}@T{
4662 ✓
4663 T}@T{
4664 ✓
4665 T}
4666 .TE
4667 .PP
4668 Additionally, when a script is executed, a few scripts are made
4669 available via \f[CR]$PATH\f[R] to simplify common usecases.
4670 .IP \[bu] 2
4671 \f[B]mkosi\-chroot\f[R]: This script will chroot into the image and
4672 execute the given command.
4673 On top of chrooting into the image, it will also mount various files and
4674 directories (\f[CR]$SRCDIR\f[R], \f[CR]$DESTDIR\f[R],
4675 \f[CR]$BUILDDIR\f[R], \f[CR]$OUTPUTDIR\f[R], \f[CR]$CHROOT_SCRIPT\f[R])
4676 into the image and modify the corresponding environment variables to
4677 point to the locations inside the image.
4678 It will also mount APIVFS filesystems (\f[CR]/proc\f[R],
4679 \f[CR]/dev\f[R], \&...)
4680 to make sure scripts and tools executed inside the chroot work properly.
4681 It also propagates \f[CR]/etc/resolv.conf\f[R] from the host into the
4682 chroot if requested so that DNS resolution works inside the chroot.
4683 After the mkosi\-chroot command exits, various mount points are cleaned
4684 up.
4685 .RS 2
4686 .PP
4687 For example, to invoke \f[B]ls\f[R] inside of the image, use the
4688 following:
4689 .IP
4690 .EX
4691 mkosi\-chroot ls ...
4692 .EE
4693 .PP
4694 To execute the entire script inside the image, add a \f[CR].chroot\f[R]
4695 suffix to the name (\f[CR]mkosi.build.chroot\f[R] instead of
4696 \f[CR]mkosi.build\f[R], etc.).
4697 .RE
4698 .IP \[bu] 2
4699 For all of the supported package managers (\f[B]dnf\f[R], \f[B]rpm\f[R],
4700 \f[B]apt\f[R], \f[B]dpkg\f[R], \f[B]pacman\f[R], \f[B]zypper\f[R]),
4701 scripts of the same name are put into \f[CR]$PATH\f[R] that make sure
4702 these commands operate on the image\[cq]s root directory with the
4703 configuration supplied by the user instead of on the host system.
4704 This means that from a script, you can do e.g.
4705 \f[CR]dnf install vim\f[R] to install vim into the image.
4706 .RS 2
4707 .PP
4708 Additionally, \f[CR]mkosi\-install\f[R], \f[CR]mkosi\-reinstall\f[R],
4709 \f[CR]mkosi\-upgrade\f[R] and \f[CR]mkosi\-remove\f[R] will invoke the
4710 corresponding operation of the package manager being used to built the
4711 image.
4712 .RE
4713 .IP \[bu] 2
4714 \f[B]git\f[R] is automatically invoked with \f[CR]safe.directory=*\f[R]
4715 to avoid permissions errors when running as the root user in a user
4716 namespace.
4717 .IP \[bu] 2
4718 \f[B]useradd\f[R] and \f[B]groupadd\f[R] are automatically invoked with
4719 \f[CR]\-\-root=$BUILDROOT\f[R] when executed outside of the image.
4720 .PP
4721 When scripts are executed, any directories that are still writable are
4722 also made read\-only (\f[CR]/home\f[R], \f[CR]/var\f[R],
4723 \f[CR]/root\f[R], \&...)
4724 and only the minimal set of directories that need to be writable remain
4725 writable.
4726 This is to ensure that scripts can\[cq]t mess with the host system when
4727 \f[B]mkosi\f[R] is running as root.
4728 .PP
4729 Note that when executing scripts, all source directories are made
4730 ephemeral which means all changes made to source directories while
4731 running scripts are thrown away after the scripts finish executing.
4732 Use the output, build or cache directories if you need to persist data
4733 between builds.
4734 .SH Files
4735 To make it easy to build images for development versions of your
4736 projects, \f[B]mkosi\f[R] can read configuration data from the local
4737 directory, under the assumption that it is invoked from a
4738 \f[I]source\f[R] tree.
4739 Specifically, the following files are used if they exist in the local
4740 directory:
4741 .IP \[bu] 2
4742 The \f[B]\f[CB]mkosi.skeleton/\f[B]\f[R] directory or
4743 \f[B]\f[CB]mkosi.skeleton.tar\f[B]\f[R] archive may be used to insert
4744 files into the image.
4745 The files are copied \f[I]before\f[R] the distribution packages are
4746 installed into the image.
4747 This allows creation of files that need to be provided early, for
4748 example to configure the package manager or set systemd presets.
4749 .RS 2
4750 .PP
4751 When using the directory, file ownership is not preserved: all files
4752 copied will be owned by root.
4753 To preserve ownership, use a tar archive.
4754 .RE
4755 .IP \[bu] 2
4756 The \f[B]\f[CB]mkosi.extra/\f[B]\f[R] directory or
4757 \f[B]\f[CB]mkosi.extra.tar\f[B]\f[R] archive may be used to insert
4758 additional files into the image, on top of what the distribution
4759 includes in its packages.
4760 They are similar to \f[CR]mkosi.skeleton/\f[R] and
4761 \f[CR]mkosi.skeleton.tar\f[R], but the files are copied into the
4762 directory tree of the image \f[I]after\f[R] the OS was installed.
4763 .RS 2
4764 .PP
4765 When using the directory, file ownership is not preserved: all files
4766 copied will be owned by root.
4767 To preserve ownership, use a tar archive.
4768 .RE
4769 .IP \[bu] 2
4770 The \f[B]\f[CB]mkosi.sandbox/\f[B]\f[R] directory or
4771 \f[B]\f[CB]mkosi.sandbox.tar\f[B]\f[R] archive may be used to configure
4772 the package manager without the files being inserted into the image.
4773 If the files should be included in the image \f[CR]mkosi.skeleton/\f[R]
4774 and \f[CR]mkosi.skeleton.tar\f[R] should be used instead.
4775 .RS 2
4776 .PP
4777 When using the directory, file ownership is not preserved: all files
4778 copied will be owned by root.
4779 To preserve ownership, use a tar archive.
4780 .RE
4781 .IP \[bu] 2
4782 The \f[B]\f[CB]mkosi.nspawn\f[B]\f[R] nspawn settings file will be
4783 copied into the same place as the output image file, if it exists.
4784 This is useful since nspawn looks for settings files next to image files
4785 it boots, for additional container runtime settings.
4786 .IP \[bu] 2
4787 The \f[B]\f[CB]mkosi.cache/\f[B]\f[R] directory, if it exists, is
4788 automatically used as package download cache, in order to speed repeated
4789 runs of the tool.
4790 .IP \[bu] 2
4791 The \f[B]\f[CB]mkosi.builddir/\f[B]\f[R] directory, if it exists, is
4792 automatically used as out\-of\-tree build directory, if the build
4793 commands in the \f[CR]mkosi.build\f[R] scripts support it.
4794 Specifically, this directory will be mounted into the build container,
4795 and the \f[CR]$BUILDDIR\f[R] environment variable will be set to it when
4796 the build scripts are invoked.
4797 A build script may then use this directory as build directory, for
4798 \f[B]automake\f[R]\-style or \f[B]ninja\f[R]\-style out\-of\-tree
4799 builds.
4800 This speeds up builds considerably, in particular when \f[B]mkosi\f[R]
4801 is used in incremental mode (\f[CR]\-i\f[R]): not only the image and
4802 build overlay, but also the build tree is reused between subsequent
4803 invocations.
4804 Note that if this directory does not exist the \f[CR]$BUILDDIR\f[R]
4805 environment variable is not set, and it is up to the build scripts to
4806 decide whether to do an in\-tree or an out\-of\-tree build, and which
4807 build directory to use.
4808 .IP \[bu] 2
4809 The \f[B]\f[CB]mkosi.rootpw\f[B]\f[R] file can be used to provide the
4810 password for the root user of the image.
4811 If the password is prefixed with \f[CR]hashed:\f[R] it is treated as an
4812 already hashed root password.
4813 The password may optionally be followed by a newline character which is
4814 implicitly removed.
4815 The file must have an access mode of 0600 or less.
4816 If this file does not exist, the distribution\[cq]s default root
4817 password is set (which usually means access to the root user is
4818 blocked).
4819 .IP \[bu] 2
4820 The \f[B]\f[CB]mkosi.passphrase\f[B]\f[R] file provides the passphrase
4821 to use when LUKS encryption is selected.
4822 It should contain the passphrase literally, and not end in a newline
4823 character (i.e.\ in the same format as \f[B]cryptsetup\f[R] and
4824 \f[CR]/etc/crypttab\f[R] expect the passphrase files).
4825 The file must have an access mode of 0600 or less.
4826 .IP \[bu] 2
4827 The \f[B]\f[CB]mkosi.crt\f[B]\f[R] and \f[B]\f[CB]mkosi.key\f[B]\f[R]
4828 files contain an X.509 certificate and PEM private key to use when
4829 signing is required (UEFI SecureBoot, verity, \&...).
4830 .IP \[bu] 2
4831 The \f[B]\f[CB]mkosi.output/\f[B]\f[R] directory is used to store all
4832 build artifacts.
4833 .IP \[bu] 2
4834 The \f[B]\f[CB]mkosi.credentials/\f[B]\f[R] directory is used as a
4835 source of extra credentials similar to the \f[CR]Credentials=\f[R]
4836 option.
4837 For each file in the directory, the filename will be used as the
4838 credential name and the file contents become the credential value, or,
4839 if the file is executable, \f[B]mkosi\f[R] will execute the file and the
4840 command\[cq]s output to stdout will be used as the credential value.
4841 Output to stderr will be ignored.
4842 Credentials configured with \f[CR]Credentials=\f[R] take precedence over
4843 files in \f[CR]mkosi.credentials\f[R].
4844 .IP \[bu] 2
4845 The \f[B]\f[CB]mkosi.repart/\f[B]\f[R] directory is used as the source
4846 for \f[B]systemd\-repart\f[R] partition definition files which are
4847 passed to \f[B]systemd\-repart\f[R] when building a disk image.
4848 If it does not exist and the \f[CR]RepartDirectories=\f[R] setting is
4849 not configured, \f[B]mkosi\f[R] will default to the following partition
4850 definition files:
4851 .RS 2
4852 .PP
4853 \f[CR]00\-esp.conf\f[R] (if we\[cq]re building a bootable image):
4854 .IP
4855 .EX
4856 \f[B][Partition]\f[R]
4857 Type=esp
4858 Format=vfat
4859 CopyFiles=/boot:/
4860 CopyFiles=/efi:/
4861 SizeMinBytes=512M
4862 SizeMaxBytes=512M
4863 .EE
4864 .PP
4865 \f[CR]05\-bios.conf\f[R] (if we\[cq]re building a BIOS bootable image):
4866 .IP
4867 .EX
4868 \f[B][Partition]\f[R]
4869 \f[I]# UUID of the grub BIOS boot partition which grubs needs on GPT to\f[R]
4870 \f[I]# embed itself into.\f[R]
4871 Type=21686148\-6449\-6e6f\-744e\-656564454649
4872 SizeMinBytes=1M
4873 SizeMaxBytes=1M
4874 .EE
4875 .PP
4876 \f[CR]10\-root.conf\f[R]
4877 .IP
4878 .EX
4879 \f[B][Partition]\f[R]
4880 Type=root
4881 Format=<distribution\-default\-filesystem>
4882 CopyFiles=/
4883 Minimize=guess
4884 .EE
4885 .PP
4886 Note that if either \f[CR]mkosi.repart/\f[R] is found or
4887 \f[CR]RepartDirectories=\f[R] is used, we will not use any of the
4888 default partition definitions.
4889 .RE
4890 .PP
4891 All these files are optional.
4892 .PP
4893 Note that the location of all these files may also be configured during
4894 invocation via command line switches, and as settings in
4895 \f[CR]mkosi.conf\f[R], in case the default settings are not acceptable
4896 for a project.
4897 .SH CACHING
4898 \f[B]mkosi\f[R] supports three different caches for speeding up
4899 repetitive re\-building of images.
4900 Specifically:
4901 .IP "1." 3
4902 The package cache of the distribution package manager may be cached
4903 between builds.
4904 This is configured with the \f[CR]\-\-cache\-directory=\f[R] option or
4905 the \f[CR]mkosi.cache/\f[R] directory.
4906 This form of caching relies on the distribution\[cq]s package manager,
4907 and caches distribution packages (RPM, deb, \&...)
4908 after they are downloaded, but before they are unpacked.
4909 .IP "2." 3
4910 If the incremental build mode is enabled with
4911 \f[CR]\-\-incremental\f[R], cached copies of the final image and build
4912 overlay are made immediately before the build sources are copied in (for
4913 the build overlay) or the artifacts generated by \f[CR]mkosi.build\f[R]
4914 are copied in (in case of the final image).
4915 This form of caching allows bypassing the time\-consuming package
4916 unpacking step of the distribution package managers, but is only
4917 effective if the list of packages to use remains stable, but the build
4918 sources and its scripts change regularly.
4919 Note that this cache requires manual flushing: whenever the package list
4920 is modified the cached images need to be explicitly removed before the
4921 next re\-build, using the \f[CR]\-f\f[R] switch.
4922 .IP "3." 3
4923 Finally, between multiple builds the build artifact directory may be
4924 shared, using the \f[CR]mkosi.builddir/\f[R] directory.
4925 This directory allows build systems such as Meson to reuse already
4926 compiled sources from a previous built, thus speeding up the build
4927 process of a \f[CR]mkosi.build\f[R] build script.
4928 .PP
4929 The package cache and incremental mode are unconditionally useful.
4930 The final cache only apply to uses of \f[B]mkosi\f[R] with a source tree
4931 and build script.
4932 When all three are enabled together turn\-around times for complete
4933 image builds are minimal, as only changed source files need to be
4934 recompiled.
4935 .SH Building multiple images
4936 If the \f[CR]mkosi.images/\f[R] directory exists, \f[B]mkosi\f[R] will
4937 load individual subimage configurations from it and build each of them.
4938 Image configurations can be either directories containing
4939 \f[B]mkosi\f[R] configuration files or regular files with the
4940 \f[CR].conf\f[R] extension.
4941 .PP
4942 When image configurations are found in \f[CR]mkosi.images/\f[R],
4943 \f[B]mkosi\f[R] will build the images specified in the
4944 \f[CR]Dependencies=\f[R] setting of the main image and all of their
4945 dependencies (or all of them if no images were explicitly configured
4946 using \f[CR]Dependencies=\f[R] in the main image configuration).
4947 To add dependencies between subimages, the \f[CR]Dependencies=\f[R]
4948 setting can be used as well.
4949 Subimages are always built before the main image.
4950 .PP
4951 When images are defined, \f[B]mkosi\f[R] will first read the main image
4952 configuration (configuration outside of the \f[CR]mkosi.images/\f[R]
4953 directory), followed by the image specific configuration.
4954 Several \[lq]universal\[rq] settings apply to the main image and all its
4955 subimages and cannot be configured separately in subimages.
4956 The following settings are universal and cannot be configured in
4957 subimages:
4958 .IP \[bu] 2
4959 \f[CR]Architecture=\f[R]
4960 .IP \[bu] 2
4961 \f[CR]BuildDirectory=\f[R]
4962 .IP \[bu] 2
4963 \f[CR]BuildSources=\f[R]
4964 .IP \[bu] 2
4965 \f[CR]BuildSourcesEphemeral=\f[R]
4966 .IP \[bu] 2
4967 \f[CR]CacheDirectory=\f[R]
4968 .IP \[bu] 2
4969 \f[CR]CacheOnly=\f[R]
4970 .IP \[bu] 2
4971 \f[CR]Distribution=\f[R]
4972 .IP \[bu] 2
4973 \f[CR]ExtraSearchPaths=\f[R]
4974 .IP \[bu] 2
4975 \f[CR]Incremental=\f[R]
4976 .IP \[bu] 2
4977 \f[CR]LocalMirror=\f[R]
4978 .IP \[bu] 2
4979 \f[CR]Mirror=\f[R]
4980 .IP \[bu] 2
4981 \f[CR]OutputDirectory=\f[R]
4982 .IP \[bu] 2
4983 \f[CR]OutputMode=\f[R]
4984 .IP \[bu] 2
4985 \f[CR]PackageCacheDirectory=\f[R]
4986 .IP \[bu] 2
4987 \f[CR]PackageDirectories=\f[R]
4988 .IP \[bu] 2
4989 \f[CR]Profiles=\f[R]
4990 .IP \[bu] 2
4991 \f[CR]ProxyClientCertificate=\f[R]
4992 .IP \[bu] 2
4993 \f[CR]ProxyClientKey=\f[R]
4994 .IP \[bu] 2
4995 \f[CR]ProxyExclude=\f[R]
4996 .IP \[bu] 2
4997 \f[CR]ProxyPeerCertificate=\f[R]
4998 .IP \[bu] 2
4999 \f[CR]ProxyUrl=\f[R]
5000 .IP \[bu] 2
5001 \f[CR]Release=\f[R]
5002 .IP \[bu] 2
5003 \f[CR]RepartOffline=\f[R]
5004 .IP \[bu] 2
5005 \f[CR]Repositories=\f[R]
5006 .IP \[bu] 2
5007 \f[CR]RepositoryKeyCheck=\f[R]
5008 .IP \[bu] 2
5009 \f[CR]SandboxTrees=\f[R]
5010 .IP \[bu] 2
5011 \f[CR]SourceDateEpoch=\f[R]
5012 .IP \[bu] 2
5013 \f[CR]ToolsTree=\f[R]
5014 .IP \[bu] 2
5015 \f[CR]ToolsTreeCertificates=\f[R]
5016 .IP \[bu] 2
5017 \f[CR]UseSubvolumes=\f[R]
5018 .IP \[bu] 2
5019 \f[CR]SecureBootCertificate=\f[R]
5020 .IP \[bu] 2
5021 \f[CR]SecureBootCertificateSource=\f[R]
5022 .IP \[bu] 2
5023 \f[CR]SecureBootKey=\f[R]
5024 .IP \[bu] 2
5025 \f[CR]SecureBootKeySource=\f[R]
5026 .IP \[bu] 2
5027 \f[CR]VerityCertificate=\f[R]
5028 .IP \[bu] 2
5029 \f[CR]VerityCertificateSource=\f[R]
5030 .IP \[bu] 2
5031 \f[CR]VerityKey=\f[R]
5032 .IP \[bu] 2
5033 \f[CR]VerityKeySource=\f[R]
5034 .IP \[bu] 2
5035 \f[CR]SignExpectedPcrCertificate=\f[R]
5036 .IP \[bu] 2
5037 \f[CR]SignExpectedPcrCertificateSource=\f[R]
5038 .IP \[bu] 2
5039 \f[CR]SignExpectedPcrKey=\f[R]
5040 .IP \[bu] 2
5041 \f[CR]SignExpectedPcrKeySource=\f[R]
5042 .IP \[bu] 2
5043 \f[CR]VolatilePackageDirectories=\f[R]
5044 .IP \[bu] 2
5045 \f[CR]WithNetwork=\f[R]
5046 .IP \[bu] 2
5047 \f[CR]WithTests\f[R]
5048 .IP \[bu] 2
5049 \f[CR]WorkspaceDirectory=\f[R]
5050 .PP
5051 There are also settings which are passed down to subimages but can be
5052 overridden.
5053 For these settings, values configured explicitly in the subimage will
5054 take priority over values configured on the CLI or in the main image
5055 config.
5056 Currently the following settings are passed down to subimages but can be
5057 overridden:
5058 .IP \[bu] 2
5059 \f[CR]ImageId=\f[R]
5060 .IP \[bu] 2
5061 \f[CR]ImageVersion=\f[R]
5062 .IP \[bu] 2
5063 \f[CR]SectorSize=\f[R]
5064 .PP
5065 Images can refer to outputs of images they depend on.
5066 Specifically, for the following options, \f[B]mkosi\f[R] will only check
5067 whether the inputs exist just before building the image:
5068 .IP \[bu] 2
5069 \f[CR]BaseTrees=\f[R]
5070 .IP \[bu] 2
5071 \f[CR]ExtraTrees=\f[R]
5072 .IP \[bu] 2
5073 \f[CR]Initrds=\f[R]
5074 .PP
5075 To refer to outputs of a image\[cq]s dependencies, simply configure any
5076 of these options with a relative path to the output to use in the output
5077 directory of the dependency.
5078 Or use the \f[CR]%O\f[R] specifier to refer to the output directory.
5079 .PP
5080 A good example on how to build multiple images can be found in the \c
5081 .UR https://github.com/systemd/systemd/tree/main/mkosi.images
5082 systemd
5083 .UE \c
5084 \ repository.
5085 .SH ENVIRONMENT VARIABLES
5086 .IP \[bu] 2
5087 \f[CR]$MKOSI_LESS\f[R] overrides options for \f[B]less\f[R] when it is
5088 invoked by \f[B]mkosi\f[R] to page output.
5089 .IP \[bu] 2
5090 \f[CR]$MKOSI_DNF\f[R] can be used to override the executable used as
5091 \f[B]dnf\f[R].
5092 This is particularly useful to select between \f[B]dnf\f[R] and
5093 \f[B]dnf5\f[R].
5094 .IP \[bu] 2
5095 \f[CR]$EPEL_MIRROR\f[R] can be used to override the default mirror
5096 location used for the epel repositories when \f[CR]Mirror=\f[R] is used.
5097 By default \f[B]mkosi\f[R] looks for the epel repositories in the
5098 \f[CR]fedora\f[R] subdirectory of the parent directory of the mirror
5099 specified in \f[CR]Mirror=\f[R].
5100 For example if the mirror is set to
5101 \f[CR]https://mirror.net/centos\-stream\f[R] \f[B]mkosi\f[R] will look
5102 for the epel repositories in \f[CR]https://mirror.net/fedora/epel\f[R].
5103 .IP \[bu] 2
5104 \f[CR]SYSEXT_SCOPE\f[R] and \f[CR]CONFEXT_SCOPE\f[R] can be used to
5105 override the default value of the respective
5106 \f[CR]extension\-release\f[R] file when building a sysext or confext.
5107 By default the value is set to \f[CR]initrd system portable\f[R].
5108 .SH EXAMPLES
5109 Create and run a raw \f[I]GPT\f[R] image with \f[I]ext4\f[R], as
5110 \f[CR]image.raw\f[R]:
5111 .IP
5112 .EX
5113 # mkosi \-p systemd \-\-incremental boot
5114 .EE
5115 .PP
5116 Create and run a bootable \f[I]GPT\f[R] image, as \f[CR]foobar.raw\f[R]:
5117 .IP
5118 .EX
5119 $ mkosi \-d fedora \-p kernel\-core \-p systemd \-p systemd\-boot \-p udev \-o foobar.raw
5120 # mkosi \-\-output foobar.raw boot
5121 $ mkosi \-\-output foobar.raw vm
5122 .EE
5123 .PP
5124 Create and run a \f[I]Fedora Linux\f[R] image in a plain directory:
5125 .IP
5126 .EX
5127 # mkosi \-\-distribution fedora \-\-format directory boot
5128 .EE
5129 .PP
5130 Create a compressed image \f[CR]image.raw.xz\f[R] with SSH installed and
5131 add a checksum file:
5132 .IP
5133 .EX
5134 $ mkosi \-\-distribution fedora \-\-format disk \-\-checksum \-\-compress\-output \-\-package=openssh\-clients
5135 .EE
5136 .PP
5137 Inside the source directory of an \f[B]automake\f[R]\-based project,
5138 configure \f[B]mkosi\f[R] so that simply invoking \f[B]mkosi\f[R]
5139 without any parameters builds an OS image containing a built version of
5140 the project in its current state:
5141 .IP
5142 .EX
5143 $ cat >mkosi.conf <<EOF
5144 [Distribution]
5145 Distribution=fedora
5146
5147 [Output]
5148 Format=disk
5149
5150 [Content]
5151 Packages=kernel,systemd,systemd\-udev,openssh\-clients,httpd
5152 BuildPackages=make,gcc,libcurl\-devel
5153 EOF
5154 $ cat >mkosi.build <<EOF
5155 #!/bin/sh
5156
5157 if [ \[dq]$container\[dq] != \[dq]mkosi\[dq] ]; then
5158 exec mkosi\-chroot \[dq]$CHROOT_SCRIPT\[dq] \[dq]$\[at]\[dq]
5159 fi
5160
5161 cd $SRCDIR
5162 \&./autogen.sh
5163 \&./configure \-\-prefix=/usr
5164 make \-j \[ga]nproc\[ga]
5165 make install
5166 EOF
5167 $ chmod +x mkosi.build
5168 # mkosi \-\-incremental boot
5169 # systemd\-nspawn \-bi image.raw
5170 .EE
5171 .SS Different ways to boot with \f[CR]vm\f[R]
5172 The easiest way to boot a virtual machine is to build an image with the
5173 required components and let \f[B]mkosi\f[R] call \f[B]qemu\f[R] with all
5174 the right options:
5175 .IP
5176 .EX
5177 $ mkosi \-d fedora \[rs]
5178 \-\-autologin \[rs]
5179 \-p systemd\-udev,systemd\-boot,kernel\-core \[rs]
5180 build
5181 $ mkosi \-d fedora vm
5182 \&...
5183 fedora login: root (automatic login)
5184 [root\[at]fedora \[ti]]#
5185 .EE
5186 .PP
5187 The default is to boot with a text console only.
5188 In this mode, messages from the boot loader, the kernel, and systemd,
5189 and later the \f[B]getty\f[R] login prompt and shell all use the same
5190 terminal.
5191 It is possible to switch between the \f[B]qemu\f[R] console and monitor
5192 by pressing \f[CR]Ctrl\-a c\f[R].
5193 The \f[B]qemu\f[R] monitor may for example be used to inject special
5194 keys or shut down the machine quickly.
5195 Alternatively the machine can be shut down using \f[CR]Ctrl\-a x\f[R].
5196 .PP
5197 To boot with a graphical window, add \f[CR]\-\-console=gui\f[R]:
5198 .IP
5199 .EX
5200 $ mkosi \-d fedora \-\-console=gui qemu
5201 .EE
5202 .PP
5203 A kernel may be booted directly with
5204 \f[CR]mkosi vm \-kernel ... \-initrd ... \-append \[aq]...\[aq]\f[R].
5205 This is a bit faster because no boot loader is used, and it is also
5206 easier to experiment with different kernels and kernel commandlines.
5207 Note that despite the name, \f[B]qemu\f[R]\[cq]s \f[CR]\-append\f[R]
5208 option replaces the default kernel commandline embedded in the kernel
5209 and any previous \f[CR]\-append\f[R] specifications.
5210 .PP
5211 The UKI is also copied into the output directory and may be booted
5212 directly:
5213 .IP
5214 .EX
5215 $ mkosi vm \-kernel mkosi.output/fedora\[ti]38/image.efi
5216 .EE
5217 .PP
5218 When booting using an external kernel, we don\[cq]t need the kernel
5219 \f[I]in\f[R] the image, but we would still want the kernel modules to be
5220 installed.
5221 .PP
5222 It is also possible to do a \f[I]direct kernel boot\f[R] into a boot
5223 loader, taking advantage of the fact that \f[B]systemd\-boot\f[R](7) is
5224 a valid UEFI binary:
5225 .IP
5226 .EX
5227 $ mkosi vm \-kernel /usr/lib/systemd/boot/efi/systemd\-bootx64.efi
5228 .EE
5229 .PP
5230 In this scenario, the kernel is loaded from the ESP in the image by
5231 \f[B]systemd\-boot\f[R].
5232 .SH REQUIREMENTS
5233 mkosi is packaged for various distributions: Debian, Kali, Ubuntu, Arch
5234 Linux, Fedora Linux, OpenMandriva, Gentoo.
5235 Note that it has been a while since the last release and the packages
5236 shipped by distributions are very out of date.
5237 We currently recommend running \f[B]mkosi\f[R] from git until a new
5238 release happens.
5239 .PP
5240 mkosi requires a Linux kernel that provides \f[CR]mount_setattr()\f[R]
5241 which was introduces in 5.12.
5242 .PP
5243 mkosi currently requires systemd 254 to build bootable disk images.
5244 .PP
5245 When not using distribution packages make sure to install the necessary
5246 dependencies.
5247 For example, on \f[I]Fedora Linux\f[R] you need:
5248 .IP
5249 .EX
5250 \f[I]# dnf install btrfs\-progs apt dosfstools mtools edk2\-ovmf e2fsprogs squashfs\-tools gnupg python3 tar xfsprogs xz zypper sbsigntools\f[R]
5251 .EE
5252 .PP
5253 On Debian/Kali/Ubuntu it might be necessary to install the
5254 \f[CR]ubuntu\-keyring\f[R], \f[CR]ubuntu\-archive\-keyring\f[R],
5255 \f[CR]kali\-archive\-keyring\f[R] and/or
5256 \f[CR]debian\-archive\-keyring\f[R] packages explicitly, in addition to
5257 \f[B]apt\f[R], depending on what kind of distribution images you want to
5258 build.
5259 .PP
5260 Note that the minimum required Python version is 3.9.
5261 .PP
5262 mkosi needs unrestricted abilities to create and act within namespaces.
5263 Some distros restrict creation of, or capabilities within, user
5264 namespaces, which breaks mkosi.
5265 .PP
5266 For information about Ubuntu, that implements such restrictions using
5267 AppArmor, see
5268 https://ubuntu.com/blog/ubuntu\-23\-10\-restricted\-unprivileged\-user\-namespaces.
5269 For other systems, try researching the
5270 \f[CR]kernel.unprivileged_userns_clone\f[R] or
5271 \f[CR]user.max.user_namespace\f[R] sysctls.
5272 .PP
5273 For Ubuntu systems, you can remove the restrictions for \f[B]mkosi\f[R]
5274 by adapting this snippet to point to your \f[B]mkosi\f[R] binary,
5275 copying it to \f[CR]/etc/apparmor.d/path.to.mkosi\f[R], and then running
5276 \f[CR]systemctl reload apparmor\f[R]:
5277 .IP
5278 .EX
5279 abi <abi/4.0>,
5280
5281 include <tunables/global>
5282
5283 /path/to/mkosi flags=(default_allow) {
5284 userns,
5285 }
5286 .EE
5287 .SH Frequently Asked Questions (FAQ)
5288 .IP \[bu] 2
5289 Why does \f[CR]mkosi vm\f[R] with KVM not work on Debian/Kali/Ubuntu?
5290 .RS 2
5291 .PP
5292 While other distributions are OK with allowing access to
5293 \f[CR]/dev/kvm\f[R], on Debian/Kali/Ubuntu this is only allowed for
5294 users in the \f[CR]kvm\f[R] group.
5295 Because \f[B]mkosi\f[R] unshares a user namespace when running
5296 unprivileged, even if the calling user was in the kvm group, when
5297 \f[B]mkosi\f[R] unshares the user namespace to run unprivileged, it
5298 loses access to the \f[CR]kvm\f[R] group and by the time we start
5299 \f[B]qemu\f[R] we don\[cq]t have access to \f[CR]/dev/kvm\f[R] anymore.
5300 As a workaround, you can change the permissions of the device nodes to
5301 \f[CR]0666\f[R] which is sufficient to make KVM work unprivileged.
5302 To persist these settings across reboots, copy
5303 \f[CR]/usr/lib/tmpfiles.d/static\-nodes\-permissions.conf\f[R] to
5304 \f[CR]/etc/tmpfiles.d/static\-nodes\-permissions.conf\f[R] and change
5305 the mode of \f[CR]/dev/kvm\f[R] from \f[CR]0660\f[R] to \f[CR]0666\f[R].
5306 .RE
5307 .IP \[bu] 2
5308 How do I add a regular user to an image?
5309 .RS 2
5310 .PP
5311 You can use the following snippet in a post\-installation script:
5312 .IP
5313 .EX
5314 useradd \-\-create\-home \-\-user\-group $USER \-\-password \[dq]$(openssl passwd \-stdin \-6 <$USER_PASSWORD_FILE)\[dq]
5315 .EE
5316 .PP
5317 Note that from systemd v256 onwards, if enabled,
5318 \f[B]systemd\-homed\-firstboot.service\f[R] will prompt to create a
5319 regular user on first boot if there are no regular users.
5320 .RE
5321 .IP \[bu] 2
5322 Why do I see failures to chown files when building images?
5323 .RS 2
5324 .PP
5325 When not running as root, your user is not able to change ownership of
5326 files to arbitrary owners.
5327 Various distributions still ship files in their packages that are not
5328 owned by the root user.
5329 When not running as root, mkosi maps the current user to root when
5330 invoking package managers, which means that changing ownership to root
5331 will work but changing ownership to any other user or group will fail.
5332 .PP
5333 Note that chown calls are only suppressed when running package managers,
5334 but not when running scripts.
5335 If this is required, e.g.\ for a build script, you can set the
5336 \f[CR]MKOSI_CHROOT_SUPPRESS_CHOWN\f[R] variable to a true value
5337 (\f[CR]1\f[R], \f[CR]yes\f[R], \f[CR]true\f[R]) to suppress chown calls
5338 in \f[B]mkosi\-chroot\f[R] and \f[CR].chroot\f[R] scripts.
5339 .PP
5340 If this behavior causes applications running in your image to misbehave,
5341 you can consider running \f[B]mkosi\f[R] as root which avoids this
5342 problem.
5343 Alternatively, if running \f[B]mkosi\f[R] as root is not desired, you
5344 can use
5345 \f[CR]unshare \-\-map\-auto \-\-map\-current\-user \-\-setuid 0 \-\-setgid 0\f[R]
5346 to become root in a user namespace with more than one user assuming the
5347 UID/GID mappings in \f[CR]/etc/subuid\f[R] and \f[CR]/etc/subgid\f[R]
5348 are configured correctly.
5349 Note that running mkosi as root or with \f[CR]unshare\f[R] means that
5350 all output files produced by \f[B]mkosi\f[R] will not be owned by your
5351 current user anymore.
5352 .PP
5353 Note that for systemd services that need directories in \f[CR]/var\f[R]
5354 owned by the service user and group, an alternative to shipping these
5355 directories in packages or creating them via systemd\-tmpfiles is to use
5356 \f[CR]StateDirectory=\f[R], \f[CR]CacheDirectory=\f[R] or
5357 \f[CR]LogsDirectory=\f[R] in the service file which instructs systemd to
5358 create the directory when it first starts the service.
5359 .PP
5360 Alternatively, the \f[CR]z\f[R] or \f[CR]Z\f[R] directives for
5361 \f[CR]systemd\-tmpfiles\f[R] can be used to chown various directories
5362 and files to their owning user when the system first boots up.
5363 .RE
5364 .IP \[bu] 2
5365 Why does
5366 \f[CR]portablectl inspect <image>\f[R]/\f[CR]systemd\-dissect <image>\f[R]
5367 say my portable service isn\[cq]t one?
5368 .RS 2
5369 .PP
5370 \f[CR]systemd\-dissect\f[R] and\f[CR]portablectl inspect\f[R] check for
5371 \f[CR]PORTABLE_PREFIXES=\f[R] in \f[CR]os\-release\f[R] and if the key
5372 is missing, will fail to recognise a portable service as one, showing ✗
5373 under \f[I]Use as\f[R] for in the case of \f[CR]systemd\-dissect\f[R] or
5374 \f[CR]n/a\f[R] under \f[I]Portable Service\f[R] for
5375 \f[CR]portablectl\f[R].
5376 .PP
5377 Since there is no good default to set for this key and the generated
5378 portable service images will still attach properly, even when the key is
5379 not set, \f[B]mkosi\f[R] doesn\[cq]t set one.
5380 .PP
5381 You can set \f[CR]PORTABLE_PREFIXES=\f[R] in the \f[CR]os\-release\f[R]
5382 file yourself in a postinst script.
5383 .RE
5384 .SH REFERENCES
5385 .IP \[bu] 2
5386 \c
5387 .UR https://github.com/systemd/mkosi/
5388 Primary mkosi git repository on GitHub
5389 .UE \c
5390 .IP \[bu] 2
5391 \c
5392 .UR https://0pointer.net/blog/mkosi-a-tool-for-generating-os-images.html
5393 mkosi \[em] A Tool for Generating OS Images
5394 .UE \c
5395 \ introductory blog post by Lennart Poettering
5396 .IP \[bu] 2
5397 \c
5398 .UR https://lwn.net/Articles/726655/
5399 The mkosi OS generation tool
5400 .UE \c
5401 \ story on LWN
5402 .SH SEE ALSO
5403 \f[B]systemd\-nspawn\f[R](1), \f[B]systemd\-repart\f[R](8),
5404 \f[B]dnf\f[R](8)