aboutsummaryrefslogtreecommitdiffstats
path: root/chapter07/sysd-custom.xml
blob: e5872ece9ef045486f4740deb8ce017375d827ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  <!ENTITY % general-entities SYSTEM "../general.ent">
  %general-entities;
]>

<sect1 id="ch-scripts-sysd-custom">
  <?dbhtml filename="sysd-custom.html"?>

  <title>Systemd Usage and Confiuration</title>

  <indexterm zone="ch-scripts-sysd-custom">
    <primary sortas="e-Systemd">Systemd Customization</primary>
  </indexterm>

  <sect2>
    <title>Basic Configuration</title>

    <para>The <filename>/etc/systemd/system.conf</filename> file contains a set
    of items to control basic operations.  The default file has all entries
    commented out with the default settings indicated. This file is where the
    log level may be changed as well as some basic journal settings.</para>

  </sect2>

  <sect2>
    <title>Disabling Screen Clearing at Boot Time</title>

    <para>The normal behavior for systemd is to clear the secreen at
    the end of the boot sequence.  If desired, this behavior may be
    changed by the following:</para>

<screen role="nodump"><userinput>mkdir -p /etc/systemd/system/getty@tty1.service.d

cat > /etc/systemd/system/getty@tty1.service.d/noclear.conf &lt;&lt; EOF
[Service]
TTYVTDisallocate=no
EOF</userinput></screen>

    <para>The boot messages can always be revied by using the
    <userinput>journalctl -b</userinput> command as the root user.</para>

  </sect2>

  <sect2>
    <title>Disabling tmpfs for /tmp </title>

    <para>By default, <filename class="directory">/tmp</filename> is created as
    a tmpfs.  If this is not desired, it can be overridden by the following:</para>

