systemd-firstboot, systemd-firstboot.service — Initialize basic system settings on or before the first boot-up of a system
systemd-firstboot initializes the most
basic system settings interactively on the first boot, or
optionally non-interactively when a system image is created.
The service is started if
is satisfied. This essentially means that
is empty, see
The following settings may be set up:
The system locale, more specifically the two
The system keyboard map
The system time zone
The system hostname
The machine ID of the system
The root user's password
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 while it is up.
The following options are understood:
Takes a directory path as an argument. All
paths will be prefixed with the given alternate
root path, including config search
paths. This is useful to operate on a system image mounted to
the specified directory instead of the host system itself.
Takes 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
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
Specification. For further information on supported disk images, see
switch of the same name.
Sets the system locale, more specifically the
settings. The argument should be a valid locale identifier,
such as "
de_DE.UTF-8". This controls the
Sets the system keyboard layout. The argument should be a valid keyboard map,
such as "
de-latin1". This controls the "
KEYMAP" entry in the
Sets the system time zone. The argument should
be a valid time zone identifier, such as
Europe/Berlin". This controls the
Sets the system hostname. The argument should be a hostname, compatible with DNS. This controls the hostname(5) configuration file.
Sets the system's machine ID. This controls the machine-id(5) file.
Sets the password of the system's root user. This creates/modifies the
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
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
Sets the shell of the system's root user. This creates/modifies the passwd(5) file.
Sets the system's kernel command line. This controls the
/etc/kernel/cmdline file which is used by
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.
Query the user for locale, keymap, timezone, hostname
and root password. This is equivalent to specifying
--prompt-root-shell in combination.
Copy a specific basic setting from the host.
This only works in combination with
Copy locale, keymap, time zone and root password from
the host. This is equivalent to specifying
--copy-root-shell in combination.
Initialize the system's machine ID to a random
ID. This only works in combination with
systemd-firstboot doesn't modify existing files unless
is specified. For modifications to
/etc/shadow, systemd-firstboot only modifies the entry of the
root" user instead of overwriting the entire file.
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.
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.
On success, 0 is returned, a non-zero failure code otherwise.
Takes a boolean argument, defaults to on. If off,
won't interactively query the user for basic settings at first boot, even if those settings are not