1 <?xml version='
1.0'
?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id=
"systemd-firstboot" conditional='ENABLE_FIRSTBOOT'
7 xmlns:
xi=
"http://www.w3.org/2001/XInclude">
10 <title>systemd-firstboot
</title>
11 <productname>systemd
</productname>
15 <refentrytitle>systemd-firstboot
</refentrytitle>
16 <manvolnum>1</manvolnum>
20 <refname>systemd-firstboot
</refname>
21 <refname>systemd-firstboot.service
</refname>
22 <refpurpose>Initialize basic system settings on or before the first boot-up of a system
</refpurpose>
27 <command>systemd-firstboot
</command>
28 <arg choice=
"opt" rep=
"repeat">OPTIONS
</arg>
31 <para><filename>systemd-firstboot.service
</filename></para>
35 <title>Description
</title>
37 <para>The
<command>systemd-firstboot.service
</command> unit is one of the units which are used to
38 initialize the machine configuration during
"First Boot", i.e. when the system is freshly installed or
39 after a factory reset. The
40 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry> manager
41 itself will initialize
42 <citerefentry><refentrytitle>machine-id
</refentrytitle><manvolnum>5</manvolnum></citerefentry> and preset
43 all units, enabling or disabling them according to the
44 <citerefentry><refentrytitle>systemd.preset
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
45 settings.
<filename>systemd-firstboot.service
</filename> is started later to interactively initialize
46 basic system configuration. It is started only if
<varname>ConditionFirstBoot=yes
</varname> is met, which
47 essentially means that
<filename>/etc/
</filename> is unpopulated, see
48 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
49 details. System credentials may be used to inject configuration; those settings are not queried
52 <para>The
<command>systemd-firstboot
</command> command can also be used to non-interactively initialize
53 an offline system image.
</para>
55 <para>The following settings may be configured:
</para>
58 <listitem><para>The machine ID of the system
</para></listitem>
60 <listitem><para>The system locale, more specifically the two
61 locale variables
<varname>LANG=
</varname> and
62 <varname>LC_MESSAGES
</varname></para></listitem>
64 <listitem><para>The system keyboard map
</para></listitem>
66 <listitem><para>The system time zone
</para></listitem>
68 <listitem><para>The system hostname
</para></listitem>
70 <listitem><para>The kernel command line used when installing kernel images
</para></listitem>
72 <listitem><para>The root user's password and shell
</para></listitem>
75 <para>Each of the fields may either be queried interactively by
76 users, set non-interactively on the tool's command line, or be
77 copied from a host system that is used to set up the system
80 <para>If a setting is already initialized, it will not be
81 overwritten and the user will not be prompted for the
84 <para>Note that this tool operates directly on the file system and
85 does not involve any running system services, unlike
86 <citerefentry project='man-pages'
><refentrytitle>localectl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
87 <citerefentry><refentrytitle>timedatectl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>
89 <citerefentry><refentrytitle>hostnamectl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
90 This allows
<command>systemd-firstboot
</command> to operate on
91 mounted but not booted disk images and in early boot. It is not
92 recommended to use
<command>systemd-firstboot
</command> on the
93 running system after it has been set up.
</para>
97 <title>Options
</title>
99 <para>The following options are understood:
</para>
103 <term><option>--root=
<replaceable>root
</replaceable></option></term>
104 <listitem><para>Takes a directory path as an argument. All
105 paths will be prefixed with the given alternate
106 <replaceable>root
</replaceable> path, including config search
107 paths. This is useful to operate on a system image mounted to
108 the specified directory instead of the host system itself.
111 <xi:include href=
"version-info.xml" xpointer=
"v216"/></listitem>
115 <term><option>--image=
<replaceable>path
</replaceable></option></term>
116 <listitem><para>Takes a path to a disk image file or block device node. If specified all operations
117 are applied to file system in the indicated disk image. This is similar to
<option>--root=
</option>
118 but operates on file systems stored in disk images or block devices. The disk image should either
119 contain just a file system or a set of file systems within a GPT partition table, following the
120 <ulink url=
"https://uapi-group.org/specifications/specs/discoverable_partitions_specification">Discoverable Partitions
121 Specification
</ulink>. For further information on supported disk images, see
122 <citerefentry><refentrytitle>systemd-nspawn
</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
123 switch of the same name.
</para>
125 <xi:include href=
"version-info.xml" xpointer=
"v246"/></listitem>
129 <term><option>--locale=
<replaceable>LOCALE
</replaceable></option></term>
130 <term><option>--locale-messages=
<replaceable>LOCALE
</replaceable></option></term>
132 <listitem><para>Sets the system locale, more specifically the
133 <varname>LANG=
</varname> and
<varname>LC_MESSAGES
</varname>
134 settings. The argument should be a valid locale identifier,
135 such as
<literal>de_DE.UTF-
8</literal>. This controls the
136 <citerefentry project='man-pages'
><refentrytitle>locale.conf
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
137 configuration file.
</para>
139 <xi:include href=
"version-info.xml" xpointer=
"v216"/></listitem>
143 <term><option>--keymap=
<replaceable>KEYMAP
</replaceable></option></term>
145 <listitem><para>Sets the system keyboard layout. The argument should be a valid keyboard map,
146 such as
<literal>de-latin1
</literal>. This controls the
<literal>KEYMAP
</literal> entry in the
147 <citerefentry project='man-pages'
><refentrytitle>vconsole.conf
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
148 configuration file.
</para>
150 <xi:include href=
"version-info.xml" xpointer=
"v236"/></listitem>
154 <term><option>--timezone=
<replaceable>TIMEZONE
</replaceable></option></term>
156 <listitem><para>Sets the system time zone. The argument should
157 be a valid time zone identifier, such as
158 <literal>Europe/Berlin
</literal>. This controls the
159 <citerefentry><refentrytitle>localtime
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
162 <xi:include href=
"version-info.xml" xpointer=
"v216"/></listitem>
166 <term><option>--hostname=
<replaceable>HOSTNAME
</replaceable></option></term>
168 <listitem><para>Sets the system hostname. The argument should
169 be a hostname, compatible with DNS. This controls the
170 <citerefentry><refentrytitle>hostname
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
171 configuration file.
</para>
173 <xi:include href=
"version-info.xml" xpointer=
"v216"/></listitem>
177 <term><option>--setup-machine-id
</option></term>
179 <listitem><para>Initialize the system's machine ID to a random ID. This controls the
180 <citerefentry><refentrytitle>machine-id
</refentrytitle><manvolnum>5</manvolnum></citerefentry> file.
183 <para>This option only works in combination with
<option>--root=
</option> or
184 <option>--image=
</option>. On a running system,
<filename>machine-id
</filename> is written by the
185 manager with help from
186 <citerefentry><refentrytitle>systemd-machine-id-commit.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
189 <xi:include href=
"version-info.xml" xpointer=
"v216"/></listitem>
193 <term><option>--machine-id=
<replaceable>ID
</replaceable></option></term>
195 <listitem><para>Set the system's machine ID to the specified value. The same restrictions apply
196 as to
<option>--setup-machine-id
</option>.
</para>
198 <xi:include href=
"version-info.xml" xpointer=
"v216"/></listitem>
202 <term><option>--root-password=
<replaceable>PASSWORD
</replaceable></option></term>
203 <term><option>--root-password-file=
<replaceable>PATH
</replaceable></option></term>
204 <term><option>--root-password-hashed=
<replaceable>HASHED_PASSWORD
</replaceable></option></term>
206 <listitem><para>Sets the password of the system's root user. This creates/modifies the
207 <citerefentry project='die-net'
><refentrytitle>passwd
</refentrytitle><manvolnum>5</manvolnum></citerefentry> and
208 <citerefentry project='die-net'
><refentrytitle>shadow
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
209 files. This setting exists in three forms:
<option>--root-password=
</option> accepts the password to
210 set directly on the command line,
<option>--root-password-file=
</option> reads it from a file and
211 <option>--root-password-hashed=
</option> accepts an already hashed password on the command line. See
212 <citerefentry project='die-net'
><refentrytitle>shadow
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
213 for more information on the format of the hashed password. Note that it is not recommended to specify
214 plaintext passwords on the command line, as other users might be able to see them simply by invoking
215 <citerefentry project='die-net'
><refentrytitle>ps
</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
218 <xi:include href=
"version-info.xml" xpointer=
"v216"/></listitem>
222 <term><option>--root-shell=
<replaceable>SHELL
</replaceable></option></term>
224 <listitem><para>Sets the shell of the system's root user. This creates/modifies the
225 <citerefentry project='die-net'
><refentrytitle>passwd
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
228 <xi:include href=
"version-info.xml" xpointer=
"v246"/></listitem>
232 <term><option>--kernel-command-line=
<replaceable>CMDLINE
</replaceable></option></term>
234 <listitem><para>Sets the system's kernel command line. This controls the
235 <filename>/etc/kernel/cmdline
</filename> file which is used by
236 <citerefentry><refentrytitle>kernel-install
</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
239 <xi:include href=
"version-info.xml" xpointer=
"v246"/></listitem>
243 <term><option>--prompt-locale
</option></term>
244 <term><option>--prompt-keymap
</option></term>
245 <term><option>--prompt-timezone
</option></term>
246 <term><option>--prompt-hostname
</option></term>
247 <term><option>--prompt-root-password
</option></term>
248 <term><option>--prompt-root-shell
</option></term>
250 <listitem><para>Prompt the user interactively for a specific
251 basic setting. Note that any explicit configuration settings
252 specified on the command line take precedence, and the user is
253 not prompted for it.
</para>
255 <xi:include href=
"version-info.xml" xpointer=
"v216"/></listitem>
259 <term><option>--prompt
</option></term>
261 <listitem><para>Query the user for locale, keymap, timezone, hostname,
262 root's password, and root's shell. This is equivalent to specifying
263 <option>--prompt-locale
</option>,
264 <option>--prompt-keymap
</option>,
265 <option>--prompt-timezone
</option>,
266 <option>--prompt-hostname
</option>,
267 <option>--prompt-root-password
</option>,
268 <option>--prompt-root-shell
</option> in combination.
</para>
270 <xi:include href=
"version-info.xml" xpointer=
"v216"/>
275 <term><option>--copy-locale
</option></term>
276 <term><option>--copy-keymap
</option></term>
277 <term><option>--copy-timezone
</option></term>
278 <term><option>--copy-root-password
</option></term>
279 <term><option>--copy-root-shell
</option></term>
281 <listitem><para>Copy a specific basic setting from the host.
282 This only works in combination with
<option>--root=
</option> or
<option>--image=
</option>.
285 <xi:include href=
"version-info.xml" xpointer=
"v216"/></listitem>
289 <term><option>--copy
</option></term>
291 <listitem><para>Copy locale, keymap, time zone, root password and shell from the host. This is
292 equivalent to specifying
293 <option>--copy-locale
</option>,
294 <option>--copy-keymap
</option>,
295 <option>--copy-timezone
</option>,
296 <option>--copy-root-password
</option>,
297 <option>--copy-root-shell
</option> in combination.
</para>
299 <xi:include href=
"version-info.xml" xpointer=
"v216"/>
304 <term><option>--force
</option></term>
306 <listitem><para>Write configuration even if the relevant files already exist. Without this option,
307 <command>systemd-firstboot
</command> doesn't modify or replace existing files. Note that when
308 configuring the root account, even with this option,
<command>systemd-firstboot
</command> only
309 modifies the entry of the
<literal>root
</literal> user, leaving other entries in
310 <filename>/etc/passwd
</filename> and
<filename>/etc/shadow
</filename> intact.
</para>
312 <xi:include href=
"version-info.xml" xpointer=
"v246"/></listitem>
316 <term><option>--reset
</option></term>
318 <listitem><para>If specified, all existing files that are configured by
319 <command>systemd-firstboot
</command> are removed. Note that the files are removed regardless of
320 whether they'll be configured with a new value or not. This operation ensures that the next boot of
321 the image will be considered a first boot, and
<command>systemd-firstboot
</command> will prompt again
322 to configure each of the removed files.
</para>
324 <xi:include href=
"version-info.xml" xpointer=
"v254"/></listitem>
328 <term><option>--delete-root-password
</option></term>
330 <listitem><para>Removes the password of the system's root user, enabling login as root without a
331 password unless the root account is locked. Note that this is extremely insecure and hence this
332 option should not be used lightly.
</para>
334 <xi:include href=
"version-info.xml" xpointer=
"v246"/></listitem>
338 <term><option>--welcome=
</option></term>
340 <listitem><para>Takes a boolean argument. By default when prompting the user for configuration
341 options a brief welcome text is shown before the first question is asked. Pass false to this option
342 to turn off the welcome text.
</para>
344 <xi:include href=
"version-info.xml" xpointer=
"v246"/></listitem>
347 <xi:include href=
"standard-options.xml" xpointer=
"help" />
348 <xi:include href=
"standard-options.xml" xpointer=
"version" />
353 <title>Credentials
</title>
355 <para><command>systemd-firstboot
</command> supports the service credentials logic as implemented by
356 <varname>ImportCredential=
</varname>/
<varname>LoadCredential=
</varname>/
<varname>SetCredential=
</varname>
357 (see
<citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
358 details). The following credentials are used when passed in:
</para>
360 <variablelist class='system-credentials'
>
362 <term><varname>passwd.hashed-password.root
</varname></term>
363 <term><varname>passwd.plaintext-password.root
</varname></term>
365 <listitem><para>A hashed or plaintext version of the root password to use, in place of prompting the
366 user. These credentials are equivalent to the same ones defined for the
367 <citerefentry><refentrytitle>systemd-sysusers.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
370 <xi:include href=
"version-info.xml" xpointer=
"v249"/></listitem>
374 <term><varname>passwd.shell.root
</varname></term>
376 <listitem><para>Specifies the shell binary to use for the specified account.
377 Equivalent to the credential of the same name defined for the
378 <citerefentry><refentrytitle>systemd-sysusers.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
381 <xi:include href=
"version-info.xml" xpointer=
"v249"/></listitem>
385 <term><varname>firstboot.locale
</varname></term>
386 <term><varname>firstboot.locale-messages
</varname></term>
388 <listitem><para>These credentials specify the locale settings to set during first boot, in place of
389 prompting the user.
</para>
391 <xi:include href=
"version-info.xml" xpointer=
"v249"/></listitem>
395 <term><varname>firstboot.keymap
</varname></term>
397 <listitem><para>This credential specifies the keyboard setting to set during first boot, in place of
398 prompting the user.
</para>
400 <para>Note the relationship to the
<varname>vconsole.keymap
</varname> credential understood by
401 <citerefentry><refentrytitle>systemd-vconsole-setup.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>:
402 both ultimately affect the same setting, but
<varname>firstboot.keymap
</varname> is written into
403 <filename>/etc/vconsole.conf
</filename> on first boot (if not already configured), and then read from
404 there by
<command>systemd-vconsole-setup
</command>, while
<varname>vconsole.keymap
</varname> is read
405 on every boot, and is not persisted to disk (but any configuration in
406 <filename>vconsole.conf
</filename> will take precedence if present).
</para>
408 <xi:include href=
"version-info.xml" xpointer=
"v249"/></listitem>
412 <term><varname>firstboot.timezone
</varname></term>
414 <listitem><para>This credential specifies the system timezone setting to set during first boot, in
415 place of prompting the user.
</para>
417 <xi:include href=
"version-info.xml" xpointer=
"v249"/></listitem>
421 <para>Note that by default the
<filename>systemd-firstboot.service
</filename> unit file is set up to
422 inherit the listed credentials
423 from the service manager. Thus, when invoking a container with an unpopulated
<filename>/etc/
</filename>
424 for the first time it is possible to configure the root user's password to be
<literal>systemd
</literal>
427 <para><programlisting># systemd-nspawn --image=… --set-credential=firstboot.locale:de_DE.UTF-
8 …
</programlisting></para>
429 <para>Note that these credentials are only read and applied during the first boot. Once they are applied
430 they remain applied for subsequent boots, and the credentials are not considered anymore.
</para>
434 <title>Exit status
</title>
436 <para>On success,
0 is returned, a non-zero failure code
441 <title>Kernel Command Line
</title>
443 <variablelist class='kernel-commandline-options'
>
445 <term><varname>systemd.firstboot=
</varname></term>
447 <listitem><para>Takes a boolean argument, defaults to on. If off,
<filename>systemd-firstboot.service
</filename>
448 won't interactively query the user for basic settings at first boot, even if those settings are not
449 initialized yet.
</para>
451 <xi:include href=
"version-info.xml" xpointer=
"v233"/></listitem>
457 <title>See Also
</title>
458 <para><simplelist type=
"inline">
459 <member><citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
460 <member><citerefentry project='man-pages'
><refentrytitle>locale.conf
</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
461 <member><citerefentry project='man-pages'
><refentrytitle>vconsole.conf
</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
462 <member><citerefentry><refentrytitle>localtime
</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
463 <member><citerefentry><refentrytitle>hostname
</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
464 <member><citerefentry><refentrytitle>machine-id
</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
465 <member><citerefentry project='die-net'
><refentrytitle>shadow
</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
466 <member><citerefentry><refentrytitle>systemd-machine-id-setup
</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
467 <member><citerefentry project='man-pages'
><refentrytitle>localectl
</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
468 <member><citerefentry><refentrytitle>timedatectl
</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
469 <member><citerefentry><refentrytitle>hostnamectl
</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>