<screen role="nodump"><userinput>ln -s /dev/null /etc/systemd/system/tmp.mount</userinput></screen>

    <para>This is not necessary if there is a separate partition for /tmp
    specified in <filename>/etc/fstab</filename>.</para>
  </sect2>

  <sect2>
    <title>Configuring Automatic File Creation and Deletion</title>

    <para>There are several services that create or delete files or
    directories:</para>

    <itemizedlist>
      <listitem><para>systemd-tmpfiles-clean.service</para></listitem>
      <listitem><para>systemd-tmpfiles-setup-dev.service</para></listitem>
      <listitem><para>systemd-tmpfiles-setup.service</para></listitem>
    </itemizedlist>
  
    <para>The system location for the configuration files is
    <filename>/usr/lib/tmpfiles.d/*.conf</filename>.  The local 
    configuration files are in <filename>/etc/tmpfiles.d/*.conf</filename>.
    Files in /etc/tmpfiles.d override files with the same name in 
    /usr/lib/tmpfiles.d.  See <userinput>man tmpfiles.d</userinput> 
    for file format details.</para>

  </sect2>

  <sect2>
    <title>Adding Custom Units and Services</title>

    <para>A custom service can be added by creating a directory and
    configuration file in <filename class="directory">/etc/systemd/system/</filename>.
    For example:</para>

<screen role="nodump"><userinput>mkdir -p /etc/systemd/system/foobar.service.d

cat > /etc/systemd/system/foobar.service.d/foobar.conf &lt;&lt; EOF
[Service]
Restart=always
RestartSec=30
EOF</userinput></screen>

     <para>See the man page for systemd.unit for more information.  After
     creating the configuration file, run <userinput>systemctl
     daemon-reload</userinput> and <userinput>systemctl restart
     foobar</userinput> to activate a service or changes to a service.</para>

  </sect2>

  <sect2 id="ch-scripts-systemd-console">
    <title>Setting Console Fonts and Keyboard</title>

    <indexterm zone="ch-scripts-systemd-console">
      <primary sortas="d-console">systemd console</primary>
      <secondary>configuring</secondary>
    </indexterm>
  
    <para>This section discusses how to configure the
    <command>systemd-vconsole-setup</command> system service, which configures
    the virtual console font and console keymap.</para>
  
    <para>The <command>systemd-vconsole-setup</command> service reads the
    <filename>/etc/vconsole.conf</filename> file for configuration
    information. Decide which keymap and screen font will be used. Various
    language-specific HOWTOs can also help with this, see <ulink
    url="http://www.tldp.org/HOWTO/HOWTO-INDEX/other-lang.html"/>.
    Examine <command>localectl list-keymaps</command> output for a list of
    valid console keymaps. Look in
    <filename class="directory">/usr/share/consolefonts</filename>
    directory for valid screen fonts.</para>
  
    <para>The <filename>/etc/vconsole.conf</filename> file should contain lines
    of the form: VARIABLE="value". The following variables are recognized:</para>
  
    <variablelist>
  
      <varlistentry>
        <term>KEYMAP</term>
        <listitem>
          <para>This variable specifies the key mapping table for the keyboard. If
          unset, it defaults to <literal>us</literal>.</para>
        </listitem>
      </varlistentry>
  
      <varlistentry>
        <term>KEYMAP_TOGGLE</term>
        <listitem>
          <para>This variable can be used to configure a second toggle keymap and
          is unset by default.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>FONT</term>
        <listitem>
          <para>This variable specifies the font used by the virtual
          console.</para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>FONT_MAP</term>
        <listitem>
          <para>This variable specifies the console map to be used.</para>
        </listitem>
      </varlistentry>
  
      <varlistentry>
        <term>FONT_UNIMAP</term>
        <listitem>
          <para>This variable specifies the unicode font map.</para>
        </listitem>
      </varlistentry>
  
    </variablelist>
  
    <para>An example for a German keyboard and console is given below:</para>

<screen role="nodump"><userinput>cat &gt; /etc/vconsole.conf &lt;&lt; "EOF"
<literal>KEYMAP=de-latin1
FONT=Lat2-Terminus16</literal>
EOF</userinput></screen>

    <para>You can change KEYMAP value at runtime by using the
    <command>localectl</command> utility:</para>

<screen role="nodump"><userinput>localectl set-keymap MAP</userinput></screen>

    <note><para>Please note that <command>localectl</command> command can
    be used  only on a system booted with Systemd.</para></note>

  </sect2>

  <sect2>
    <title>Clock Configuration</title>

    <indexterm zone="ch-scripts-clock">
      <primary sortas="d-clock">clock</primary>
    <secondary>configuring</secondary></indexterm>
  
    <para>This section discusses how to configure the
    <command>systemd-timedated</command> system service, which configures
    system clock and timezone.</para>
  
    <para><command>systemd-timedated</command> reads
    <filename>/etc/adjtime</filename>, and depending on the contents of the file,
    it sets the clock to either UTC or local time.  Create the
    <filename>/etc/adjtime</filename> file with the following contents <emphasis>if your
    hardware clock is set to local time</emphasis>:</para>

<screen role="nodump"><userinput>cat &gt; /etc/adjtime &lt;&lt; "EOF"
<literal>0.0 0 0.0
0
LOCAL</literal>
EOF</userinput></screen>

    <para>If <filename>/etc/adjtime</filename> isn't present at first boot,
    <command>systemd-timedated</command> will assume that hardware clock is
    set to UTC and create the file using that setting.</para>

    <para>You can also use the <command>timedatectl</command> utility to tell
    <command>systemd-timedated</command> if your hardware clock is set to
    UTC or local time:</para>

<screen role="nodump"><userinput>timedatectl set-local-rtc 1</userinput></screen>

    <para><command>timedatectl</command> can also be used to change system time and
    time zone.</para>

    <para>To change your current system time, issue:</para>

<screen role="nodump"><userinput>timedatectl set-time YYYY:MM:DD HH:MM:SS</userinput></screen>

    <para>Hardware clock will also be updated accordingly.</para>

    <para>To change your current time zone, issue:</para>

<screen role="nodump"><userinput>timedatectl set-timezone TIMEZONE</userinput></screen>

    <para>You can get list of available time zones by running:</para>

<screen role="nodump"><userinput>timedatectl list-timezones</userinput></screen>

    <note><para>The <command>timedatectl</command> command can
    be used only on a system booted with Systemd.</para></note>

  </sect2>

  <sect2>
    <title>Debugging the Boot Sequence</title>

    <para>There are several commands that can be used to help debug the systemd 
    boot process.  Here are some examples:</para>

    <itemizedlist>
       <listitem><para>systemctl list-units -t service [--all]</para></listitem>
       <listitem><para>systemctl list-units -t target  [--all]</para></listitem>
       <listitem><para>systemctl show -p Wants multi-user.target</para></listitem>
       <listitem><para>systemctl status sshd.service</para></listitem>
    </itemizedlist>

  </sect2>

</sect1>