systemd-vmspawnsystemdsystemd-vmspawn1systemd-vmspawnSpawn an OS in a virtual machine.systemd-vmspawnOPTIONSARGSDescriptionsystemd-vmspawn may be used to start a virtual machine from an OS image. In many ways it is similar to systemd-nspawn1, but it
launches a full virtual machine instead of using namespaces.File descriptors for /dev/kvm and /dev/vhost-vsock can be
passed to systemd-vmspawn via systemd's native socket passing interface (see
sd_listen_fds3 for
details about the precise protocol used and the order in which the file descriptors are passed), these
fds must be passed with the names kvm and vhost-vsock respectively.Note: on Ubuntu/Debian derivatives systemd-vmspawn requires the user to be in the kvm group to use the VSock options.OptionsThe excess arguments are passed as extra kernel command line arguments using SMBIOS.The following options are understood: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.Image OptionsDirectory to use as file system root for the virtual machine.One of either or must be specified.Note: If mounting a non-root owned directory you may require
to map into the user's subuid namespace.Root file system disk image (or device node) for the virtual machine.Host ConfigurationSMPConfigures the number of CPUs to start the virtual machine with.
Defaults to 1.MEMConfigures the amount of memory to start the virtual machine with.
Defaults to 2G.BOOLConfigures whether to use KVM. If the option is not specified KVM support will be
detected automatically. If true, KVM is always used, and if false, KVM is never used.BOOLConfigure whether to use VSock networking.If the option is not specified VSock support will be detected automatically.
If yes is specified VSocks are always used, and vice versa if no is set VSocks are never used.CIDConfigure vmspawn to use a specific CID for the guest.If the option is not specified or an empty argument is supplied the guest will be assigned a random CID.Valid CIDs are in the range 3 to 4294967294 (0xFFFF_FFFE).
CIDs outside of this range are reserved.BOOLConfigure whether to use qemu with a virtual TPM or not.If the option is not specified vmspawn will detect the presence of swtpm8 and use it if available.
If yes is specified swtpm8
is always used, and vice versa if no is set swtpm8 is never used.Note: the virtual TPM used may change in future.PATHSet the linux kernel image to use for direct kernel boot.If no kernel was installed into the image then the image will fail to boot.PATHSet the initrd to use for direct kernel boot.If the linux kernel supplied is a UKI then this argument is not required.If no initrd was installed into the image then the image will fail to boot.Start QEMU in graphical mode.Create a TAP device to network with the virtual machine.
Note: root privileges are required to use TAP networking.
Additionally requires a correctly setup
systemd-networkd8
to be running on the host to ensure the host interface is correctly configured.
The relevant .network file can be found at /usr/lib/systemd/network/80-vm-vt.network.
Use user mode networking with QEMU.PATHTakes an absolute path, or a relative path beginning with
./. 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 list is specified lists all discovered firmwares.BOOLConfigure whether to search for firmware which supports Secure Boot.If the option is not specified the first firmware which is 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.System Identity OptionsSets 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
machinectl1
and similar).User Namespacing OptionsUID_SHIFT[:UID_RANGE]Controls user namespacing under .
If enabled, virtiofsd1
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's 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's UID/GID 65536).If one or two colon-separated numbers are specified, user namespacing is turned on. UID_SHIFT
specifies the first host UID/GID to map, UID_RANGE is optional and specifies number of host
UIDs/GIDs to assign to the virtual machine. If UID_RANGE is omitted, 65536 UIDs/GIDs are assigned.When user namespaces are used, the GID range assigned to each virtual machine is always chosen identical to the
UID range.Mount OptionsPATHPATHMount a directory from the host into the virtual machine. Takes one of: a path
argument — 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 — 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 option creates read-only bind mounts.
Backslash escapes are interpreted, so \: may be used to embed colons in either path.
This option may be specified multiple times for creating multiple independent bind mount points.CredentialsID:PATHID:VALUEPass a credential to the virtual machine. These two options correspond to the
LoadCredential= and SetCredential= settings in unit files. See
systemd.exec5 for
details about these concepts, as well as the syntax of the option's arguments.In order to embed binary data into the credential data for ,
use C-style escaping (i.e. \n to embed a newline, or \x00 to
embed a NUL byte). Note that the invoking shell might already apply unescaping
once, hence this might require double escaping!.OtherExamplesRun an Arch Linux VM image generated by mkosi
$ mkosi -d arch -p systemd -p linux --autologin -o image.raw -f build
$ systemd-vmspawn --image=image.raw
Exit statusIf 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.See Alsosystemd1mkosi1