Tag LFS-7.9-systemd-rc2
[linux_from_scratch.git] / chapter07 / systemd-custom.xml
blob01df05b456e3fffe85e84cb62ca2b730f4648901
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3   "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4   <!ENTITY % general-entities SYSTEM "../general.ent">
5   %general-entities;
6 ]>
8 <sect1 id="ch-scripts-systemd-custom">
9   <?dbhtml filename="systemd-custom.html"?>
11   <title>Systemd Usage and Configuration</title>
13   <indexterm zone="ch-scripts-systemd-custom">
14     <primary sortas="e-Systemd">Systemd Customization</primary>
15   </indexterm>
17   <sect2>
18     <title>Basic Configuration</title>
20     <para>The <filename>/etc/systemd/system.conf</filename> file contains a set
21     of options to control basic systemd operations. The default file has all
22     entries commented out with the default settings indicated. This file is
23     where the log level may be changed as well as some basic logging settings.
24     See <filename>systemd-system.conf(5)</filename> manual page for details on
25     each configuration option.</para>
27   </sect2>
29   <sect2>
30     <title>Disabling Screen Clearing at Boot Time</title>
32     <para>The normal behavior for systemd is to clear the screen at
33     the end of the boot sequence. If desired, this behavior may be
34     changed by running the following command:</para>
36 <screen role="nodump"><userinput>mkdir -pv /etc/systemd/system/getty@tty1.service.d
38 cat &gt; /etc/systemd/system/getty@tty1.service.d/noclear.conf &lt;&lt; EOF
39 <literal>[Service]
40 TTYVTDisallocate=no</literal>
41 EOF</userinput></screen>
43     <para>The boot messages can always be revied by using the
44     <userinput>journalctl -b</userinput> command as the root user.</para>
46   </sect2>
48   <sect2>
49     <title>Disabling tmpfs for /tmp</title>
51     <para>By default, <filename class="directory">/tmp</filename> is created as
52     a tmpfs. If this is not desired, it can be overridden by the following:</para>
54 <screen role="nodump"><userinput>ln -sfv /dev/null /etc/systemd/system/tmp.mount</userinput></screen>
56     <para>This is not necessary if there is a separate partition for
57     <filename class="directory">/tmp</filename> specified in
58     <filename>/etc/fstab</filename>.</para>
60   </sect2>
62   <sect2>
63     <title>Configuring Automatic File Creation and Deletion</title>
65     <para>There are several services that create or delete files or
66     directories:</para>
68     <itemizedlist>
69       <listitem><para>systemd-tmpfiles-clean.service</para></listitem>
70       <listitem><para>systemd-tmpfiles-setup-dev.service</para></listitem>
71       <listitem><para>systemd-tmpfiles-setup.service</para></listitem>
72     </itemizedlist>
73   
74     <para>The system location for the configuration files is
75     <filename>/usr/lib/tmpfiles.d/*.conf</filename>. The local 
76     configuration files are in
77     <filename class="directory">/etc/tmpfiles.d</filename>. Files in
78     <filename class="directory">/etc/tmpfiles.d</filename> override
79     files with the same name in
80     <filename class="directory">/usr/lib/tmpfiles.d</filename>. See
81     <filename>tmpfiles.d(5)</filename> manual page  for file format
82     details.</para>
84   </sect2>
86   <sect2>
87     <title>Overriding Default Services Behavior</title>
89     <para>A systemd service contents can be overriden by creating a directory
90     and a configuration file in <filename
91     class="directory">/etc/systemd/system</filename>. For example:</para>
93 <screen role="nodump"><userinput>mkdir -pv /etc/systemd/system/foobar.service.d
95 cat > /etc/systemd/system/foobar.service.d/foobar.conf &lt;&lt; EOF
96 <literal>[Service]
97 Restart=always
98 RestartSec=30</literal>
99 EOF</userinput></screen>
101      <para>See <filename>systemd.unit(5)</filename> manual page for more
102      information. After creating the configuration file, run
103      <userinput>systemctl daemon-reload</userinput> and <userinput>systemctl
104      restart foobar</userinput> to activate the changes to a service.</para>
106   </sect2>
108   <sect2>
109     <title>Debugging the Boot Sequence</title>
111     <para>There are several commands that can be used to help debug the systemd 
112     boot process. Here are some examples:</para>
114     <itemizedlist>
115        <listitem><para>systemctl list-units -t service [--all]</para></listitem>
116        <listitem><para>systemctl list-units -t target  [--all]</para></listitem>
117        <listitem><para>systemctl show -p Wants multi-user.target</para></listitem>
118        <listitem><para>systemctl status sshd.service</para></listitem>
119     </itemizedlist>
121   </sect2>
123 </sect1>