Name
systemd-firstboot, systemd-firstboot.service — Initialize basic system settings on or before the first boot-up of a system
Synopsis
systemd-firstboot [OPTIONS...]
systemd-firstboot.service
Description¶
The systemd-firstboot.service unit is one of the units which are used to
initialize the machine configuration during "First Boot", i.e. when the system is freshly installed or
after a factory reset. The
systemd(1) manager
itself will initialize
machine-id(5) and preset
all units, enabling or disabling them according to the
systemd.preset(5)
settings. systemd-firstboot.service is started later to interactively initialize
basic system configuration. It is started only if ConditionFirstBoot=yes is met, which
essentially means that /etc/ is unpopulated, see
systemd.unit(5) for
details. System credentials may be used to inject configuration; those settings are not queried
interactively.
The systemd-firstboot command can also be used to non-interactively initialize an offline system image.
The following settings may be configured:
The machine ID of the system
The system locale, more specifically the two locale variables
LANG=andLC_MESSAGESThe system keyboard map
The system time zone
The system hostname
The machine tags
The kernel command line used when installing kernel images
The root user's password and shell
Each of the fields may either be queried interactively by users, set non-interactively on the tool's command line, or be copied from a host system that is used to set up the system image.
If a setting is already initialized, it will not be overwritten and the user will not be prompted for the setting.
Note that this tool operates directly on the file system and does not involve any running system services, unlike localectl(1), timedatectl(1) or hostnamectl(1). This allows systemd-firstboot to operate on mounted but not booted disk images and in early boot. It is not recommended to use systemd-firstboot on the running system after it has been set up.
Options¶
The following options are understood:
--root=¶rootTakes a directory path as an argument. All paths will be prefixed with the given alternate
rootpath, including config search paths. This is useful to operate on a system image mounted to the specified directory instead of the host system itself.--image=¶pathTakes a path to a disk image file or block device node. If specified all operations are applied to file system in the indicated disk image. This is similar to
--root=but operates on file systems stored in disk images or block devices. The disk image should either contain just a file system or a set of file systems within a GPT partition table, following the UAPI.2 Discoverable Partitions Specification. For further information on supported disk images, see systemd-nspawn(1)'s switch of the same name.--locale=,LOCALE--locale-messages=¶LOCALESets the system locale, more specifically the
LANG=andLC_MESSAGESsettings. The argument should be a valid locale identifier, such as "de_DE.UTF-8". This controls the locale.conf(5) configuration file.--keymap=¶KEYMAPSets the system keyboard layout. The argument should be a valid keyboard map, such as "
de-latin1". This controls the "KEYMAP" entry in the vconsole.conf(5) configuration file.--timezone=¶TIMEZONESets the system time zone. The argument should be a valid time zone identifier, such as "
Europe/Berlin". This controls the localtime(5) symlink.--hostname=¶HOSTNAMESets the system hostname. The argument should be a hostname, compatible with DNS. This controls the hostname(5) configuration file.
--setup-machine-id¶Initialize the system's machine ID to a random ID. This controls the machine-id(5) file.
This option only works in combination with
--root=or--image=. On a running system,machine-idis written by the manager with help from systemd-machine-id-commit.service(8).--machine-id=¶IDSet the system's machine ID to the specified value. The same restrictions apply as to
--setup-machine-id.Set the machine tags to the specified colon-separated list. Machine tags are short labels that may be used to classify and group machines for management purposes, for example to identify the role a machine plays in a deployment, the fleet or organizational unit it belongs to, or any other administrator-defined attribute. Each individual tag must be 1…255 characters long and consist only of ASCII alphanumeric characters, "
-" and ".". This controls theTAGS=field of machine-info(5). The tags may later be queried and changed with the tags command of hostnamectl(1), and matched against with theConditionMachineTag=/AssertMachineTag=unit settings, see systemd.unit(5).Unlike most other settings, machine tags are not prompted for interactively.
--root-password=,PASSWORD--root-password-file=,PATH--root-password-hashed=¶HASHED_PASSWORDSets the password of the system's root user. This creates/modifies the passwd(5) and shadow(5) files. This setting exists in three forms:
--root-password=accepts the password to set directly on the command line,--root-password-file=reads it from a file and--root-password-hashed=accepts an already hashed password on the command line. See shadow(5) for more information on the format of the hashed password. Note that it is not recommended to specify plaintext passwords on the command line, as other users might be able to see them simply by invoking ps(1).--root-shell=¶SHELLSets the shell of the system's root user. This creates/modifies the passwd(5) file.
--kernel-command-line=¶CMDLINESets the system's kernel command line. This controls the
/etc/kernel/cmdlinefile which is used by kernel-install(8).--prompt-locale,--prompt-keymap,--prompt-timezone,--prompt-hostname,--prompt-root-password,--prompt-root-shell¶Prompt the user interactively for a specific basic setting. Note that any explicit configuration settings specified on the command line take precedence, and the user is not prompted for it.
--prompt¶Query the user for locale, keymap, timezone, hostname, root's password, and root's shell. This is equivalent to specifying
--prompt-locale,--prompt-keymap,--prompt-timezone,--prompt-hostname,--prompt-root-password,--prompt-root-shellin combination.--prompt-keymap-auto¶If invoked from a virtual terminal TTY equivalent to
--prompt-keymap, otherwise has no effect. Or in other words, only prompts interactively for a keymap if a local keyboard is used for interactivity that requires it.--copy-locale,--copy-keymap,--copy-timezone,--copy-root-password,--copy-root-shell¶Copy a specific basic setting from the host. This only works in combination with
--root=or--image=.--copy¶Copy locale, keymap, time zone, root password and shell from the host. This is equivalent to specifying
--copy-locale,--copy-keymap,--copy-timezone,--copy-root-password,--copy-root-shellin combination.--force¶Write configuration even if the relevant files already exist. Without this option, systemd-firstboot does not modify or replace existing files. Note that when configuring the root account, even with this option, systemd-firstboot only modifies the entry of the "
root" user, leaving other entries in/etc/passwdand/etc/shadowintact.--reset¶If specified, all existing files that are configured by systemd-firstboot are removed. Note that the files are removed regardless of whether they'll be configured with a new value or not. This operation ensures that the next boot of the image will be considered a first boot, and systemd-firstboot will prompt again to configure each of the removed files.
--delete-root-password¶Removes the password of the system's root user, enabling login as root without a password unless the root account is locked. Note that this is extremely insecure and hence this option should not be used lightly.
--welcome=¶Takes a boolean argument. By default, when prompting the user for configuration options a brief welcome text is shown before the first question is asked. Pass false to this option to turn off the welcome text.
--chrome=¶Takes a boolean argument. By default the initial setup screen will show reverse color "chrome" bars at the top and the bottom of the terminal screen, which may be disabled by setting this option to false.
--mute-console=¶Takes a boolean argument. If true kernel log output and service manager status output to the system console is temporarily disabled while systemd-firstboot is running, so that its own output is not interrupted. Defaults to false.
-h,--help¶--version¶Print a short version string and exit.
Credentials¶
systemd-firstboot supports the service credentials logic as implemented by
ImportCredential=/LoadCredential=/SetCredential=
(see systemd.exec(5) for
details). The following credentials are used when passed in:
passwd.hashed-password.root,passwd.plaintext-password.root¶A hashed or plaintext version of the root password to use, in place of prompting the user. These credentials are equivalent to the same ones defined for the systemd-sysusers.service(8) service.
passwd.shell.root¶Specifies the shell binary to use for the specified account. Equivalent to the credential of the same name defined for the systemd-sysusers.service(8) service.
firstboot.locale,firstboot.locale-messages¶These credentials specify the locale settings to set during first boot, in place of prompting the user.
firstboot.keymap¶This credential specifies the keyboard setting to set during first boot, in place of prompting the user.
Note the relationship to the
vconsole.keymapcredential understood by systemd-vconsole-setup.service(8): both ultimately affect the same setting, butfirstboot.keymapis written into/etc/vconsole.confon first boot (if not already configured), and then read from there by systemd-vconsole-setup, whilevconsole.keymapis read on every boot, and is not persisted to disk (but any configuration invconsole.confwill take precedence if present).firstboot.timezone¶This credential specifies the system timezone setting to set during first boot, in place of prompting the user.
firstboot.hostname¶This credential specifies the static system hostname to set during first boot. The user will not be prompted for the hostname. Note that this controls the static hostname, not the transient hostname, and only has an effect on first boot, unlike
system.hostname.This credential specifies the machine tags to set during first boot, as a colon-separated list, equivalent to the
--machine-tags=switch described above. The tags are written into theTAGS=field of/etc/machine-info(if that file is not already present), and only have an effect on first boot. If the list contains invalid tags it is ignored in its entirety.
Note that by default the systemd-firstboot.service unit file is set up to
inherit the listed credentials
from the service manager. Thus, when invoking a container with an unpopulated /etc/
for the first time it is possible to configure the root user's password to be "systemd"
like this:
# systemd-nspawn --image=… --set-credential=firstboot.locale:de_DE.UTF-8 …
Note that these credentials are only read and applied during the first boot. Once they are applied they remain applied for subsequent boots, and the credentials are not considered anymore.
Kernel Command Line¶
systemd.firstboot=¶Takes a boolean argument or the special value "
headless", defaults to on. If off,systemd-firstboot.servicewill not interactively query the user for basic settings at first boot, even if those settings are not initialized yet. If set to "headless", interactive prompts are suppressed just like with "no", but non-interactive auto-configuration that requires no user input is still performed (for example, selecting the sole installed locale, or applying settings passed in via credentials).