[c729bc9] | 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 | ]>
|
---|
| 7 |
|
---|
| 8 | <sect1 id="ch-scripts-sysd-custom">
|
---|
| 9 | <?dbhtml filename="sysd-custom.html"?>
|
---|
| 10 |
|
---|
[bf58c1e] | 11 | <title>Systemd Usage and Confiuration</title>
|
---|
[c729bc9] | 12 |
|
---|
| 13 | <indexterm zone="ch-scripts-sysd-custom">
|
---|
| 14 | <primary sortas="e-Systemd">Systemd Customization</primary>
|
---|
| 15 | </indexterm>
|
---|
| 16 |
|
---|
| 17 | <sect2>
|
---|
| 18 | <title>Basic Configuration</title>
|
---|
| 19 |
|
---|
| 20 | <para>The <filename>/etc/systemd/system.conf</filename> file contains a set
|
---|
| 21 | of items to control basic operations. The default file has all entries
|
---|
| 22 | commented out with the default settings indicated. This file is where the
|
---|
| 23 | log level may be changed as well as some basic journal settings.</para>
|
---|
| 24 |
|
---|
| 25 | </sect2>
|
---|
| 26 |
|
---|
| 27 | <sect2>
|
---|
| 28 | <title>Disabling Screen Clearing at Boot Time</title>
|
---|
| 29 |
|
---|
| 30 | <para>The normal behavior for systemd is to clear the secreen at
|
---|
| 31 | the end of the boot sequence. If desired, this behavior may be
|
---|
| 32 | changed by the following:</para>
|
---|
| 33 |
|
---|
| 34 | <screen role="nodump"><userinput>mkdir -p /etc/systemd/system/getty@tty1.service.d
|
---|
| 35 |
|
---|
| 36 | cat > /etc/systemd/system/getty@tty1.service.d/noclear.conf << EOF
|
---|
| 37 | [Service]
|
---|
| 38 | TTYVTDisallocate=no
|
---|
| 39 | EOF</userinput></screen>
|
---|
| 40 |
|
---|
| 41 | <para>The boot messages can always be revied by using the
|
---|
| 42 | <userinput>journalctl -b</userinput> command as the root user.</para>
|
---|
| 43 |
|
---|
| 44 | </sect2>
|
---|
| 45 |
|
---|
| 46 | <sect2>
|
---|
| 47 | <title>Disabling tmpfs for /tmp </title>
|
---|
| 48 |
|
---|
| 49 | <para>By default, <filename class="directory">/tmp</filename> is created as
|
---|
| 50 | a tmpfs. If this is not desired, it can be overridden by the following:</para>
|
---|
| 51 |
|
---|
| 52 | <screen role="nodump"><userinput>ln -s /dev/null /etc/systemd/system/tmp.mount</userinput></screen>
|
---|
| 53 |
|
---|
| 54 | <para>This is not necessary if there is a separate partition for /tmp
|
---|
| 55 | specified in <filename>/etc/fstab</filename>.</para>
|
---|
| 56 | </sect2>
|
---|
| 57 |
|
---|
| 58 | <sect2>
|
---|
| 59 | <title>Configuring Automatic File Creation and Deletion</title>
|
---|
| 60 |
|
---|
| 61 | <para>There are several services that create or delete files or
|
---|
| 62 | directories:</para>
|
---|
| 63 |
|
---|
| 64 | <itemizedlist>
|
---|
| 65 | <listitem><para>systemd-tmpfiles-clean.service</para></listitem>
|
---|
| 66 | <listitem><para>systemd-tmpfiles-setup-dev.service</para></listitem>
|
---|
| 67 | <listitem><para>systemd-tmpfiles-setup.service</para></listitem>
|
---|
| 68 | </itemizedlist>
|
---|
| 69 |
|
---|
| 70 | <para>The system location for the configuration files is
|
---|
| 71 | <filename>/usr/lib/tmpfiles.d/*.conf</filename>. The local
|
---|
| 72 | configuration files are in <filename>/etc/tmpfiles.d/*.conf</filename>.
|
---|
| 73 | Files in /etc/tmpfiles.d override files with the same name in
|
---|
| 74 | /usr/lib/tmpfiles.d. See <userinput>man tmpfiles.d</userinput>
|
---|
| 75 | for file format details.</para>
|
---|
| 76 |
|
---|
| 77 | </sect2>
|
---|
| 78 |
|
---|
| 79 | <sect2>
|
---|
| 80 | <title>Adding Custom Units and Services</title>
|
---|
| 81 |
|
---|
| 82 | <para>A custom service can be added by creating a directory and
|
---|
| 83 | configuration file in <filename class="directory">/etc/systemd/system/</filename>.
|
---|
| 84 | For example:</para>
|
---|
| 85 |
|
---|
| 86 | <screen role="nodump"><userinput>mkdir -p /etc/systemd/system/foobar.service.d
|
---|
| 87 |
|
---|
| 88 | cat > /etc/systemd/system/foobar.service.d/foobar.conf << EOF
|
---|
| 89 | [Service]
|
---|
| 90 | Restart=always
|
---|
| 91 | RestartSec=30
|
---|
| 92 | EOF</userinput></screen>
|
---|
| 93 |
|
---|
| 94 | <para>See the man page for systemd.unit for more information. After
|
---|
| 95 | creating the configuration file, run <userinput>systemctl
|
---|
| 96 | daemon-reload</userinput> and <userinput>systemctl restart
|
---|
| 97 | foobar</userinput> to activate a service or changes to a service.</para>
|
---|
| 98 |
|
---|
| 99 | </sect2>
|
---|
| 100 |
|
---|
[bf58c1e] | 101 | <sect2 id="ch-scripts-systemd-console">
|
---|
| 102 | <title>Setting Console Fonts and Keyboard</title>
|
---|
| 103 |
|
---|
| 104 | <indexterm zone="ch-scripts-systemd-console">
|
---|
| 105 | <primary sortas="d-console">systemd console</primary>
|
---|
| 106 | <secondary>configuring</secondary>
|
---|
| 107 | </indexterm>
|
---|
| 108 |
|
---|
| 109 | <para>This section discusses how to configure the
|
---|
| 110 | <command>systemd-vconsole-setup</command> system service, which configures
|
---|
| 111 | the virtual console font and console keymap.</para>
|
---|
| 112 |
|
---|
| 113 | <para>The <command>systemd-vconsole-setup</command> service reads the
|
---|
| 114 | <filename>/etc/vconsole.conf</filename> file for configuration
|
---|
| 115 | information. Decide which keymap and screen font will be used. Various
|
---|
| 116 | language-specific HOWTOs can also help with this, see <ulink
|
---|
| 117 | url="http://www.tldp.org/HOWTO/HOWTO-INDEX/other-lang.html"/>.
|
---|
| 118 | Examine <command>localectl list-keymaps</command> output for a list of
|
---|
| 119 | valid console keymaps. Look in
|
---|
| 120 | <filename class="directory">/usr/share/consolefonts</filename>
|
---|
| 121 | directory for valid screen fonts.</para>
|
---|
| 122 |
|
---|
| 123 | <para>The <filename>/etc/vconsole.conf</filename> file should contain lines
|
---|
| 124 | of the form: VARIABLE="value". The following variables are recognized:</para>
|
---|
| 125 |
|
---|
| 126 | <variablelist>
|
---|
| 127 |
|
---|
| 128 | <varlistentry>
|
---|
| 129 | <term>KEYMAP</term>
|
---|
| 130 | <listitem>
|
---|
| 131 | <para>This variable specifies the key mapping table for the keyboard. If
|
---|
| 132 | unset, it defaults to <literal>us</literal>.</para>
|
---|
| 133 | </listitem>
|
---|
| 134 | </varlistentry>
|
---|
| 135 |
|
---|
| 136 | <varlistentry>
|
---|
| 137 | <term>KEYMAP_TOGGLE</term>
|
---|
| 138 | <listitem>
|
---|
| 139 | <para>This variable can be used to configure a second toggle keymap and
|
---|
| 140 | is unset by default.</para>
|
---|
| 141 | </listitem>
|
---|
| 142 | </varlistentry>
|
---|
| 143 | <varlistentry>
|
---|
| 144 | <term>FONT</term>
|
---|
| 145 | <listitem>
|
---|
| 146 | <para>This variable specifies the font used by the virtual
|
---|
| 147 | console.</para>
|
---|
| 148 | </listitem>
|
---|
| 149 | </varlistentry>
|
---|
| 150 | <varlistentry>
|
---|
| 151 | <term>FONT_MAP</term>
|
---|
| 152 | <listitem>
|
---|
| 153 | <para>This variable specifies the console map to be used.</para>
|
---|
| 154 | </listitem>
|
---|
| 155 | </varlistentry>
|
---|
| 156 |
|
---|
| 157 | <varlistentry>
|
---|
| 158 | <term>FONT_UNIMAP</term>
|
---|
| 159 | <listitem>
|
---|
| 160 | <para>This variable specifies the unicode font map.</para>
|
---|
| 161 | </listitem>
|
---|
| 162 | </varlistentry>
|
---|
| 163 |
|
---|
| 164 | </variablelist>
|
---|
| 165 |
|
---|
| 166 | <para>An example for a German keyboard and console is given below:</para>
|
---|
| 167 |
|
---|
| 168 | <screen role="nodump"><userinput>cat > /etc/vconsole.conf << "EOF"
|
---|
| 169 | <literal>KEYMAP=de-latin1
|
---|
| 170 | FONT=Lat2-Terminus16</literal>
|
---|
| 171 | EOF</userinput></screen>
|
---|
| 172 |
|
---|
| 173 | <para>You can change KEYMAP value at runtime by using the
|
---|
| 174 | <command>localectl</command> utility:</para>
|
---|
| 175 |
|
---|
| 176 | <screen role="nodump"><userinput>localectl set-keymap MAP</userinput></screen>
|
---|
| 177 |
|
---|
| 178 | <note><para>Please note that <command>localectl</command> command can
|
---|
| 179 | be used only on a system booted with Systemd.</para></note>
|
---|
| 180 |
|
---|
| 181 | </sect2>
|
---|
| 182 |
|
---|
| 183 | <sect2>
|
---|
| 184 | <title>Clock Configuration</title>
|
---|
| 185 |
|
---|
| 186 | <indexterm zone="ch-scripts-clock">
|
---|
| 187 | <primary sortas="d-clock">clock</primary>
|
---|
| 188 | <secondary>configuring</secondary></indexterm>
|
---|
| 189 |
|
---|
| 190 | <para>This section discusses how to configure the
|
---|
| 191 | <command>systemd-timedated</command> system service, which configures
|
---|
| 192 | system clock and timezone.</para>
|
---|
| 193 |
|
---|
| 194 | <para><command>systemd-timedated</command> reads
|
---|
| 195 | <filename>/etc/adjtime</filename>, and depending on the contents of the file,
|
---|
| 196 | it sets the clock to either UTC or local time. Create the
|
---|
| 197 | <filename>/etc/adjtime</filename> file with the following contents <emphasis>if your
|
---|
| 198 | hardware clock is set to local time</emphasis>:</para>
|
---|
| 199 |
|
---|
| 200 | <screen role="nodump"><userinput>cat > /etc/adjtime << "EOF"
|
---|
| 201 | <literal>0.0 0 0.0
|
---|
| 202 | 0
|
---|
| 203 | LOCAL</literal>
|
---|
| 204 | EOF</userinput></screen>
|
---|
| 205 |
|
---|
| 206 | <para>If <filename>/etc/adjtime</filename> isn't present at first boot,
|
---|
| 207 | <command>systemd-timedated</command> will assume that hardware clock is
|
---|
| 208 | set to UTC and create the file using that setting.</para>
|
---|
| 209 |
|
---|
| 210 | <para>You can also use the <command>timedatectl</command> utility to tell
|
---|
| 211 | <command>systemd-timedated</command> if your hardware clock is set to
|
---|
| 212 | UTC or local time:</para>
|
---|
| 213 |
|
---|
| 214 | <screen role="nodump"><userinput>timedatectl set-local-rtc 1</userinput></screen>
|
---|
| 215 |
|
---|
| 216 | <para><command>timedatectl</command> can also be used to change system time and
|
---|
| 217 | time zone.</para>
|
---|
| 218 |
|
---|
| 219 | <para>To change your current system time, issue:</para>
|
---|
| 220 |
|
---|
| 221 | <screen role="nodump"><userinput>timedatectl set-time YYYY:MM:DD HH:MM:SS</userinput></screen>
|
---|
| 222 |
|
---|
| 223 | <para>Hardware clock will also be updated accordingly.</para>
|
---|
| 224 |
|
---|
| 225 | <para>To change your current time zone, issue:</para>
|
---|
| 226 |
|
---|
| 227 | <screen role="nodump"><userinput>timedatectl set-timezone TIMEZONE</userinput></screen>
|
---|
| 228 |
|
---|
| 229 | <para>You can get list of available time zones by running:</para>
|
---|
| 230 |
|
---|
| 231 | <screen role="nodump"><userinput>timedatectl list-timezones</userinput></screen>
|
---|
| 232 |
|
---|
| 233 | <note><para>The <command>timedatectl</command> command can
|
---|
| 234 | be used only on a system booted with Systemd.</para></note>
|
---|
| 235 |
|
---|
| 236 | </sect2>
|
---|
| 237 |
|
---|
[c729bc9] | 238 | <sect2>
|
---|
| 239 | <title>Debugging the Boot Sequence</title>
|
---|
| 240 |
|
---|
| 241 | <para>There are several commands that can be used to help debug the systemd
|
---|
| 242 | boot process. Here are some examples:</para>
|
---|
| 243 |
|
---|
| 244 | <itemizedlist>
|
---|
| 245 | <listitem><para>systemctl list-units -t service [--all]</para></listitem>
|
---|
| 246 | <listitem><para>systemctl list-units -t target [--all]</para></listitem>
|
---|
| 247 | <listitem><para>systemctl show -p Wants multi-user.target</para></listitem>
|
---|
| 248 | <listitem><para>systemctl status sshd.service</para></listitem>
|
---|
| 249 | </itemizedlist>
|
---|
| 250 |
|
---|
| 251 | </sect2>
|
---|
| 252 |
|
---|
| 253 | </sect1>
|
---|