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.2/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><command>systemd-firstboot
</command> initializes basic system settings interactively during the
38 first boot, or non-interactively on an offline system image. The service is started during boot if
39 <varname>ConditionFirstBoot=yes
</varname> is met, which essentially means that
<filename>/etc/
</filename>
41 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
44 <para>The following settings may be configured:
</para>
47 <listitem><para>The machine ID of the system
</para></listitem>
49 <listitem><para>The system locale, more specifically the two
50 locale variables
<varname>LANG=
</varname> and
51 <varname>LC_MESSAGES
</varname></para></listitem>
53 <listitem><para>The system keyboard map
</para></listitem>
55 <listitem><para>The system time zone
</para></listitem>
57 <listitem><para>The system hostname
</para></listitem>
59 <listitem><para>The kernel command line used when installing kernel images
</para></listitem>
61 <listitem><para>The root user's password and shell
</para></listitem>
64 <para>Each of the fields may either be queried interactively by
65 users, set non-interactively on the tool's command line, or be
66 copied from a host system that is used to set up the system
69 <para>If a setting is already initialized, it will not be
70 overwritten and the user will not be prompted for the
73 <para>Note that this tool operates directly on the file system and
74 does not involve any running system services, unlike
75 <citerefentry project='man-pages'
><refentrytitle>localectl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
76 <citerefentry><refentrytitle>timedatectl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>
78 <citerefentry><refentrytitle>hostnamectl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
79 This allows
<command>systemd-firstboot
</command> to operate on
80 mounted but not booted disk images and in early boot. It is not
81 recommended to use
<command>systemd-firstboot
</command> on the
82 running system after it has been set up.
</para>
86 <title>Options
</title>
88 <para>The following options are understood:
</para>
92 <term><option>--root=
<replaceable>root
</replaceable></option></term>
93 <listitem><para>Takes a directory path as an argument. All
94 paths will be prefixed with the given alternate
95 <replaceable>root
</replaceable> path, including config search
96 paths. This is useful to operate on a system image mounted to
97 the specified directory instead of the host system itself.
100 <xi:include href=
"version-info.xml" xpointer=
"v216"/></listitem>
104 <term><option>--image=
<replaceable>path
</replaceable></option></term>
105 <listitem><para>Takes a path to a disk image file or block device node. If specified all operations
106 are applied to file system in the indicated disk image. This is similar to
<option>--root=
</option>
107 but operates on file systems stored in disk images or block devices. The disk image should either
108 contain just a file system or a set of file systems within a GPT partition table, following the
109 <ulink url=
"https://uapi-group.org/specifications/specs/discoverable_partitions_specification">Discoverable Partitions
110 Specification
</ulink>. For further information on supported disk images, see
111 <citerefentry><refentrytitle>systemd-nspawn
</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
112 switch of the same name.
</para>
114 <xi:include href=
"version-info.xml" xpointer=
"v246"/></listitem>
118 <term><option>--locale=
<replaceable>LOCALE
</replaceable></option></term>
119 <term><option>--locale-messages=
<replaceable>LOCALE
</replaceable></option></term>
121 <listitem><para>Sets the system locale, more specifically the
122 <varname>LANG=
</varname> and
<varname>LC_MESSAGES
</varname>
123 settings. The argument should be a valid locale identifier,
124 such as
<literal>de_DE.UTF-
8</literal>. This controls the
125 <citerefentry project='man-pages'
><refentrytitle>locale.conf
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
126 configuration file.
</para>
128 <xi:include href=
"version-info.xml" xpointer=
"v216"/></listitem>
132 <term><option>--keymap=
<replaceable>KEYMAP
</replaceable></option></term>
134 <listitem><para>Sets the system keyboard layout. The argument should be a valid keyboard map,
135 such as
<literal>de-latin1
</literal>. This controls the
<literal>KEYMAP
</literal> entry in the
136 <citerefentry project='man-pages'
><refentrytitle>vconsole.conf
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
137 configuration file.
</para>
139 <xi:include href=
"version-info.xml" xpointer=
"v236"/></listitem>
143 <term><option>--timezone=
<replaceable>TIMEZONE
</replaceable></option></term>
145 <listitem><para>Sets the system time zone. The argument should
146 be a valid time zone identifier, such as
147 <literal>Europe/Berlin
</literal>. This controls the
148 <citerefentry><refentrytitle>localtime
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
151 <xi:include href=
"version-info.xml" xpointer=
"v216"/></listitem>
155 <term><option>--hostname=
<replaceable>HOSTNAME
</replaceable></option></term>
157 <listitem><para>Sets the system hostname. The argument should
158 be a hostname, compatible with DNS. This controls the
159 <citerefentry><refentrytitle>hostname
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
160 configuration file.
</para>
162 <xi:include href=
"version-info.xml" xpointer=
"v216"/></listitem>
166 <term><option>--setup-machine-id
</option></term>
168 <listitem><para>Initialize the system's machine ID to a random ID. This controls the
169 <citerefentry><refentrytitle>machine-id
</refentrytitle><manvolnum>5</manvolnum></citerefentry> file.
172 <para>This option only works in combination with
<option>--root=
</option> or
173 <option>--image=
</option>. On a running system,
<filename>machine-id
</filename> is written by the
174 manager with help from
175 <citerefentry><refentrytitle>systemd-machine-id-commit.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
178 <xi:include href=
"version-info.xml" xpointer=
"v216"/></listitem>
182 <term><option>--machine-id=
<replaceable>ID
</replaceable></option></term>
184 <listitem><para>Set the system's machine ID to the specified value. The same restrictions apply
185 as to
<option>--setup-machine-id
</option>.
</para>
187 <xi:include href=
"version-info.xml" xpointer=
"v216"/></listitem>
191 <term><option>--root-password=
<replaceable>PASSWORD
</replaceable></option></term>
192 <term><option>--root-password-file=
<replaceable>PATH
</replaceable></option></term>
193 <term><option>--root-password-hashed=
<replaceable>HASHED_PASSWORD
</replaceable></option></term>
195 <listitem><para>Sets the password of the system's root user. This creates/modifies the
196 <citerefentry project='die-net'
><refentrytitle>passwd
</refentrytitle><manvolnum>5</manvolnum></citerefentry> and
197 <citerefentry project='die-net'
><refentrytitle>shadow
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
198 files. This setting exists in three forms:
<option>--root-password=
</option> accepts the password to
199 set directly on the command line,
<option>--root-password-file=
</option> reads it from a file and
200 <option>--root-password-hashed=
</option> accepts an already hashed password on the command line. See
201 <citerefentry project='die-net'
><refentrytitle>shadow
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
202 for more information on the format of the hashed password. Note that it is not recommended to specify
203 plaintext passwords on the command line, as other users might be able to see them simply by invoking
204 <citerefentry project='die-net'
><refentrytitle>ps
</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
209 <term><option>--root-shell=
<replaceable>SHELL
</replaceable></option></term>
211 <listitem><para>Sets the shell of the system's root user. This creates/modifies the
212 <citerefentry project='die-net'
><refentrytitle>passwd
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
215 <xi:include href=
"version-info.xml" xpointer=
"v246"/></listitem>
219 <term><option>--kernel-command-line=
<replaceable>CMDLINE
</replaceable></option></term>
221 <listitem><para>Sets the system's kernel command line. This controls the
222 <filename>/etc/kernel/cmdline
</filename> file which is used by
223 <citerefentry><refentrytitle>kernel-install
</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
226 <xi:include href=
"version-info.xml" xpointer=
"v246"/></listitem>
230 <term><option>--prompt-locale
</option></term>
231 <term><option>--prompt-keymap
</option></term>
232 <term><option>--prompt-timezone
</option></term>
233 <term><option>--prompt-hostname
</option></term>
234 <term><option>--prompt-root-password
</option></term>
235 <term><option>--prompt-root-shell
</option></term>
237 <listitem><para>Prompt the user interactively for a specific
238 basic setting. Note that any explicit configuration settings
239 specified on the command line take precedence, and the user is
240 not prompted for it.
</para></listitem>
244 <term><option>--prompt
</option></term>
246 <listitem><para>Query the user for locale, keymap, timezone, hostname,
247 root's password, and root's shell. This is equivalent to specifying
248 <option>--prompt-locale
</option>,
249 <option>--prompt-keymap
</option>,
250 <option>--prompt-timezone
</option>,
251 <option>--prompt-hostname
</option>,
252 <option>--prompt-root-password
</option>,
253 <option>--prompt-root-shell
</option> in combination.
</para>
255 <xi:include href=
"version-info.xml" xpointer=
"v216"/>
260 <term><option>--copy-locale
</option></term>
261 <term><option>--copy-keymap
</option></term>
262 <term><option>--copy-timezone
</option></term>
263 <term><option>--copy-root-password
</option></term>
264 <term><option>--copy-root-shell
</option></term>
266 <listitem><para>Copy a specific basic setting from the host.
267 This only works in combination with
<option>--root=
</option> or
<option>--image=
</option>.
272 <term><option>--copy
</option></term>
274 <listitem><para>Copy locale, keymap, time zone, root password and shell from the host. This is
275 equivalent to specifying
276 <option>--copy-locale
</option>,
277 <option>--copy-keymap
</option>,
278 <option>--copy-timezone
</option>,
279 <option>--copy-root-password
</option>,
280 <option>--copy-root-shell
</option> in combination.
</para>
282 <xi:include href=
"version-info.xml" xpointer=
"v216"/>
287 <term><option>--force
</option></term>
289 <listitem><para>Write configuration even if the relevant files already exist. Without this option,
290 <filename>systemd-firstboot
</filename> doesn't modify or replace existing files. Note that when
291 configuring the root account, even with this option,
<filename>systemd-firstboot
</filename> only
292 modifies the entry of the
<literal>root
</literal> user, leaving other entries in
293 <filename>/etc/passwd
</filename> and
<filename>/etc/shadow
</filename> intact.
</para>
295 <xi:include href=
"version-info.xml" xpointer=
"v246"/></listitem>
299 <term><option>--reset
</option></term>
301 <listitem><para>If specified, all existing files that are configured by
302 <command>systemd-firstboot
</command> are removed. Note that the files are removed regardless of
303 whether they'll be configured with a new value or not. This operation ensures that the next boot of
304 the image will be considered a first boot, and
<command>systemd-firstboot
</command> will prompt again
305 to configure each of the removed files.
</para>
307 <xi:include href=
"version-info.xml" xpointer=
"v254"/></listitem>
311 <term><option>--delete-root-password
</option></term>
313 <listitem><para>Removes the password of the system's root user, enabling login as root without a
314 password unless the root account is locked. Note that this is extremely insecure and hence this
315 option should not be used lightly.
</para>
317 <xi:include href=
"version-info.xml" xpointer=
"v246"/></listitem>
321 <term><option>--welcome=
</option></term>
323 <listitem><para>Takes a boolean argument. By default when prompting the user for configuration
324 options a brief welcome text is shown before the first question is asked. Pass false to this option
325 to turn off the welcome text.
</para>
327 <xi:include href=
"version-info.xml" xpointer=
"v246"/></listitem>
330 <xi:include href=
"standard-options.xml" xpointer=
"help" />
331 <xi:include href=
"standard-options.xml" xpointer=
"version" />
336 <title>Credentials
</title>
338 <para><command>systemd-firstboot
</command> supports the service credentials logic as implemented by
339 <varname>ImportCredential=
</varname>/
<varname>LoadCredential=
</varname>/
<varname>SetCredential=
</varname>
340 (see
<citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>1</manvolnum></citerefentry> for
341 details). The following credentials are used when passed in:
</para>
343 <variablelist class='system-credentials'
>
345 <term><varname>passwd.hashed-password.root
</varname></term>
346 <term><varname>passwd.plaintext-password.root
</varname></term>
348 <listitem><para>A hashed or plaintext version of the root password to use, in place of prompting the
349 user. These credentials are equivalent to the same ones defined for the
350 <citerefentry><refentrytitle>systemd-sysusers.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
353 <xi:include href=
"version-info.xml" xpointer=
"v249"/></listitem>
357 <term><varname>passwd.shell.root
</varname></term>
359 <listitem><para>Specifies the shell binary to use for the specified account.
360 Equivalent to the credential of the same name defined for the
361 <citerefentry><refentrytitle>systemd-sysusers.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
364 <xi:include href=
"version-info.xml" xpointer=
"v249"/></listitem>
368 <term><varname>firstboot.locale
</varname></term>
369 <term><varname>firstboot.locale-messages
</varname></term>
371 <listitem><para>These credentials specify the locale settings to set during first boot, in place of
372 prompting the user.
</para>
374 <xi:include href=
"version-info.xml" xpointer=
"v249"/></listitem>
378 <term><varname>firstboot.keymap
</varname></term>
380 <listitem><para>This credential specifies the keyboard setting to set during first boot, in place of
381 prompting the user.
</para>
383 <para>Note the relationship to the
<varname>vconsole.keymap
</varname> credential understood by
384 <citerefentry><refentrytitle>systemd-vconsole-setup.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>:
385 both ultimately affect the same setting, but
<varname>firstboot.keymap
</varname> is written into
386 <filename>/etc/vconsole.conf
</filename> on first boot (if not already configured), and then read from
387 there by
<command>systemd-vconsole-setup
</command>, while
<varname>vconsole.keymap
</varname> is read
388 on every boot, and is not persisted to disk (but any configuration in
389 <filename>vconsole.conf
</filename> will take precedence if present).
</para>
391 <xi:include href=
"version-info.xml" xpointer=
"v249"/></listitem>
395 <term><varname>firstboot.timezone
</varname></term>
397 <listitem><para>This credential specifies the system timezone setting to set during first boot, in
398 place of prompting the user.
</para>
400 <xi:include href=
"version-info.xml" xpointer=
"v249"/></listitem>
404 <para>Note that by default the
<filename>systemd-firstboot.service
</filename> unit file is set up to
405 inherit the listed credentials
406 from the service manager. Thus, when invoking a container with an unpopulated
<filename>/etc/
</filename>
407 for the first time it is possible to configure the root user's password to be
<literal>systemd
</literal>
410 <para><programlisting># systemd-nspawn --image=… --set-credential=firstboot.locale:de_DE.UTF-
8 …
</programlisting></para>
412 <para>Note that these credentials are only read and applied during the first boot process. Once they are
413 applied they remain applied for subsequent boots, and the credentials are not considered anymore.
</para>
417 <title>Exit status
</title>
419 <para>On success,
0 is returned, a non-zero failure code
424 <title>Kernel Command Line
</title>
426 <variablelist class='kernel-commandline-options'
>
428 <term><varname>systemd.firstboot=
</varname></term>
430 <listitem><para>Takes a boolean argument, defaults to on. If off,
<filename>systemd-firstboot.service
</filename>
431 won't interactively query the user for basic settings at first boot, even if those settings are not
432 initialized yet.
</para>
434 <xi:include href=
"version-info.xml" xpointer=
"v233"/></listitem>
440 <title>See Also
</title>
442 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
443 <citerefentry project='man-pages'
><refentrytitle>locale.conf
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
444 <citerefentry project='man-pages'
><refentrytitle>vconsole.conf
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
445 <citerefentry><refentrytitle>localtime
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
446 <citerefentry><refentrytitle>hostname
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
447 <citerefentry><refentrytitle>machine-id
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
448 <citerefentry project='die-net'
><refentrytitle>shadow
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
449 <citerefentry><refentrytitle>systemd-machine-id-setup
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
450 <citerefentry project='man-pages'
><refentrytitle>localectl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
451 <citerefentry><refentrytitle>timedatectl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
452 <citerefentry><refentrytitle>hostnamectl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>