Debian Codegraph @

upstream/opensuse-tumbleweed/man1/systemd-vmspawn.1

raw
1 '\" t
2 .TH "SYSTEMD\-VMSPAWN" "1" "" "systemd 260.1" "systemd-vmspawn"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 systemd-vmspawn \- Spawn an OS in a virtual machine
24 .SH "SYNOPSIS"
25 .HP \w'\fBsystemd\-vmspawn\fR\ 'u
26 \fBsystemd\-vmspawn\fR [OPTIONS...] [ARGS...]
27 .SH "DESCRIPTION"
28 .PP
29 \fBsystemd\-vmspawn\fR
30 may be used to start a virtual machine from an OS image\&. In many ways it is similar to
31 \fBsystemd-nspawn\fR(1), but launches a full virtual machine instead of using namespaces\&.
32 .PP
33 File descriptors for
34 /dev/kvm
35 and
36 /dev/vhost\-vsock
37 can be passed to
38 \fBsystemd\-vmspawn\fR
39 via systemd\*(Aqs native socket passing interface (see
40 \fBsd_listen_fds\fR(3)
41 for details about the precise protocol used and the order in which the file descriptors are passed), these file descriptors must be passed with the names
42 "kvm"
43 and
44 "vhost\-vsock"
45 respectively\&.
46 .PP
47 Note: on Ubuntu/Debian derivatives
48 \fBsystemd\-vmspawn\fR
49 requires the user to be in the
50 "kvm"
51 group to use the VSOCK options\&.
52 .SH "OPTIONS"
53 .PP
54 The excess arguments are passed as extra kernel command line arguments using SMBIOS\&.
55 .PP
56 The following options are understood:
57 .PP
58 \fB\-q\fR, \fB\-\-quiet\fR
59 .RS 4
60 Turns off any status output by the tool itself\&. When this switch is used, the only output from vmspawn will be the console output of the Virtual Machine OS itself\&.
61 .sp
62 Added in version 256\&.
63 .RE
64 .PP
65 \fB\-\-system\fR, \fB\-\-user\fR
66 .RS 4
67 Specify whether to interact with the user manager or the system manager and whether to register with the user machined instance or the system machined instance\&. If unspecified, the system manager and machined instance will be used when running as root, otherwise the user manager and machined instance will be used\&.
68 .sp
69 Added in version 260\&.
70 .RE
71 .SS "Image Options"
72 .PP
73 \fB\-D\fR, \fB\-\-directory=\fR
74 .RS 4
75 Directory to use as file system root for the virtual machine\&.
76 .sp
77 One of either
78 \fB\-\-directory=\fR
79 or
80 \fB\-\-image=\fR
81 must be specified\&. If neither are specified
82 \fB\-\-directory=\&.\fR
83 is assumed\&.
84 .sp
85 Note: If mounting a non\-root owned directory you may require
86 \fB\-\-private\-users=\fR
87 to map into the user\*(Aqs subuid namespace\&. An example of how to use
88 \fB/etc/subuid\fR
89 for this is given later\&.
90 .sp
91 Added in version 256\&.
92 .RE
93 .PP
94 \fB\-i\fR, \fB\-\-image=\fR
95 .RS 4
96 Root file system disk image (or device node) for the virtual machine\&.
97 .sp
98 Added in version 255\&.
99 .RE
100 .PP
101 \fB\-\-image\-format=\fR\fB\fIFORMAT\fR\fR
102 .RS 4
103 Specifies the format of the disk image passed to
104 \fB\-\-image=\fR\&. Takes either
105 "raw"
106 or
107 "qcow2"\&. Defaults to
108 "raw"\&. Note that
109 "qcow2"
110 is only supported for regular files, not block devices\&.
111 .sp
112 Added in version 260\&.
113 .RE
114 .PP
115 \fB\-x\fR, \fB\-\-ephemeral\fR
116 .RS 4
117 If specified, the VM is run with a temporary snapshot of its file system that is removed immediately when the VM terminates\&. Only works with
118 \fB\-\-image=\fR
119 currently\&. Note that
120 \fB\-\-ephemeral\fR
121 will not work with
122 \fB\-\-extra\-drive=\fR\&.
123 .sp
124 Added in version 260\&.
125 .RE
126 .SS "Host Configuration"
127 .PP
128 \fB\-\-cpus=\fR\fB\fICPUS\fR\fR
129 .RS 4
130 The number of CPUs to start the virtual machine with\&. Defaults to 1\&.
131 .sp
132 Added in version 255\&.
133 .RE
134 .PP
135 \fB\-\-ram=\fR\fB\fIBYTES\fR\fR
136 .RS 4
137 The amount of memory to start the virtual machine with\&. Defaults to 2G\&.
138 .sp
139 Added in version 255\&.
140 .RE
141 .PP
142 \fB\-\-kvm=\fR\fB\fIBOOL\fR\fR
143 .RS 4
144 Controls whether to enable KVM acceleration\&. If not specified or set to
145 \fBauto\fR, KVM support will be detected automatically\&. If true, KVM is insisted on\&. If false, disable KVM\&.
146 .sp
147 Added in version 255\&.
148 .RE
149 .PP
150 \fB\-\-vsock=\fR\fB\fIBOOL\fR\fR
151 .RS 4
152 Controls whether to allocate a VSOCK socket for guest\&. If not specified or set to
153 \fBauto\fR, VSOCK networking support will be detected automatically\&. If true, VSOCK is insisted on\&. If false, VSOCK networking is disabled\&.
154 .sp
155 Added in version 255\&.
156 .RE
157 .PP
158 \fB\-\-vsock\-cid=\fR\fB\fICID\fR\fR
159 .RS 4
160 Sets the specific CID to use for the guest\&. Valid CIDs are in the range
161 \fB3\fR
162 to
163 \fB4294967294\fR
164 (\fB0xFFFF_FFFE\fR)\&. CIDs outside of this range are reserved\&. By default, vmspawn will attempt to derive a CID for the guest derived from the machine name, falling back to a random CID if this CID is taken\&.
165 .sp
166 Added in version 255\&.
167 .RE
168 .PP
169 \fB\-\-tpm=\fR\fB\fIBOOL\fR\fR
170 .RS 4
171 Controls whether to serve a TPM device for guest, via
172 \fBswtpm\fR(8)\&. If not specified or set to
173 \fBauto\fR, vmspawn will detect the presence of swtpm binary automatically\&. If yes, swtpm support is insisted on\&. If no, TPM is disabled\&.
174 .sp
175 Added in version 256\&.
176 .RE
177 .PP
178 \fB\-\-tpm\-state=\fR\fB\fIPATH\fR\fR\fB|auto|off\fR
179 .RS 4
180 Configures where to place TPM state, in case TPM support is enabled (see
181 \fB\-\-tpm=\fR
182 above)\&. This takes an absolute file system path to a directory to persistently place the state in\&. If the directory is missing it is created as needed\&. If set to the special string
183 "auto"
184 a persistent path is automatically derived from the VM image path or directory path, with the
185 "\&.tpmstate"
186 suffix appended\&. If set to the special string
187 "off"
188 the TPM state is only maintained transiently and flushed out when the VM shuts down\&. This mode is not suitable for VMs which lock disk encryption keys to the TPM, as these keys will be lost on every reboot\&. Defaults to
189 "auto"\&.
190 .sp
191 If
192 \fB\-\-ephemeral\fR
193 is specified,
194 "auto"
195 behaves like
196 "off"\&.
197 .sp
198 Added in version 258\&.
199 .RE
200 .PP
201 \fB\-\-linux=\fR\fB\fIPATH\fR\fR
202 .RS 4
203 Set the linux kernel image to use for direct kernel boot\&. If a directory type image is used and
204 \fB\-\-linux=\fR
205 was omitted, vmspawn will search for boot loader entries according to the
206 \m[blue]\fBUAPI\&.1 Boot Loader Specification\fR\m[]\&\s-2\u[1]\d\s+2
207 assuming XBOOTLDR to be located at /boot and ESP to be /efi respectively\&. If no kernel was installed into the image then the image will fail to boot\&.
208 .sp
209 Added in version 256\&.
210 .RE
211 .PP
212 \fB\-\-initrd=\fR\fB\fIPATH\fR\fR
213 .RS 4
214 Set the initrd to use for direct kernel boot\&. If the
215 \fB\-\-linux=\fR
216 supplied is a
217 \m[blue]\fBUAPI\&.1 Boot Loader Specification\fR\m[]\&\s-2\u[1]\d\s+2
218 Type #2 entry, then this argument is not required\&. If no initrd was installed into the image then the image will fail to boot\&.
219 .sp
220 \fB\-\-initrd=\fR
221 can be specified multiple times and vmspawn will merge them together\&.
222 .sp
223 Added in version 256\&.
224 .RE
225 .PP
226 \fB\-n\fR, \fB\-\-network\-tap\fR
227 .RS 4
228 Create a TAP device to network with the virtual machine\&.
229 .sp
230 Note: root privileges are required to use TAP networking\&. Additionally,
231 \fBsystemd-networkd\fR(8)
232 must be running and correctly set up on the host to provision the host interface\&. The relevant
233 "\&.network"
234 file can be found at
235 /usr/lib/systemd/network/80\-vm\-vt\&.network\&.
236 .sp
237 Added in version 255\&.
238 .RE
239 .PP
240 \fB\-\-network\-user\-mode\fR
241 .RS 4
242 Use user mode networking\&.
243 .sp
244 Added in version 255\&.
245 .RE
246 .PP
247 \fB\-\-firmware=\fR\fB\fIPATH\fR\fR
248 .RS 4
249 Takes an absolute path, or a relative path beginning with
250 \&./\&. Specifies a JSON firmware definition file, which allows selecting the firmware to boot in the VM\&. If not specified, a suitable firmware is automatically discovered\&. If the special string
251 "list"
252 is specified lists all discovered firmwares\&.
253 .sp
254 Added in version 256\&.
255 .RE
256 .PP
257 \fB\-\-discard\-disk=\fR\fB\fIBOOL\fR\fR
258 .RS 4
259 Controls whether qemu processes discard requests from the VM\&. This prevents long running VMs from using more disk space than required\&. This is enabled by default\&.
260 .sp
261 Added in version 256\&.
262 .RE
263 .PP
264 \fB\-\-secure\-boot=\fR\fB\fIBOOL\fR\fR
265 .RS 4
266 Configure whether to search for firmware which supports Secure Boot\&.
267 .sp
268 If the option is not specified or set to
269 \fBauto\fR, the first firmware detected will be used\&. If the option is set to yes, then the first firmware with Secure Boot support will be selected\&. If no is specified, then the first firmware without Secure Boot will be selected\&.
270 .sp
271 Added in version 255\&.
272 .RE
273 .PP
274 \fB\-\-grow\-image=\fR\fB\fIBYTES\fR\fR, \fB\-G \fR\fB\fIBYTES\fR\fR
275 .RS 4
276 Grows the image file specified by
277 \fB\-\-image=\fR
278 to the specified size in bytes if it is smaller\&. Executes no operation if no image file is used or the image file is already as large or larger than requested\&. The specified size accepts the usual K, M, G suffixes (to the base of 1024)\&. Specified values are rounded up to multiples of 4096\&.
279 .sp
280 Added in version 258\&.
281 .RE
282 .PP
283 \fB\-\-smbios11=\fR\fB\fISTRING\fR\fR, \fB\-s \fR\fB\fISTRING\fR\fR
284 .RS 4
285 Passes the specified string into the VM as an SMBIOS Type #11 vendor string\&. This is useful to parameterize the invoked VM in various ways\&. See
286 \fBsmbios-type-11\fR(7)
287 for details\&.
288 .sp
289 Added in version 258\&.
290 .RE
291 .PP
292 \fB\-\-notify\-ready=\fR
293 .RS 4
294 Configures support for notifications from the VM\*(Aqs init process to
295 \fBsystemd\-vmspawn\fR\&. If true,
296 \fBsystemd\-vmspawn\fR
297 will consider the machine as ready only when it has received a
298 "READY=1"
299 message from the init process in the VM\&. If false,
300 \fBsystemd\-vmspawn\fR
301 will consider the machine as ready immediately after creation\&. In either case,
302 \fBsystemd\-vmspawn\fR
303 sends its own readiness notification to its manager after the spawned VM is ready\&. For more details about notifications see
304 \fBsd_notify\fR(3)\&.
305 .sp
306 Defaults to true\&. (Note that this is unlike the option of the same name to
307 \fBsystemd-nspawn\fR(1)
308 that defaults to false\&.)
309 .sp
310 Added in version 258\&.
311 .RE
312 .SS "System Identity Options"
313 .PP
314 \fB\-M\fR, \fB\-\-machine=\fR
315 .RS 4
316 Sets the machine name for this virtual machine\&. This name may be used to identify this virtual machine during its runtime (for example in tools like
317 \fBmachinectl\fR(1)
318 and similar)\&.
319 .sp
320 Added in version 255\&.
321 .RE
322 .PP
323 \fB\-\-uuid=\fR
324 .RS 4
325 Set the specified UUID for the virtual machine\&. The init system will initialize
326 /etc/machine\-id
327 from this if this file is not set yet\&. Note that this option takes effect only if
328 /etc/machine\-id
329 in the virtual machine is unpopulated\&.
330 .sp
331 Added in version 256\&.
332 .RE
333 .SS "Property Options"
334 .PP
335 \fB\-S\fR, \fB\-\-slice=\fR
336 .RS 4
337 Make the VM part of the specified slice, instead of the default
338 machine\&.slice\&. This applies only if the machine is run in its own scope unit, i\&.e\&. if
339 \fB\-\-keep\-unit\fR
340 is not used\&.
341 .sp
342 Added in version 258\&.
343 .RE
344 .PP
345 \fB\-\-property=\fR
346 .RS 4
347 Set a unit property on the scope unit to register for the machine\&. This applies only if the machine is run in its own scope unit, i\&.e\&. if
348 \fB\-\-keep\-unit\fR
349 is not used\&. Takes unit property assignments in the same format as
350 \fBsystemctl set\-property\fR\&. This is useful to set memory limits and similar for the VM\&.
351 .sp
352 Added in version 258\&.
353 .RE
354 .PP
355 \fB\-\-register=\fR
356 .RS 4
357 Controls whether the virtual machine is registered with
358 \fBsystemd-machined\fR(8)\&. Takes a boolean argument, which defaults to
359 "yes"
360 when running as root, and
361 "no"
362 when running as a regular user\&. This ensures that the virtual machine is accessible via
363 \fBmachinectl\fR(1)\&.
364 .sp
365 Note: root privileges are required to use this option as registering with
366 \fBsystemd-machined\fR(8)
367 requires privileged D\-Bus method calls\&.
368 .sp
369 Added in version 256\&.
370 .RE
371 .SS "User Namespacing Options"
372 .PP
373 \fB\-\-private\-users=\fR\fB\fIUID_SHIFT[:UID_RANGE]\fR\fR
374 .RS 4
375 Controls user namespacing under
376 \fB\-\-directory=\fR\&. If enabled,
377 \fBvirtiofsd\fR(1)
378 is instructed to map user and group ids (UIDs and GIDs)\&. This involves mapping the private UIDs/GIDs used in the virtual machine (starting with the virtual machine\*(Aqs root user 0 and up) to a range of UIDs/GIDs on the host that are not used for other purposes (usually in the range beyond the host\*(Aqs UID/GID 65536)\&.
379 .sp
380 If one or two colon\-separated numbers are specified, user namespacing is turned on\&.
381 \fIUID_SHIFT\fR
382 specifies the first host UID/GID to map,
383 \fIUID_RANGE\fR
384 is optional and specifies number of host UIDs/GIDs to assign to the virtual machine\&. If
385 \fIUID_RANGE\fR
386 is omitted, 65536 UIDs/GIDs are assigned\&.
387 .sp
388 When user namespaces are used, the GID range assigned to each virtual machine is always chosen identical to the UID range\&.
389 .sp
390 Added in version 256\&.
391 .RE
392 .SS "Mount Options"
393 .PP
394 \fB\-\-bind=\fR\fB\fIPATH\fR\fR, \fB\-\-bind\-ro=\fR\fB\fIPATH\fR\fR
395 .RS 4
396 Mount a directory from the host into the virtual machine\&. Takes one of: a path argument\ \&\(em in which case the specified path will be mounted from the host to the same path in the virtual machine, or a colon\-separated pair of paths\ \&\(em in which case the first specified path is the source in the host, and the second path is the destination in the virtual machine\&. If the source path is not absolute, it is resolved relative to the current working directory\&. The
397 \fB\-\-bind\-ro=\fR
398 option creates read\-only bind mounts\&. Backslash escapes are interpreted, so
399 "\e:"
400 may be used to embed colons in either path\&. This option may be specified multiple times for creating multiple independent bind mount points\&.
401 .sp
402 Added in version 256\&.
403 .RE
404 .PP
405 \fB\-\-extra\-drive=[\fR\fB\fIFORMAT\fR\fR\fB:]\fR\fB\fIPATH\fR\fR
406 .RS 4
407 Takes a disk image or block device on the host and supplies it to the virtual machine as another drive\&. Optionally, the image format can be specified by prefixing the path with
408 "raw"
409 or
410 "qcow2"
411 and a colon\&. The format defaults to
412 "raw"\&. Note that
413 "qcow2"
414 is only supported for regular files, not block devices\&.
415 .sp
416 Added in version 256\&.
417 .RE
418 .PP
419 \fB\-\-bind\-user=\fR
420 .RS 4
421 Binds the home directory of the specified user on the host into the virtual machine\&. Takes the name of an existing user on the host as argument\&. May be used multiple times to bind multiple users into the virtual machine\&. This does two things:
422 .sp
423 .RS 4
424 .ie n \{\
425 \h'-04' 1.\h'+01'\c
426 .\}
427 .el \{\
428 .sp -1
429 .IP " 1." 4.2
430 .\}
431 The user\*(Aqs home directory is made available from the host into
432 /run/vmhost/home/
433 using virtiofs\&. virtiofsd id translation to map the host user\*(Aqs UID/GID to its assigned UID/GID in the virtual machine\&.
434 .RE
435 .sp
436 .RS 4
437 .ie n \{\
438 \h'-04' 2.\h'+01'\c
439 .\}
440 .el \{\
441 .sp -1
442 .IP " 2." 4.2
443 .\}
444 JSON user and group records are generated in that describes the mapped user which are passed into the virtual machine using
445 "userdb\&.transient\&.*"
446 credentials\&. They contain a minimized representation of the host\*(Aqs user record, adjusted to the UID/GID and home directory path assigned to the user in the virtual machine\&. The
447 \fBnss-systemd\fR(8)
448 glibc NSS module will pick up these records from there and make them available in the virtual machine\*(Aqs user/group databases\&.
449 .RE
450 .sp
451 The combination of the two operations above ensures that it is possible to log into the virtual machine using the same account information as on the host\&. The user is only mapped transiently, while the virtual machine is running, and the mapping itself does not result in persistent changes to the virtual machine (except maybe for log messages generated at login time, and similar)\&. Note that in particular the UID/GID assignment in the virtual machine is not made persistently\&. If the user is mapped transiently, it is best to not allow the user to make persistent changes to the virtual machine\&. If the user leaves files or directories owned by the user, and those UIDs/GIDs are reused during later virtual machine invocations (possibly with a different
452 \fB\-\-bind\-user=\fR
453 mapping), those files and directories will be accessible to the "new" user\&.
454 .sp
455 The user/group record mapping only works if the virtual machine contains systemd 258 or newer, with
456 \fBnss\-systemd\fR
457 properly configured in
458 nsswitch\&.conf\&. See
459 \fBnss-systemd\fR(8)
460 for details\&.
461 .sp
462 Note that the user record propagated from the host into the virtual machine will contain the UNIX password hash of the user, so that seamless logins in the virtual machine are possible\&. If the virtual machine is less trusted than the host it is hence important to use a strong UNIX password hash function (e\&.g\&. yescrypt or similar, with the
463 "$y$"
464 hash prefix)\&.
465 .sp
466 Added in version 259\&.
467 .RE
468 .PP
469 \fB\-\-bind\-user\-shell=\fR
470 .RS 4
471 When used with
472 \fB\-\-bind\-user=\fR, includes the specified shell in the user records of users bound into the virtual machine\&. Takes either a boolean or an absolute path\&.
473 .sp
474 .RS 4
475 .ie n \{\
476 \h'-04'\(bu\h'+03'\c
477 .\}
478 .el \{\
479 .sp -1
480 .IP \(bu 2.3
481 .\}
482 If false (the default), no shell is passed in the user records for users bound into the virtual machine\&. This causes bound users to the use the virtual machine\*(Aqs default shell\&.
483 .RE
484 .sp
485 .RS 4
486 .ie n \{\
487 \h'-04'\(bu\h'+03'\c
488 .\}
489 .el \{\
490 .sp -1
491 .IP \(bu 2.3
492 .\}
493 If true, the shells specified by the host user records are included in the user records of all users bound into the virtual machine\&.
494 .RE
495 .sp
496 .RS 4
497 .ie n \{\
498 \h'-04'\(bu\h'+03'\c
499 .\}
500 .el \{\
501 .sp -1
502 .IP \(bu 2.3
503 .\}
504 If passed an absolute path, sets that path as the shell for user records of all users bound into the virtual machine\&.
505 .RE
506 .sp
507 Note: This will not check whether the specified shells exist in the virtual machine\&.
508 .sp
509 This operation is only supported in combination with
510 \fB\-\-bind\-user=\fR\&.
511 .sp
512 Added in version 259\&.
513 .RE
514 .PP
515 \fB\-\-bind\-user\-group=\fR\fB\fINAME\fR\fR
516 .RS 4
517 When used with
518 \fB\-\-bind\-user=\fR, includes the specified group as an auxiliary group in the user records of users bound into the virtual machine\&. Takes a group name\&.
519 .sp
520 Note: This will not check whether the specified groups exist in the virtual machine\&.
521 .sp
522 This operation is only supported in combination with
523 \fB\-\-bind\-user=\fR\&.
524 .sp
525 Added in version 259\&.
526 .RE
527 .SS "Integration Options"
528 .PP
529 \fB\-\-forward\-journal=\fR\fB\fIFILE|DIR\fR\fR
530 .RS 4
531 Forward the virtual machine\*(Aqs journal to the host\&.
532 \fBsystemd-journal-remote\fR(8)
533 is currently used to receive the guest VM\*(Aqs forwarded journal entries\&. This option determines where this journal is saved on the host and has the same semantics as
534 \fB\-o\fR/\fB\-\-output\fR
535 described in
536 \fBsystemd-journal-remote\fR(8)\&.
537 .sp
538 Added in version 256\&.
539 .RE
540 .PP
541 \fB\-\-pass\-ssh\-key=\fR\fB\fIBOOL\fR\fR
542 .RS 4
543 By default, an SSH key is generated to allow
544 \fBsystemd\-vmspawn\fR
545 to open a D\-Bus connection to the VM\*(Aqs systemd bus\&. Setting this to "no" will disable SSH key generation\&.
546 .sp
547 The generated keys are ephemeral\&. That is they are valid only for the current invocation of
548 \fBsystemd\-vmspawn\fR, and are typically not persisted\&.
549 .sp
550 Added in version 256\&.
551 .RE
552 .PP
553 \fB\-\-ssh\-key\-type=\fR\fB\fITYPE\fR\fR
554 .RS 4
555 Configures the type of SSH key to generate, see
556 \fBssh-keygen\fR(1)
557 for more information\&.
558 .sp
559 By default,
560 "ed25519"
561 keys are generated, however
562 "rsa"
563 keys may also be useful if the VM has a particularly old version of
564 \fBsshd\fR(8)\&.
565 .sp
566 Added in version 256\&.
567 .RE
568 .SS "Input/Output Options"
569 .PP
570 \fB\-\-console=\fR\fB\fIMODE\fR\fR
571 .RS 4
572 Configures how to set up the console of the VM\&. Takes one of
573 "interactive",
574 "read\-only",
575 "native",
576 "gui"\&. Defaults to
577 "interactive"\&.
578 "interactive"
579 provides an interactive terminal interface to the VM\&.
580 "read\-only"
581 is similar, but is strictly read\-only, i\&.e\&. does not accept any input from the user\&.
582 "native"
583 also provides a TTY\-based interface, but uses qemu native implementation (which means the qemu monitor is available)\&.
584 "gui"
585 shows the qemu graphical UI\&.
586 .sp
587 Added in version 256\&.
588 .RE
589 .PP
590 \fB\-\-background=\fR\fB\fICOLOR\fR\fR
591 .RS 4
592 Change the terminal background color to the specified ANSI color as long as the VM runs\&. The color specified should be an ANSI X3\&.64 SGR background color, i\&.e\&. strings such as
593 "40",
594 "41", \&...,
595 "47",
596 "48;2;\&...",
597 "48;5;\&..."\&. See
598 \m[blue]\fBANSI Escape Code (Wikipedia)\fR\m[]\&\s-2\u[2]\d\s+2
599 for details\&. Assign an empty string to disable any coloring\&. This only has an effect in
600 \fB\-\-console=interactive\fR
601 and
602 \fB\-\-console=read\-only\fR
603 modes\&.
604 .sp
605 Added in version 256\&.
606 .RE
607 .SS "Credentials"
608 .PP
609 \fB\-\-load\-credential=\fR\fB\fIID\fR\fR\fB:\fR\fB\fIPATH\fR\fR, \fB\-\-set\-credential=\fR\fB\fIID\fR\fR\fB:\fR\fB\fIVALUE\fR\fR
610 .RS 4
611 Pass a credential to the virtual machine\&. These two options correspond to the
612 \fILoadCredential=\fR
613 and
614 \fISetCredential=\fR
615 settings in unit files\&. See
616 \fBsystemd.exec\fR(5)
617 for details about these concepts, as well as the syntax of the option\*(Aqs arguments\&.
618 .sp
619 In order to embed binary data into the credential data for
620 \fB\-\-set\-credential=\fR, use C\-style escaping (i\&.e\&.
621 "\en"
622 to embed a newline, or
623 "\ex00"
624 to embed a
625 \fBNUL\fR
626 byte)\&. Note that the invoking shell might already apply unescaping once, hence this might require double escaping!
627 .sp
628 Added in version 255\&.
629 .RE
630 .SS "Other"
631 .PP
632 \fB\-\-no\-pager\fR
633 .RS 4
634 Do not pipe output into a pager\&.
635 .RE
636 .PP
637 \fB\-h\fR, \fB\-\-help\fR
638 .RS 4
639 Print a short help text and exit\&.
640 .RE
641 .PP
642 \fB\-\-version\fR
643 .RS 4
644 Print a short version string and exit\&.
645 .RE
646 .PP
647 \fB\-\-no\-ask\-password\fR
648 .RS 4
649 Do not query the user for authentication for privileged operations\&.
650 .RE
651 .SH "ENVIRONMENT"
652 .PP
653 \fI$SYSTEMD_LOG_LEVEL\fR
654 .RS 4
655 The maximum log level of emitted messages (messages with a higher log level, i\&.e\&. less important ones, will be suppressed)\&. Takes a comma\-separated list of values\&. A value may be either one of (in order of decreasing importance)
656 \fBemerg\fR,
657 \fBalert\fR,
658 \fBcrit\fR,
659 \fBerr\fR,
660 \fBwarning\fR,
661 \fBnotice\fR,
662 \fBinfo\fR,
663 \fBdebug\fR, or an integer in the range 0\&...7\&. See
664 \fBsyslog\fR(3)
665 for more information\&. Each value may optionally be prefixed with one of
666 \fBconsole\fR,
667 \fBsyslog\fR,
668 \fBkmsg\fR
669 or
670 \fBjournal\fR
671 followed by a colon to set the maximum log level for that specific log target (e\&.g\&.
672 \fBSYSTEMD_LOG_LEVEL=debug,console:info\fR
673 specifies to log at debug level except when logging to the console which should be at info level)\&. Note that the global maximum log level takes priority over any per target maximum log levels\&.
674 .RE
675 .PP
676 \fI$SYSTEMD_LOG_COLOR\fR
677 .RS 4
678 A boolean\&. If true, messages written to the tty will be colored according to priority\&.
679 .sp
680 This setting is only useful when messages are written directly to the terminal, because
681 \fBjournalctl\fR(1)
682 and other tools that display logs will color messages based on the log level on their own\&.
683 .RE
684 .PP
685 \fI$SYSTEMD_LOG_TIME\fR
686 .RS 4
687 A boolean\&. If true, console log messages will be prefixed with a timestamp\&.
688 .sp
689 This setting is only useful when messages are written directly to the terminal or a file, because
690 \fBjournalctl\fR(1)
691 and other tools that display logs will attach timestamps based on the entry metadata on their own\&.
692 .RE
693 .PP
694 \fI$SYSTEMD_LOG_LOCATION\fR
695 .RS 4
696 A boolean\&. If true, messages will be prefixed with a filename and line number in the source code where the message originates\&.
697 .sp
698 Note that the log location is often attached as metadata to journal entries anyway\&. Including it directly in the message text can nevertheless be convenient when debugging programs\&.
699 .RE
700 .PP
701 \fI$SYSTEMD_LOG_TID\fR
702 .RS 4
703 A boolean\&. If true, messages will be prefixed with the current numerical thread ID (TID)\&.
704 .sp
705 Note that the this information is attached as metadata to journal entries anyway\&. Including it directly in the message text can nevertheless be convenient when debugging programs\&.
706 .RE
707 .PP
708 \fI$SYSTEMD_LOG_TARGET\fR
709 .RS 4
710 The destination for log messages\&. One of
711 \fBconsole\fR
712 (log to the attached tty),
713 \fBconsole\-prefixed\fR
714 (log to the attached tty but with prefixes encoding the log level and "facility", see
715 \fBsyslog\fR(3),
716 \fBkmsg\fR
717 (log to the kernel circular log buffer),
718 \fBjournal\fR
719 (log to the journal),
720 \fBjournal\-or\-kmsg\fR
721 (log to the journal if available, and to kmsg otherwise),
722 \fBauto\fR
723 (determine the appropriate log target automatically, the default),
724 \fBnull\fR
725 (disable log output)\&.
726 .RE
727 .PP
728 \fI$SYSTEMD_LOG_RATELIMIT_KMSG\fR
729 .RS 4
730 Whether to ratelimit kmsg or not\&. Takes a boolean\&. Defaults to
731 "true"\&. If disabled, systemd will not ratelimit messages written to kmsg\&.
732 .RE
733 .PP
734 \fI$SYSTEMD_PAGER\fR, \fI$PAGER\fR
735 .RS 4
736 Pager to use when
737 \fB\-\-no\-pager\fR
738 is not given\&.
739 \fI$SYSTEMD_PAGER\fR
740 is used if set; otherwise
741 \fI$PAGER\fR
742 is used\&. If neither
743 \fI$SYSTEMD_PAGER\fR
744 nor
745 \fI$PAGER\fR
746 are set, a set of well\-known pager implementations is tried in turn, including
747 \fBless\fR(1)
748 and
749 \fBmore\fR(1), until one is found\&. If no pager implementation is discovered, no pager is invoked\&. Setting those environment variables to an empty string or the value
750 "cat"
751 is equivalent to passing
752 \fB\-\-no\-pager\fR\&.
753 .sp
754 Note: if
755 \fI$SYSTEMD_PAGERSECURE\fR
756 is not set,
757 \fI$SYSTEMD_PAGER\fR
758 and
759 \fI$PAGER\fR
760 can only be used to disable the pager (with
761 "cat"
762 or
763 ""), and are otherwise ignored\&.
764 .RE
765 .PP
766 \fI$SYSTEMD_LESS\fR
767 .RS 4
768 Override the options passed to
769 \fBless\fR
770 (by default
771 "FRSXMK")\&.
772 .sp
773 Users might want to change two options in particular:
774 .PP
775 \fBK\fR
776 .RS 4
777 This option instructs the pager to exit immediately when
778 Ctrl+C
779 is pressed\&. To allow
780 \fBless\fR
781 to handle
782 Ctrl+C
783 itself to switch back to the pager command prompt, unset this option\&.
784 .sp
785 If the value of
786 \fI$SYSTEMD_LESS\fR
787 does not include
788 "K", and the pager that is invoked is
789 \fBless\fR,
790 Ctrl+C
791 will be ignored by the executable, and needs to be handled by the pager\&.
792 .RE
793 .PP
794 \fBX\fR
795 .RS 4
796 This option instructs the pager to not send termcap initialization and deinitialization strings to the terminal\&. It is set by default to allow command output to remain visible in the terminal even after the pager exits\&. Nevertheless, this prevents some pager functionality from working, in particular paged output cannot be scrolled with the mouse\&.
797 .RE
798 .sp
799 Note that setting the regular
800 \fI$LESS\fR
801 environment variable has no effect for
802 \fBless\fR
803 invocations by systemd tools\&.
804 .sp
805 See
806 \fBless\fR(1)
807 for more discussion\&.
808 .RE
809 .PP
810 \fI$SYSTEMD_LESSCHARSET\fR
811 .RS 4
812 Override the charset passed to
813 \fBless\fR
814 (by default
815 "utf\-8", if the invoking terminal is determined to be UTF\-8 compatible)\&.
816 .sp
817 Note that setting the regular
818 \fI$LESSCHARSET\fR
819 environment variable has no effect for
820 \fBless\fR
821 invocations by systemd tools\&.
822 .RE
823 .PP
824 \fI$SYSTEMD_PAGERSECURE\fR
825 .RS 4
826 Common pager commands like
827 \fBless\fR(1), in addition to "paging", i\&.e\&. scrolling through the output, support opening of or writing to other files and running arbitrary shell commands\&. When commands are invoked with elevated privileges, for example under
828 \fBsudo\fR(8)
829 or
830 \fBpkexec\fR(1), the pager becomes a security boundary\&. Care must be taken that only programs with strictly limited functionality are used as pagers, and unintended interactive features like opening or creation of new files or starting of subprocesses are not allowed\&. "Secure mode" for the pager may be enabled as described below,
831 \fIif the pager supports that\fR
832 (most pagers are not written in a way that takes this into consideration)\&. It is recommended to either explicitly enable "secure mode" or to completely disable the pager using
833 \fB\-\-no\-pager\fR
834 or
835 \fIPAGER=cat\fR
836 when allowing untrusted users to execute commands with elevated privileges\&.
837 .sp
838 This option takes a boolean argument\&. When set to true, the "secure mode" of the pager is enabled\&. In "secure mode",
839 \fBLESSSECURE=1\fR
840 will be set when invoking the pager, which instructs the pager to disable commands that open or create new files or start new subprocesses\&. Currently only
841 \fBless\fR(1)
842 is known to understand this variable and implement "secure mode"\&.
843 .sp
844 When set to false, no limitation is placed on the pager\&. Setting
845 \fISYSTEMD_PAGERSECURE=0\fR
846 or not removing it from the inherited environment may allow the user to invoke arbitrary commands\&.
847 .sp
848 When
849 \fI$SYSTEMD_PAGERSECURE\fR
850 is not set, systemd tools attempt to automatically figure out if "secure mode" should be enabled and whether the pager supports it\&. "Secure mode" is enabled if the effective UID is not the same as the owner of the login session, see
851 \fBgeteuid\fR(2)
852 and
853 \fBsd_pid_get_owner_uid\fR(3), or when running under
854 \fBsudo\fR(8)
855 or similar tools (\fI$SUDO_UID\fR
856 is set
857 \&\s-2\u[3]\d\s+2)\&. In those cases,
858 \fISYSTEMD_PAGERSECURE=1\fR
859 will be set and pagers which are not known to implement "secure mode" will not be used at all\&. Note that this autodetection only covers the most common mechanisms to elevate privileges and is intended as convenience\&. It is recommended to explicitly set
860 \fI$SYSTEMD_PAGERSECURE\fR
861 or disable the pager\&.
862 .sp
863 Note that if the
864 \fI$SYSTEMD_PAGER\fR
865 or
866 \fI$PAGER\fR
867 variables are to be honoured, other than to disable the pager,
868 \fI$SYSTEMD_PAGERSECURE\fR
869 must be set too\&.
870 .RE
871 .PP
872 \fI$SYSTEMD_COLORS\fR
873 .RS 4
874 Takes a boolean argument, or a special value\&. By default (unset),
875 \fBsystemd\fR
876 and related utilities will use colors in their output if possible\&. If
877 \fI$COLORTERM\fR
878 is set to
879 "truecolor"
880 or
881 "24bit", 24\-bit colors will be enabled, 256 colors otherwise, unless
882 \fI$NO_COLOR\fR
883 or
884 \fI$TERM\fR
885 indicates colors are disabled\&.
886 .PP
887 \fBtrue\fR
888 .RS 4
889 Same as unset, except that
890 \fI$NO_COLOR\fR
891 is ignored\&.
892 .RE
893 .PP
894 \fBfalse\fR
895 .RS 4
896 The output will be monochrome\&.
897 .RE
898 .PP
899 "16", "256", "24bit"
900 .RS 4
901 Always use the base 16 ANSI colors, 256 colors, or 24 bit color, respectively\&.
902 .RE
903 .PP
904 "auto\-16", "auto\-256", "auto\-24bit"
905 .RS 4
906 Use the given quantity of colours, subject to
907 \fI$TERM\fR, and what the console is connected to\&.
908 .RE
909 .RE
910 .PP
911 \fI$SYSTEMD_URLIFY\fR
912 .RS 4
913 The value must be a boolean\&. Controls whether clickable links should be generated in the output for terminal emulators supporting this\&. This can be specified to override the decision that
914 \fBsystemd\fR
915 makes based on
916 \fI$TERM\fR
917 and other conditions\&.
918 .RE
919 .SH "EXAMPLES"
920 .PP
921 \fBExample\ \&1.\ \&Run an Arch Linux VM image generated by mkosi\fR
922 .sp
923 .if n \{\
924 .RS 4
925 .\}
926 .nf
927 $ mkosi \-d arch \-p systemd \-p linux \-\-autologin \-o image\&.raw \-f build
928 $ systemd\-vmspawn \-\-image=image\&.raw
929 .fi
930 .if n \{\
931 .RE
932 .\}
933 .PP
934 \fBExample\ \&2.\ \&Import and run a Fedora 43 Cloud image using machinectl\fR
935 .sp
936 .if n \{\
937 .RS 4
938 .\}
939 .nf
940 $ curl \-L \e
941 \-O https://download\&.fedoraproject\&.org/pub/fedora/linux/releases/43/Cloud/x86_64/images/Fedora\-Cloud\-Base\-43\-1\&.6\&.x86_64\&.raw\&.xz \e
942 \-O https://download\&.fedoraproject\&.org/pub/fedora/linux/releases/43/Cloud/x86_64/images/Fedora\-Cloud\-43\-1\&.6\-x86_64\-CHECKSUM \e
943 \-O https://fedoraproject\&.org/fedora\&.gpg
944 $ gpgv \-\-keyring \&./fedora\&.gpg Fedora\-Cloud\-43\-1\&.6\-x86_64\-CHECKSUM
945 $ sha256sum \-c Fedora\-Cloud\-43\-1\&.6\-x86_64\-CHECKSUM
946 # machinectl import\-raw Fedora\-Cloud\-Base\-43\-1\&.6\&.x86_64\&.raw\&.xz fedora\-43\-cloud
947 # systemd\-vmspawn \-M fedora\-43\-cloud
948 .fi
949 .if n \{\
950 .RE
951 .\}
952 .PP
953 \fBExample\ \&3.\ \&Build and run systemd\*(Aqs system image and forward the VM\*(Aqs journal to a local file\fR
954 .sp
955 .if n \{\
956 .RS 4
957 .\}
958 .nf
959 $ mkosi build
960 $ systemd\-vmspawn \e
961 \-D mkosi\&.output/system \e
962 \-\-private\-users $(grep $(whoami) /etc/subuid | cut \-d: \-f2) \e
963 \-\-linux mkosi\&.output/system\&.efi \e
964 \-\-forward\-journal=vm\&.journal \e
965 enforcing=0
966 .fi
967 .if n \{\
968 .RE
969 .\}
970 .PP
971 Note: this example also uses a kernel command line argument to ensure SELinux is not started in enforcing mode\&.
972 .PP
973 \fBExample\ \&4.\ \&SSH into a running VM using systemd\-ssh\-proxy\fR
974 .sp
975 .if n \{\
976 .RS 4
977 .\}
978 .nf
979 $ mkosi build
980 $ my_vsock_cid=3735928559
981 $ systemd\-vmspawn \e
982 \-D mkosi\&.output/system \e
983 \-\-private\-users $(grep $(whoami) /etc/subuid | cut \-d: \-f2) \e
984 \-\-linux mkosi\&.output/system\&.efi \e
985 \-\-vsock\-cid $my_vsock_cid \e
986 enforcing=0
987 $ ssh root@vsock/$my_vsock_cid \-i /run/user/$UID/systemd/vmspawn/machine\-*\-system\-ed25519
988 .fi
989 .if n \{\
990 .RE
991 .\}
992 .SH "EXIT STATUS"
993 .PP
994 If an error occurred the value errno is propagated to the return code\&. If EXIT_STATUS is supplied by the running image that is returned\&. Otherwise, EXIT_SUCCESS is returned\&.
995 .SH "SEE ALSO"
996 .PP
997 \fBsystemd\fR(1), \fBmkosi\fR(1), \fBmachinectl\fR(1), \fBimportctl\fR(1), \m[blue]\fBUAPI\&.1 Boot Loader Specification\fR\m[]\&\s-2\u[1]\d\s+2
998 .SH "NOTES"
999 .IP " 1." 4
1000 UAPI.1 Boot Loader Specification
1001 .RS 4
1002 \%https://uapi-group.org/specifications/specs/boot_loader_specification
1003 .RE
1004 .IP " 2." 4
1005 ANSI Escape Code (Wikipedia)
1006 .RS 4
1007 \%https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
1008 .RE
1009 .IP " 3." 4
1010 It is recommended for other tools to set and check
1011 \fI$SUDO_UID\fR
1012 as appropriate, treating it is a common interface.
1013