SYSTEMD-FIRSTBOOT(1)
๐ systemd-firstboot(1) โ the systemd-firstboot glow-up ๐
okay so this is the manual for systemd-firstboot and systemd-firstboot.service, and ngl it's the "welcome to your brand new machine" era of the boot process ๐
โจ 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 ๐
So bestie, the systemd-firstboot.service unit is one of the units that handle initializing your machine's configuration during "First Boot" โ aka when the system is freshly installed, or after a factory reset. ๐
The systemd(1) manager itself is the one that initializes machine-id(5) and presets all units, enabling or disabling them according to the systemd.preset(5) settings. Then systemd-firstboot.service gets started later to interactively initialize the basic system configuration. It only starts if ConditionFirstBoot=yes is met, which basically means /etc/ is unpopulated โ see systemd.unit(5) for the deets. 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. no cap.
Here's everything that may be configured โจ:
- The machine ID of the system
- The system locale โ more specifically the two locale variables
LANG=andLC_MESSAGES - The 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. three ways, pick your fighter ๐ซถ
If a setting is already initialized, it will not be overwritten and the user will not be prompted for the setting. it's giving "respect the existing config".
โ ๏ธ Heads up: this tool operates directly on the file system and does not involve any running system services โ unlikelocalectl(1),timedatectl(1)orhostnamectl(1). That's the whole reasonsystemd-firstbootcan operate on mounted but not booted disk images and in early boot. It is not recommended to usesystemd-firstbooton the running system after it has been set up. ๐
๐ OPTIONS ๐
The following options are understood:
--root=root โ 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.
Added in version 216.
--image=path โ 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--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[1]. For further information on supported disk images, seesystemd-nspawn(1)'s switch of the same name.
Added in version 246.
--locale=LOCALE,--locale-messages=LOCALE โ Sets the system locale, more specifically theLANG=andLC_MESSAGESsettings. The argument should be a valid locale identifier, such as"de_DE.UTF-8". This controls thelocale.conf(5)configuration file.
Added in version 216.
--keymap=KEYMAP โ Sets the system keyboard layout. The argument should be a valid keyboard map, such as"de-latin1". This controls the"KEYMAP"entry in thevconsole.conf(5)configuration file.
Added in version 236.
--timezone=TIMEZONE โ Sets the system time zone. The argument should be a valid time zone identifier, such as"Europe/Berlin". This controls thelocaltime(5)symlink.
Added in version 216.
--hostname=HOSTNAME โ Sets the system hostname. The argument should be a hostname, compatible with DNS. This controls thehostname(5)configuration file.
Added in version 216.
--setup-machine-idโ Initialize the system's machine ID to a random ID. This controls themachine-id(5)file.
This option only works in combination with --root= or --image=. On a running system, machine-id is written by the manager with help from systemd-machine-id-commit.service(8).
Added in version 216.
--machine-id=ID โ Set the system's machine ID to the specified value. The same restrictions apply as to--setup-machine-id.
Added in version 216.
--machine-tags=TAG[:TAG...] โ 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 ofmachine-info(5). The tags may later be queried and changed with thetagscommand ofhostnamectl(1), and matched against with theConditionMachineTag=/AssertMachineTag=unit settings, seesystemd.unit(5).
Unlike most other settings, machine tags are not prompted for interactively. ๐
Added in version 261.
--root-password=PASSWORD,--root-password-file=PATH,--root-password-hashed=HASHED_PASSWORD โ Sets the password of the system's root user. This creates/modifies thepasswd(5)andshadow(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. Seeshadow(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). ๐
Added in version 216.
--root-shell=SHELL โ Sets the shell of the system's root user. This creates/modifies thepasswd(5)file.
Added in version 246.
--kernel-command-line=CMDLINE โ Sets the system's kernel command line. This controls the/etc/kernel/cmdlinefile which is used bykernel-install(8).
Added in version 246.
--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.
Added in version 216.
--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. the combo meal ๐
Added in version 216.
--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.
Added in version 259.
--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=.
Added in version 216.
--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.
Added in version 216.
--forceโ Write configuration even if the relevant files already exist. Without this option,systemd-firstbootdoes not modify or replace existing files. Note that when configuring the root account, even with this option,systemd-firstbootonly modifies the entry of the"root"user, leaving other entries in/etc/passwdand/etc/shadowintact. ๐ซก
Added in version 246.
--resetโ If specified, all existing files that are configured bysystemd-firstbootare 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, andsystemd-firstbootwill prompt again to configure each of the removed files. it's giving "factory reset energy" ๐ฅ
Added in version 254.
--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. bestie please.
Added in version 246.
--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. Passfalseto this option to turn off the welcome text.
Added in version 246.
--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 tofalse. aesthetic choice honestly โจ
Added in version 259.
--mute-console=โ Takes a boolean argument. Iftruekernel log output and service manager status output to the system console is temporarily disabled whilesystemd-firstbootis running, so that its own output is not interrupted. Defaults tofalse.
Added in version 259.
-h,--helpโ Print a short help text and exit.--versionโ Print a short version string and exit.
okay bestie that's OPTIONS wrapped ๐ the rest of this page is coming in part 2, so don't go anywhere ๐
๐ CREDENTIALS ๐
okay bestie so systemd-firstboot is fully plugged into the service credentials system, the one that runs on ImportCredential=, LoadCredential= and SetCredential= (peep systemd.exec(5) for the whole lore). And these are the credentials it actually picks up when you hand them over:
passwd.hashed-password.root, passwd.plaintext-password.root
a hashed OR plaintext version of the root password to use, so nobody has to sit there and get prompted like it's 2009. these two are literally the same credentials defined for the systemd-sysusers.service(8) service. twin behavior, no notes. ๐
added in version 249.
passwd.shell.root
tells it which shell binary to use for the account in question. equivalent to the credential with the same name defined for systemd-sysusers.service(8).
added in version 249.
firstboot.locale, firstboot.locale-messages
these ones specify the locale settings to apply during first boot, instead of making the user type them in. ๐ฆ
added in version 249.
firstboot.keymap
this credential specifies the keyboard setting to set during first boot, in place of prompting the user.
โ ๏ธ bestie, pay attention to the relationship here with thevconsole.keymapcredential thatsystemd-vconsole-setup.service(8)understands: they both end up affecting the same setting, butfirstboot.keymapgets written into/etc/vconsole.confon first boot (if it isn't already configured), and then it's read from there bysystemd-vconsole-setup. meanwhilevconsole.keymapis read on every boot and is not persisted to disk โ though any config already sitting invconsole.conftakes precedence if it's there. iykyk. โจ
added in version 249.
firstboot.timezone
this credential specifies the system timezone setting to set during first boot, instead of prompting the user.
added in version 249.
firstboot.hostname
this credential specifies the static system hostname to set during first boot. the user will not be prompted for the hostname at all. heads up though: this controls the static hostname, not the transient hostname, and it only has an effect on first boot โ unlike system.hostname. ๐
added in version 261.
firstboot.machine-tags
this credential specifies the machine tags to set during first boot, given as a colon-separated list, equivalent to the --machine-tags= switch described above. the tags get written into the TAGS= field of /etc/machine-info (if that file isn't already present), and they only have an effect on first boot. and if the list contains invalid tags, the whole thing is ignored in its entirety. ๐
added in version 261.
fr fr, by default the systemd-firstboot.service unit file is set up to inherit those listed credentials straight from the service manager. so when you invoke a container with an unpopulated /etc/ for the first time, you can configure the root user's password to be "systemd" like this:
# systemd-nspawn --image=... --set-credential=firstboot.locale:de_DE.UTF-8 ...
also! these credentials are only read and applied during that first boot. once they're applied, they stay applied for all the boots after that, and the credentials just aren't considered anymore. one and done, periodt. ๐
๐ EXIT STATUS ๐
if it worked: 0. if it didn't: a non-zero failure code. that's the whole vibe check.
โจ๏ธ KERNEL COMMAND LINE โจ๏ธ
systemd.firstboot=
takes a boolean argument, or the special value "headless", and defaults to on. if it's off, then systemd-firstboot.service will not interactively query the user for basic settings at first boot โ even if those settings haven't been initialized yet. if it's set to "headless", interactive prompts get suppressed exactly like with "no", but the non-interactive auto-configuration that needs zero user input still happens (for example, picking the sole installed locale, or applying settings that came in via credentials). ๐ซถ
added in version 233.
๐ SEE ALSO ๐
systemd(1)locale.conf(5)vconsole.conf(5)localtime(5)hostname(5)machine-id(5)shadow(5)systemd-machine-id-setup(1)localectl(1)timedatectl(1)hostnamectl(1)
๐ NOTES ๐
- UAPI.2 Discoverable Partitions Specification โ
https://uapi-group.org/specifications/specs/discoverable_partitions_specification
and that's the whole page bestie, we ate and left no crumbs ๐
๐ธ this one's from systemd 262.1, manual page SYSTEMD-FIRSTBOOT(1) โ go forth and firstboot responsibly, mwah ๐โจ
๐ฆ where this page comes from
- arch rolling: systemd 262.1-1 ยท LGPL-2.1-or-later AND CC0-1.0 AND GPL-2.0-or-later AND MIT-0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms