aboutsummaryrefslogtreecommitdiffstats
path: root/chapter07
diff options
context:
space:
mode:
authorBruce Dubbs <bdubbs@linuxfromscratch.org>2016-05-24 21:24:59 +0000
committerBruce Dubbs <bdubbs@linuxfromscratch.org>2016-05-24 21:24:59 +0000
commit1118b1757d67c5e7deb4c9e4b864b00f9d8a8b0c (patch)
treecf1411feb617804f8468b98348eff7f377b2ee07 /chapter07
parent11ebea60aa77e5a8b24f08971e153d05c12a4406 (diff)
Create branches/merge in svn repo fo rtesting of merged LFS books
git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/merge@11073 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
Diffstat (limited to 'chapter07')
-rw-r--r--chapter07/chapter07d.xml25
-rw-r--r--chapter07/clock.xml104
-rw-r--r--chapter07/consoled.xml137
-rw-r--r--chapter07/etcshellsd.xml48
-rw-r--r--chapter07/introductiond.xml73
-rw-r--r--chapter07/locale.xml152
-rw-r--r--chapter07/networkd.xml270
-rw-r--r--chapter07/symlinksd.xml63
-rw-r--r--chapter07/sysd-custom.xml253
-rw-r--r--chapter07/systemd-custom.xml175
-rw-r--r--chapter07/udevd.xml337
11 files changed, 1384 insertions, 253 deletions
diff --git a/chapter07/chapter07d.xml b/chapter07/chapter07d.xml
new file mode 100644
index 000000000..a2c30abe0
--- /dev/null
+++ b/chapter07/chapter07d.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE chapter 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;
+]>
+
+<chapter id="chapter-bootscripts" xreflabel="Chapter 7">
+ <?dbhtml dir="chapter07"?>
+ <?dbhtml filename="chapter07.html"?>
+
+ <title>Basic System Configuration</title>
+
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="introductiond.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="networkd.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="udevd.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="symlinksd.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="clock.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="consoled.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="locale.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="inputrc.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="etcshellsd.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="systemd-custom.xml"/>
+
+</chapter>
diff --git a/chapter07/clock.xml b/chapter07/clock.xml
new file mode 100644
index 000000000..0dbdc7eaf
--- /dev/null
+++ b/chapter07/clock.xml
@@ -0,0 +1,104 @@
+<?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-clock">
+ <?dbhtml filename="clock.html"?>
+
+ <title>Configuring the system clock</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>If you cannot remember whether or not the hardware clock is set to UTC,
+ find out by running the <userinput>hwclock --localtime --show</userinput>
+ command. This will display what the current time is according to the hardware
+ clock. If this time matches whatever your watch says, then the hardware clock is
+ set to local time. If the output from <command>hwclock</command> is not local
+ time, chances are it is set to UTC time. Verify this by adding or subtracting
+ the proper amount of hours for the timezone to the time shown by
+ <command>hwclock</command>. For example, if you are currently in the MST
+ timezone, which is also known as GMT -0700, add seven hours to the local
+ time.</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.</para>
+
+ <para>Create the <filename>/etc/adjtime</filename> file with the following contents
+ if your hardware clock is set to local time:</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 adjust the file according to that.</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>Please note that <command>timedatectl</command> command can
+ be used only on a system booted with systemd.</para></note>
+
+ <sect2>
+ <title>Network Time Synchronization</title>
+
+ <para>Starting with version 213, systemd ships a daemon called
+ <command>systemd-timesyncd</command> which can be used to
+ synchronize the system time with remote NTP servers.</para>
+
+ <para>The daemon is not intended as a replacement for the well
+ established NTP daemon, but as a client only implementation
+ of the SNTP protocol which can be used for less advanced
+ tasks and on resource limited systems.</para>
+
+ <para>Starting with systemd version 216, the
+ <command>systemd-timesyncd</command> daemon is enabled by
+ default. If you want to disable it, issue the following
+ command:</para>
+
+<screen role="nodump"><userinput>systemctl disable systemd-timesyncd</userinput></screen>
+
+ <para>The <filename>/etc/systemd/timesyncd.conf</filename> file
+ can be used to change the NTP servers that
+ <command>systemd-timesyncd</command> synchronizes with.</para>
+
+ <para>Please note that when system clock is set to Local Time,
+ <command>systemd-timesyncd</command> won't update hardware
+ clock.</para>
+
+ </sect2>
+
+</sect1>
diff --git a/chapter07/consoled.xml b/chapter07/consoled.xml
new file mode 100644
index 000000000..ea1062c23
--- /dev/null
+++ b/chapter07/consoled.xml
@@ -0,0 +1,137 @@
+<?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-console">
+ <?dbhtml filename="console.html"?>
+
+ <title>Configuring the Linux Console</title>
+
+ <indexterm zone="ch-scripts-console">
+ <primary sortas="d-console">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>
+
+ <para>You can also use <command>localectl</command> utility with the
+ corresponding parameters to change X11 keyboard layout, model, variant
+ and options:</para>
+
+<screen role="nodump"><userinput>localectl set-x11-keymap LAYOUT [MODEL] [VARIANT] [OPTIONS]</userinput></screen>
+
+ <para>To list possible values for <command>localectl set-x11-keymap</command>
+ parameters, run <command>localectl</command> with parameters listed below:
+ </para>
+
+ <variablelist>
+
+ <varlistentry>
+ <term>list-x11-keymap-models</term>
+ <listitem>
+ <para>Show known X11 keyboard mapping models.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>list-x11-keymap-layouts</term>
+ <listitem>
+ <para>Show known X11 keyboard mapping layouts.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>list-x11-keymap-variants</term>
+ <listitem>
+ <para>Show known X11 keyboard mapping variants.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>list-x11-keymap-options</term>
+ <listitem>
+ <para>Show known X11 keyboard mapping options.</para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+
+ <note><para>Using any of the parameters listed above requires
+ XKeyboard Config package from BLFS.</para></note>
+
+</sect1>
diff --git a/chapter07/etcshellsd.xml b/chapter07/etcshellsd.xml
new file mode 100644
index 000000000..ddccafa9b
--- /dev/null
+++ b/chapter07/etcshellsd.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE part 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-config-shells" xreflabel="Creating the /etc/shells File">
+ <?dbhtml filename="etcshells.html"?>
+
+ <sect1info>
+ <othername>$LastChangedBy$</othername>
+ <date>$Date$</date>
+ </sect1info>
+
+ <title>Creating the /etc/shells File</title>
+
+ <indexterm zone="ch-config-shells">
+ <primary sortas="e-etc-shells">/etc/shells</primary>
+ </indexterm>
+
+ <para>The <filename>shells</filename> file contains a list of
+ login shells on the system. Applications use this file to determine
+ whether a shell is valid. For each shell a single line should be
+ present, consisting of the shell's path, relative to the root of the
+ directory structure (/).</para>
+
+ <para>For example, this file is consulted by <command>chsh</command>
+ to determine whether an unprivileged user may change the login shell for her
+ own account. If the command name is not listed, the user will be denied of
+ change.</para>
+
+ <para>It is a requirement for applications such as
+ <application>GDM</application> which does not populate the
+ face browser if it can't find <filename>/etc/shells</filename>, or
+ FTP daemons which traditionally disallow access to users
+ with shells not included in this file.</para>
+
+<screen role="root"><userinput>cat &gt; /etc/shells &lt;&lt; "EOF"
+<literal># Begin /etc/shells
+
+/bin/sh
+/bin/bash
+
+# End /etc/shells</literal>
+EOF</userinput></screen>
+
+</sect1>
diff --git a/chapter07/introductiond.xml b/chapter07/introductiond.xml
new file mode 100644
index 000000000..59d618b8b
--- /dev/null
+++ b/chapter07/introductiond.xml
@@ -0,0 +1,73 @@
+<?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-introduction">
+ <?dbhtml filename="introduction.html"?>
+
+ <title>Introduction</title>
+
+ <para>This chapter discusses configuration files and systemd services.
+ First, the general configuration files needed to set up networking are
+ presented.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para><xref linkend="ch-scripts-network" role="."/></para>
+ </listitem>
+ <listitem>
+ <para><xref linkend="ch-scripts-hostname" role="."/></para>
+ </listitem>
+ <listitem>
+ <para><xref linkend="ch-scripts-hosts" role="."/></para>
+ </listitem>
+ </itemizedlist>
+
+ <para>Second, issues that affect the proper setup of devices are
+ discussed.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para><xref linkend="ch-scripts-udev" role="."/></para>
+ </listitem>
+ <listitem>
+ <para><xref linkend="ch-scripts-symlinks" role="."/></para>
+ </listitem>
+ </itemizedlist>
+
+ <para>Third, configuring the system clock and keyboard layout.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para><xref linkend="ch-scripts-clock" role="."/></para>
+ </listitem>
+ <listitem>
+ <para><xref linkend="ch-scripts-console" role="."/></para>
+ </listitem>
+ </itemizedlist>
+
+
+ <para>Fourth, a brief introduction to the scripts and configuration
+ files used when the user logs into the system.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para><xref linkend="ch-scripts-locale" role="."/></para>
+ </listitem>
+ <listitem>
+ <para><xref linkend="ch-scripts-inputrc" role="."/></para>
+ </listitem>
+ </itemizedlist>
+
+ <para>And finally, configuring the systemd behavior.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para><xref linkend="ch-scripts-systemd-custom" role="."/></para>
+ </listitem>
+ </itemizedlist>
+
+</sect1>
diff --git a/chapter07/locale.xml b/chapter07/locale.xml
new file mode 100644
index 000000000..76dbb7251
--- /dev/null
+++ b/chapter07/locale.xml
@@ -0,0 +1,152 @@
+<?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-locale">
+ <?dbhtml filename="locale.html"?>
+
+ <title>Configuring the System Locale</title>
+
+ <indexterm zone="ch-scripts-locale">
+ <primary sortas="e-etc-locale-conf">/etc/locale.conf</primary>
+ </indexterm>
+
+ <para>The <filename>/etc/locale.conf</filename> below sets some
+ environment variables necessary for native language support. Setting
+ them properly results in:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>The output of programs translated into the native language</para>
+ </listitem>
+ <listitem>
+ <para>Correct classification of characters into letters, digits and other
+ classes. This is necessary for <command>bash</command> to properly accept
+ non-ASCII characters in command lines in non-English locales</para>
+ </listitem>
+ <listitem>
+ <para>The correct alphabetical sorting order for the country</para>
+ </listitem>
+ <listitem>
+ <para>Appropriate default paper size</para>
+ </listitem>
+ <listitem>
+ <para>Correct formatting of monetary, time, and date values</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>Replace <replaceable>&lt;ll&gt;</replaceable> below with the two-letter code
+ for the desired language (e.g., <quote>en</quote>) and
+ <replaceable>&lt;CC&gt;</replaceable> with the two-letter code for the appropriate
+ country (e.g., <quote>GB</quote>). <replaceable>&lt;charmap&gt;</replaceable> should
+ be replaced with the canonical charmap for your chosen locale. Optional
+ modifiers such as <quote>@euro</quote> may also be present.</para>
+
+ <para>The list of all locales supported by Glibc can be obtained by running
+ the following command:</para>
+
+<screen role="nodump"><userinput>locale -a</userinput></screen>
+
+ <para>Charmaps can have a number of aliases, e.g., <quote>ISO-8859-1</quote>
+ is also referred to as <quote>iso8859-1</quote> and <quote>iso88591</quote>.
+ Some applications cannot handle the various synonyms correctly (e.g., require
+ that <quote>UTF-8</quote> is written as <quote>UTF-8</quote>, not
+ <quote>utf8</quote>), so it is safest in most
+ cases to choose the canonical name for a particular locale. To determine
+ the canonical name, run the following command, where <replaceable>&lt;locale
+ name&gt;</replaceable> is the output given by <command>locale -a</command> for
+ your preferred locale (<quote>en_GB.iso88591</quote> in our example).</para>
+
+<screen role="nodump"><userinput>LC_ALL=<replaceable>&lt;locale name&gt;</replaceable> locale charmap</userinput></screen>
+
+ <para>For the <quote>en_GB.iso88591</quote> locale, the above command
+ will print:</para>
+
+<screen><computeroutput>ISO-8859-1</computeroutput></screen>
+
+ <para>This results in a final locale setting of <quote>en_GB.ISO-8859-1</quote>.
+ It is important that the locale found using the heuristic above is tested prior
+ to it being added to the Bash startup files:</para>
+
+<screen role="nodump"><userinput>LC_ALL=&lt;locale name&gt; locale language
+LC_ALL=&lt;locale name&gt; locale charmap
+LC_ALL=&lt;locale name&gt; locale int_curr_symbol
+LC_ALL=&lt;locale name&gt; locale int_prefix</userinput></screen>
+
+ <para>The above commands should print the language name, the character
+ encoding used by the locale, the local currency, and the prefix to dial
+ before the telephone number in order to get into the country. If any of the
+ commands above fail with a message similar to the one shown below, this means
+ that your locale was either not installed in Chapter 6 or is not supported by
+ the default installation of Glibc.</para>
+
+<screen><computeroutput>locale: Cannot set LC_* to default locale: No such file or directory</computeroutput></screen>
+
+ <para>If this happens, you should either install the desired locale using the
+ <command>localedef</command> command, or consider choosing a different locale.
+ Further instructions assume that there are no such error messages from
+ Glibc.</para>
+
+ <!-- FIXME: the xlib example will became obsolete real soon -->
+ <para>Some packages beyond LFS may also lack support for your chosen locale. One
+ example is the X library (part of the X Window System), which outputs the
+ following error message if the locale does not exactly match one of the character
+ map names in its internal files:</para>
+
+<screen><computeroutput>Warning: locale not supported by Xlib, locale set to C</computeroutput></screen>
+
+ <para>In several cases Xlib expects that the character map will be listed in
+ uppercase notation with canonical dashes. For instance, "ISO-8859-1" rather
+ than "iso88591". It is also possible to find an appropriate specification by
+ removing the charmap part of the locale specification. This can be checked
+ by running the <command>locale charmap</command> command in both locales.
+ For example, one would have to change "de_DE.ISO-8859-15@euro" to
+ "de_DE@euro" in order to get this locale recognized by Xlib.</para>
+
+ <para>Other packages can also function incorrectly (but may not necessarily
+ display any error messages) if the locale name does not meet their expectations.
+ In those cases, investigating how other Linux distributions support your locale
+ might provide some useful information.</para>
+
+ <para>Once the proper locale settings have been determined, create the
+ <filename>/etc/locale.conf</filename> file:</para>
+
+<screen><userinput>cat &gt; /etc/locale.conf &lt;&lt; "EOF"
+<literal>LANG=<replaceable>&lt;ll&gt;_&lt;CC&gt;.&lt;charmap&gt;&lt;@modifiers&gt;</replaceable></literal>
+EOF</userinput></screen>
+
+ <para>Note that you can modify <filename>/etc/locale.conf</filename> with
+ systemd <command>localectl</command> utility. To use <command>localectl</command>
+ for the example above, run:</para>
+
+<screen role="nodump"><userinput>localectl set-locale LANG="<replaceable>&lt;ll&gt;_&lt;CC&gt;.&lt;charmap&gt;&lt;@modifiers&gt;</replaceable>"</userinput></screen>
+
+ <para>You can also specify other language specific environment variables such
+ as <envar>LANG</envar>, <envar>LC_CTYPE</envar>, <envar>LC_NUMERIC</envar> or
+ any other environment variable from <command>locale</command> output. Just
+ separate them with a space. An example where <envar>LANG</envar> is set as
+ en_US.UTF-8 but <envar>LC_CTYPE</envar> is set as just en_US is:</para>
+
+<screen role="nodump"><userinput>localectl set-locale LANG="en_US.UTF-8" LC_CTYPE="en_US"</userinput></screen>
+
+ <note><para>Please note that <command>localectl</command> command can
+ be used only on a system booted with systemd.</para></note>
+
+ <para>The <quote>C</quote> (default) and <quote>en_US</quote> (the recommended
+ one for United States English users) locales are different. <quote>C</quote>
+ uses the US-ASCII 7-bit character set, and treats bytes with the high bit set
+ as invalid characters. That's why, e.g., the <command>ls</command> command
+ substitutes them with question marks in that locale. Also, an attempt to send
+ mail with such characters from Mutt or Pine results in non-RFC-conforming
+ messages being sent (the charset in the outgoing mail is indicated as <quote>unknown
+ 8-bit</quote>). So you can use the <quote>C</quote> locale only if you are sure that
+ you will never need 8-bit characters.</para>
+
+ <para>UTF-8 based locales are not supported well by many programs.
+ Work is in progress to document and, if possible, fix such problems, see
+ <ulink url="&blfs-book;introduction/locale-issues.html"/>.</para>
+
+</sect1>
diff --git a/chapter07/networkd.xml b/chapter07/networkd.xml
new file mode 100644
index 000000000..86dcb3e53
--- /dev/null
+++ b/chapter07/networkd.xml
@@ -0,0 +1,270 @@
+<?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-network">
+ <?dbhtml filename="network.html"?>
+
+ <title>General Network Configuration</title>
+
+ <indexterm zone="ch-scripts-network">
+ <primary sortas="d-network">network</primary>
+ <secondary>configuring</secondary></indexterm>
+
+ <para>This section only applies if a network card is to be
+ configured.</para>
+
+ <sect2>
+ <title>Network Interface Configuration Files</title>
+
+ <para>Starting with version 209, systemd ships a network configuration
+ daemon called <command>systemd-networkd</command> which can be used for
+ basic network configuration. Additionally, since version 213, DNS name
+ resolution can be handled by <command>systemd-resolved</command> in place
+ of a static <filename>/etc/resolv.conf</filename> file. Both services are
+ enabled by defualt, and absolutely should not be disabled.</para>
+
+ <para>Configuration files for <command>systemd-networkd</command> (and
+ <command>systemd-resolved</command>) can be placed in
+ <filename class="directory">/usr/lib/systemd/network</filename>
+ or <filename class="directory">/etc/systemd/network</filename>. Files in
+ <filename class="directory">/etc/systemd/network</filename> have a
+ higher priority than the ones in
+ <filename class="directory">/usr/lib/systemd/network</filename>.
+ There are three types of configuration files:
+ <filename class="extension">.link</filename>,
+ <filename class="extension">.netdev</filename> and
+ <filename class="extension">.network</filename> files. For detailed
+ descriptions and example contents of these configuration files, consult
+ the <filename>systemd-link(5)</filename>,
+ <filename>systemd-netdev(5)</filename> and
+ <filename>systemd-network(5)</filename> manual pages.</para>
+
+ <note><para>Udev may assign network card interface names based
+ on system physical characteristics such as enp2s1. If you are
+ not sure what your interface name is, you can always run
+ <command>ip link</command> after you have booted your system.
+ </para></note>
+
+ <sect3 id="systemd-networkd-static">
+ <title>Static IP Configuration</title>
+
+ <para>The command below creates a basic configuration file for a
+ Static IP setup (using both systemd-networkd and
+ systemd-resolved):</para>
+
+<screen role="nodump"><userinput>cat &gt; /etc/systemd/network/10-eth0-static.network &lt;&lt; "EOF"
+<literal>[Match]
+Name=eth0
+
+[Network]
+Address=192.168.0.2/24
+Gateway=192.168.0.1
+DNS=192.168.0.1
+Domains=<replaceable>&lt;Your Domain Name&gt;</replaceable></literal>
+EOF</userinput></screen>
+
+ <para>Multiple DNS entries can be added if you have more than one DNS
+ server. Do not include DNS or Domains entries if you intend to use a
+ static <filename>/etc/reslov.conf</filename> file.</para>
+
+ </sect3>
+
+ <sect3 id="systemd-networkd-dhcp">
+ <title>DHCP Configuration</title>
+
+ <para>The command below creates a basic configuration file for an IPv4
+ DHCP setup:</para>
+
+<screen role="nodump"><userinput>cat &gt; /etc/systemd/network/10-eth0-dhcp.network &lt;&lt; "EOF"
+<literal>[Match]
+Name=eth0
+
+[Network]
+DHCP=ipv4
+
+[DHCP]
+UseDomains=true</literal>
+EOF</userinput></screen>
+
+ </sect3>
+
+ </sect2>
+
+ <sect2 id="resolv.conf">
+ <title>Creating the /etc/resolv.conf File</title>
+
+ <indexterm zone="resolv.conf">
+ <primary sortas="e-/etc/resolv.conf">/etc/resolv.conf</primary>
+ </indexterm>
+
+ <para>If the system is going to be connected to the Internet, it will
+ need some means of Domain Name Service (DNS) name resolution to
+ resolve Internet domain names to IP addresses, and vice versa. This is
+ best achieved by placing the IP address of the DNS server, available
+ from the ISP or network administrator, into
+ <filename>/etc/resolv.conf</filename>.</para>
+
+ <sect3 id="resolv-conf-systemd-resoloved">
+ <title>systemd-resolved Configuration</title>
+
+ <note><para>If using another means to configure your network
+ interfaces (ex: ppp, network-manager, etc.), or if using any type of
+ local resolver (ex: bind, dnsmasq, etc.), or any other software that
+ generates an <filename>/etc/resolv.conf</filename> (ex: resolvconf), the
+ <command>systemd-resolved</command> service should not be
+ used.</para></note>
+
+ <para>When using <command>systemd-resolved</command> for DNS
+ configuration, it is responsible for creating the
+ <filename>/etc/resolv.conf</filename> file. Since version 226, the
+ symlink for <filename>/etc/resolv.conf</filename> is created by systemd
+ when needed, so no further configuration is necessary.</para>
+
+ </sect3>
+
+ <sect3 id="resolv-conf-static">
+ <title>Static resolv.conf Configuration</title>
+
+ <para>If a static <filename>/etc/resolv.conf</filename> is desired,
+ create it by running the following command:</para>
+
+<screen role="nodump"><userinput>cat &gt; /etc/resolv.conf &lt;&lt; "EOF"
+<literal># Begin /etc/resolv.conf
+
+domain <replaceable>&lt;Your Domain Name&gt;</replaceable>
+nameserver <replaceable>&lt;IP address of your primary nameserver&gt;</replaceable>
+nameserver <replaceable>&lt;IP address of your secondary nameserver&gt;</replaceable>
+
+# End /etc/resolv.conf</literal>
+EOF</userinput></screen>
+
+ <para>The <varname>domain</varname> statement can be omitted
+ or replaced with a <varname>search</varname> statement. See the man page
+ for resolv.conf for more details.</para>
+
+ <para>Replace
+ <replaceable>&lt;IP address of the nameserver&gt;</replaceable>
+ with the IP address of the DNS most appropriate for the setup. There will
+ often be more than one entry (requirements demand secondary servers for
+ fallback capability). If you only need or want one DNS server, remove the
+ second <emphasis>nameserver</emphasis> line from the file. The IP address
+ may also be a router on the local network.</para>
+
+ <note><para>The Google Public IPv4 DNS addresses are
+ <parameter>8.8.8.8</parameter> and <parameter>8.8.4.4</parameter>
+ for IPv4, and <parameter>2001:4860:4860::8888</parameter> and
+ <parameter>2001:4860:4860::8844</parameter> for IPv6.</para></note>
+
+ </sect3>
+
+ </sect2>
+
+ <sect2 id="ch-scripts-hostname">
+ <title>Configuring the system hostname</title>
+
+ <indexterm zone="ch-scripts-hostname">
+ <primary sortas="d-hostname">hostname</primary>
+ <secondary>configuring</secondary>
+ </indexterm>
+
+ <para>During the boot process, the file <filename>/etc/hostname</filename>
+ is used for establishing the system's hostname.</para>
+
+ <para>Create the <filename>/etc/hostname</filename> file and enter a
+ hostname by running:</para>
+
+<screen><userinput>echo "<replaceable>&lt;lfs&gt;</replaceable>" &gt; /etc/hostname</userinput></screen>
+
+ <para><replaceable>&lt;lfs&gt;</replaceable> needs to be replaced with the
+ name given to the computer. Do not enter the Fully Qualified Domain Name
+ (FQDN) here. That information is put in the
+ <filename>/etc/hosts</filename> file.</para>
+
+ </sect2>
+
+ <sect2 id="ch-scripts-hosts">
+ <title>Customizing the /etc/hosts File</title>
+
+ <indexterm zone="ch-scripts-hosts">
+ <primary sortas="e-/etc/hosts">/etc/hosts</primary>
+ </indexterm>
+
+ <indexterm zone="ch-scripts-hosts">
+ <primary sortas="d-localnet">localnet</primary>
+ <secondary>/etc/hosts</secondary>
+ </indexterm>
+
+ <indexterm zone="ch-scripts-hosts">
+ <primary sortas="d-network">network</primary>
+ <secondary>/etc/hosts</secondary>
+ </indexterm>
+
+ <para>Decide on a fully-qualified domain name (FQDN), and possible aliases
+ for use in the <filename>/etc/hosts</filename> file. If using static
+ addresses, you'll also need to decide on an IP address. The syntax
+ for a hosts file entry is:</para>
+
+<screen><literal>IP_address myhost.example.org aliases</literal></screen>
+
+ <para>Unless the computer is to be visible to the Internet (i.e., there is
+ a registered domain and a valid block of assigned IP addresses&mdash;most
+ users do not have this), make sure that the IP address is in the private
+ network IP address range. Valid ranges are:</para>
+
+<screen><literal>Private Network Address Range Normal Prefix
+10.0.0.1 - 10.255.255.254 8
+172.x.0.1 - 172.x.255.254 16
+192.168.y.1 - 192.168.y.254 24</literal></screen>
+
+ <para>x can be any number in the range 16-31. y can be any number in the
+ range 0-255.</para>
+
+ <para>A valid private IP address could be 192.168.1.1. A valid FQDN for
+ this IP could be lfs.example.org.</para>
+
+ <para>Even if not using a network card, a valid FQDN is still required.
+ This is necessary for certain programs to operate correctly.</para>
+
+ <para>If using DHCP, DHCPv6, IPv6 Autoconfiguration, or if a network card
+ is not going to be configured, create the <filename>/etc/hosts</filename>
+ file by running the following command:</para>
+
+<screen><userinput>cat &gt; /etc/hosts &lt;&lt; "EOF"
+<literal># Begin /etc/hosts
+
+127.0.0.1 <replaceable>&lt;HOSTNAME.example.org&gt;</replaceable> <replaceable>&lt;HOSTNAME&gt;</replaceable> localhost <replaceable>[alias1] [alias2] ...</replaceable>
+::1 <replaceable>&lt;HOSTNAME.example.org&gt;</replaceable> <replaceable>&lt;HOSTNAME&gt;</replaceable> localhost <replaceable>[alias1] [alias2] ...</replaceable>
+
+# End /etc/hosts</literal>
+EOF</userinput></screen>
+
+ <para>The ::1 entry is the IPv6 counterpart of 127.0.0.1 and represents
+the IPv6 loopback interface.</para>
+
+ <para>If ussing a staic address, create the <filename>/etc/hosts</filename>
+ file by running this command instead:</para>
+
+<screen role="nodump"><userinput>cat &gt; /etc/hosts &lt;&lt; "EOF"
+<literal># Begin /etc/hosts
+
+127.0.0.1 localhost
+::1 localhost
+<replaceable>&lt;192.168.0.2&gt;</replaceable> <replaceable>&lt;HOSTNAME.example.org&gt;</replaceable> <replaceable>&lt;HOSTNAME&gt;</replaceable> <replaceable>[alias1] [alias2] ...</replaceable>
+
+# End /etc/hosts</literal>
+EOF</userinput></screen>
+
+ <para>The <replaceable>&lt;192.168.0.2&gt;</replaceable>,
+ <replaceable>&lt;HOSTNAME.example.org&gt;</replaceable>, and
+ <replaceable>&lt;HOSTNAME&gt;</replaceable> values need to be
+ changed for specific uses or requirements (if assigned an IP address by a
+ network/system administrator and the machine will be connected to an
+ existing network). The optional alias name(s) can be omitted.</para>
+
+ </sect2>
+
+</sect1>
diff --git a/chapter07/symlinksd.xml b/chapter07/symlinksd.xml
new file mode 100644
index 000000000..354ae319a
--- /dev/null
+++ b/chapter07/symlinksd.xml
@@ -0,0 +1,63 @@
+<?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-symlinks">
+ <?dbhtml filename="symlinks.html"?>
+
+ <title>Creating Custom Symlinks to Devices</title>
+
+ <sect2>
+ <title>Dealing with duplicate devices</title>
+
+ <para>As explained in <xref linkend="ch-scripts-udev"/>, the order in
+ which devices with the same function appear in
+ <filename class="directory">/dev</filename> is essentially random.
+ E.g., if you have a USB web camera and a TV tuner, sometimes
+ <filename>/dev/video0</filename> refers to the camera and
+ <filename>/dev/video1</filename> refers to the tuner, and sometimes
+ after a reboot the order changes to the opposite one.
+ For all classes of hardware except sound cards and network cards, this is
+ fixable by creating udev rules for custom persistent symlinks.
+ The case of network cards is covered separately in
+ <xref linkend="ch-scripts-network"/>, and sound card configuration can
+ be found in <ulink url="&blfs-book;postlfs/devices.html">BLFS</ulink>.</para>
+
+ <para>For each of your devices that is likely to have this problem
+ (even if the problem doesn't exist in your current Linux distribution),
+ find the corresponding directory under
+ <filename class="directory">/sys/class</filename> or
+ <filename class="directory">/sys/block</filename>.
+ For video devices, this may be
+ <filename
+ class="directory">/sys/class/video4linux/video<replaceable>X</replaceable></filename>.
+ Figure out the attributes that identify the device uniquely (usually,
+ vendor and product IDs and/or serial numbers work):</para>
+
+<screen role="nodump"><userinput>udevadm info -a -p /sys/class/video4linux/video0</userinput></screen>
+
+ <para>Then write rules that create the symlinks, e.g.:</para>
+
+<screen role="nodump"><userinput>cat &gt; /etc/udev/rules.d/83-duplicate_devs.rules &lt;&lt; "EOF"
+<literal>
+# Persistent symlinks for webcam and tuner
+KERNEL=="video*", ATTRS{idProduct}=="1910", ATTRS{idVendor}=="0d81", \
+ SYMLINK+="webcam"
+KERNEL=="video*", ATTRS{device}=="0x036f", ATTRS{vendor}=="0x109e", \
+ SYMLINK+="tvtuner"
+</literal>
+EOF</userinput></screen>
+
+ <para>The result is that <filename>/dev/video0</filename> and
+ <filename>/dev/video1</filename> devices still refer randomly to the tuner
+ and the web camera (and thus should never be used directly), but there are
+ symlinks <filename>/dev/tvtuner</filename> and
+ <filename>/dev/webcam</filename> that always point to the correct
+ device.</para>
+
+ </sect2>
+
+</sect1>
diff --git a/chapter07/sysd-custom.xml b/chapter07/sysd-custom.xml
deleted file mode 100644
index e5872ece9..000000000
--- a/chapter07/sysd-custom.xml
+++ /dev/null
@@ -1,253 +0,0 @@
-<?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>
diff --git a/chapter07/systemd-custom.xml b/chapter07/systemd-custom.xml
new file mode 100644
index 000000000..0c8ca75b9
--- /dev/null
+++ b/chapter07/systemd-custom.xml
@@ -0,0 +1,175 @@
+<?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-systemd-custom">
+ <?dbhtml filename="systemd-custom.html"?>
+
+ <title>Systemd Usage and Configuration</title>
+
+ <indexterm zone="ch-scripts-systemd-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 options to control basic systemd 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 logging settings.
+ See <filename>systemd-system.conf(5)</filename> manual page for details on
+ each configuration option.</para>
+
+ </sect2>
+
+ <sect2>
+ <title>Disabling Screen Clearing at Boot Time</title>
+
+ <para>The normal behavior for systemd is to clear the screen at
+ the end of the boot sequence. If desired, this behavior may be
+ changed by running the following command:</para>
+
+<screen role="nodump"><userinput>mkdir -pv /etc/systemd/system/getty@tty1.service.d
+
+cat &gt; /etc/systemd/system/getty@tty1.service.d/noclear.conf &lt;&lt; EOF
+<literal>[Service]
+TTYVTDisallocate=no</literal>
+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 -sfv /dev/null /etc/systemd/system/tmp.mount</userinput></screen>
+
+ <para>This is not necessary if there is a separate partition for
+ <filename class="directory">/tmp</filename> 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 class="directory">/etc/tmpfiles.d</filename>. Files in
+ <filename class="directory">/etc/tmpfiles.d</filename> override
+ files with the same name in
+ <filename class="directory">/usr/lib/tmpfiles.d</filename>. See
+ <filename>tmpfiles.d(5)</filename> manual page for file format
+ details.</para>
+
+ </sect2>
+
+ <sect2>
+ <title>Overriding Default Services Behavior</title>
+
+ <para>A systemd service contents can be overriden by creating a directory
+ and a configuration file in <filename
+ class="directory">/etc/systemd/system</filename>. For example:</para>
+
+<screen role="nodump"><userinput>mkdir -pv /etc/systemd/system/foobar.service.d
+
+cat > /etc/systemd/system/foobar.service.d/foobar.conf &lt;&lt; EOF
+<literal>[Service]
+Restart=always
+RestartSec=30</literal>
+EOF</userinput></screen>
+
+ <para>See <filename>systemd.unit(5)</filename> manual page for more
+ information. After creating the configuration file, run
+ <userinput>systemctl daemon-reload</userinput> and <userinput>systemctl
+ restart foobar</userinput> to activate the changes to a service.</para>
+
+ </sect2>
+
+ <sect2>
+ <title>Debugging the Boot Sequence</title>
+
+ <para>Rather than plain shell scripts used in SysVinit or BSD style init
+ systems, systemd uses a unified format for different type of startup
+ files (or units). The command <command>systemctl</command> is used to
+ enable, disable, controll state, and obtain status of unit files. Here
+ are some examples of frequently used commands:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para><command>systemctl list-units -t <replaceable>&lt;service&gt;</replaceable> [--all]</command>:
+ lists loaded unit files of type service.</para>
+ </listitem>
+ <listitem>
+ <para><command>systemctl list-units -t <replaceable>&lt;target&gt;</replaceable> [--all]</command>:
+ lists loaded unit files of type target.</para>
+ </listitem>
+ <listitem>
+ <para><command>systemctl show -p Wants <replaceable>&lt;multi-user.target&gt;</replaceable></command>:
+ shows all units that depend on the multi-user target. Targets are
+ special unit files that are anogalous to runlevels under
+ SysVinit.</para>
+ </listitem>
+ <listitem>
+ <para><command>systemctl status <replaceable>&lt;servicename.service&gt;</replaceable></command>:
+ shows the status of the servicename service. The .service extension
+ can be omitted if there are no other unit files with the same name,
+ such as .socket files (which create a listening socket that provides
+ similar functionality to inetd/xinetd).</para>
+ </listitem>
+ </itemizedlist>
+
+ </sect2>
+
+ <sect2>
+ <title>Working with the Systemd Journal</title>
+
+ <para>Logging on a system booted with systemd is handled by
+ systemd-journald (default), rather than a typical unix syslog daemon.
+ systemd-journald write log entries to a binary file format, rather than
+ a plain text log file. To assist with parsing the file, the command
+ <command>journalctl</command> is provided. Here are some examples of
+ frequently used commands:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para><command>journalctl -r</command>: shows all contents of the
+ journal in reverse chronological order.</para>
+ </listitem>
+ <listitem>
+ <para><command>journalctl -u <replaceable>UNIT</replaceable></command>:
+ shows the journal entries associated with the specified UNIT
+ file.</para>
+ </listitem>
+ <listitem>
+ <para><command>journalctl -b[=ID] -r</command>: shows the journal
+ entries since last successfull boot (or for boot ID) in reverse
+ chronological order.</para>
+ </listitem>
+ <listitem>
+ <para><command>journalctl -f</command>: povides functionality similar
+ to tail -f (follow).</para>
+ </listitem>
+ </itemizedlist>
+
+ </sect2>
+</sect1>
diff --git a/chapter07/udevd.xml b/chapter07/udevd.xml
new file mode 100644
index 000000000..548a2d2ee
--- /dev/null
+++ b/chapter07/udevd.xml
@@ -0,0 +1,337 @@
+<?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-udev">
+ <?dbhtml filename="udev.html"?>
+
+ <title>Device and Module Handling on an LFS System</title>
+
+ <indexterm zone="ch-scripts-udev">
+ <primary sortas="a-Udev">Udev</primary>
+ <secondary>usage</secondary>
+ </indexterm>
+
+ <para>In <xref linkend="chapter-building-system"/>, we installed Udev
+ from the systemd source package. Before we go into the details regarding
+ how this works, a brief history of previous methods of handling devices
+ is in order.</para>
+
+ <para>Linux systems in general traditionally use a static device creation
+ method, whereby a great many device nodes are created under <filename
+ class="directory">/dev</filename> (sometimes literally thousands of nodes),
+ regardless of whether the corresponding hardware devices actually exist. This
+ is typically done via a <command>MAKEDEV</command> script, which contains a
+ number of calls to the <command>mknod</command> program with the relevant
+ major and minor device numbers for every possible device that might exist in
+ the world.</para>
+
+ <para>Using the Udev method, only those devices which are detected by the
+ kernel get device nodes created for them. Because these device nodes will be
+ created each time the system boots, they will be stored on a <systemitem
+ class="filesystem">devtmpfs</systemitem> file system (a virtual file system
+ that resides entirely in system memory). Device nodes do not require much
+ space, so the memory that is used is negligible.</para>
+
+ <sect2>
+ <title>History</title>
+
+ <para>In February 2000, a new filesystem called <systemitem
+ class="filesystem">devfs</systemitem> was merged into the 2.3.46 kernel
+ and was made available during the 2.4 series of stable kernels. Although
+ it was present in the kernel source itself, this method of creating devices
+ dynamically never received overwhelming support from the core kernel
+ developers.</para>
+
+ <para>The main problem with the approach adopted by <systemitem
+ class="filesystem">devfs</systemitem> was the way it handled device
+ detection, creation, and naming. The latter issue, that of device node
+ naming, was perhaps the most critical. It is generally accepted that if
+ device names are allowed to be configurable, then the device naming policy
+ should be up to a system administrator, not imposed on them by any
+ particular developer(s). The <systemitem
+ class="filesystem">devfs</systemitem> file system also suffers from race
+ conditions that are inherent in its design and cannot be fixed without a
+ substantial revision to the kernel. It was marked as deprecated for a long
+ period &ndash; due to a lack of maintenance &ndash; and was finally removed
+ from the kernel in June, 2006.</para>
+
+ <para>With the development of the unstable 2.5 kernel tree, later released
+ as the 2.6 series of stable kernels, a new virtual filesystem called
+ <systemitem class="filesystem">sysfs</systemitem> came to be. The job of
+ <systemitem class="filesystem">sysfs</systemitem> is to export a view of
+ the system's hardware configuration to userspace processes. With this
+ userspace-visible representation, the possibility of seeing a userspace
+ replacement for <systemitem class="filesystem">devfs</systemitem> became
+ much more realistic.</para>
+
+ </sect2>
+
+ <sect2>
+ <title>Udev Implementation</title>
+
+ <sect3>
+ <title>Sysfs</title>
+
+ <para>The <systemitem class="filesystem">sysfs</systemitem> filesystem
+ was mentioned briefly above. One may wonder how <systemitem
+ class="filesystem">sysfs</systemitem> knows about the devices present on
+ a system and what device numbers should be used for them. Drivers that
+ have been compiled into the kernel directly register their objects with a
+ <systemitem class="filesystem">sysfs</systemitem> (devtmpfs internally)
+ as they are detected by the kernel. For drivers compiled as modules, this
+ registration will happen when the module is loaded. Once the <systemitem
+ class="filesystem">sysfs</systemitem> filesystem is mounted (on /sys),
+ data which the drivers register with <systemitem
+ class="filesystem">sysfs</systemitem> are available to userspace
+ processes and to udevd for processing (including modifications to device
+ nodes).</para>
+
+ </sect3>
+
+ <sect3>
+ <title>Device Node Creation</title>
+
+ <para>Device files are created by the kernel by the <systemitem
+ class="filesystem">devtmpfs</systemitem> filesystem. Any driver that
+ wishes to register a device node will go through <systemitem
+ class="filesystem">devtmpfs</systemitem> (via the driver core) to do it.
+ When a <systemitem class="filesystem">devtmpfs</systemitem> instance is
+ mounted on <filename class="directory">/dev</filename>, the device node
+ will initially be created with a fixed name, permissions, and
+ owner.</para>
+
+ <para>A short time later, the kernel will send a uevent to <command>
+ udevd</command>. Based on the rules specified in the files within the
+ <filename class="directory">/etc/udev/rules.d</filename>, <filename
+ class="directory">/lib/udev/rules.d</filename>, and <filename
+ class="directory">/run/udev/rules.d</filename> directories, <command>
+ udevd</command> will create additional symlinks to the device node, or
+ change its permissions, owner, or group, or modify the internal
+ <command>udevd</command> database entry (name) for that object.</para>
+
+ <para>The rules in these three directories are numbered in a similar
+ fashion to the LFS-Bootscripts package and all three directories are
+ merged together. If <command>udevd</command> can't find a rule for the
+ device it is creating, it will leave the permissions and ownership at
+ whatever <systemitem class="filesystem">devtmpfs</systemitem> used
+ initially.</para>
+
+ </sect3>
+
+ <sect3>
+ <title>Module Loading</title>
+
+ <para>Device drivers compiled as modules may have aliases built into them.
+ Aliases are visible in the output of the <command>modinfo</command>
+ program and are usually related to the bus-specific identifiers of devices
+ supported by a module. For example, the <emphasis>snd-fm801</emphasis>
+ driver supports PCI devices with vendor ID 0x1319 and device ID 0x0801,
+ and has an alias of <quote>pci:v00001319d00000801sv*sd*bc04sc01i*</quote>.
+ For most devices, the bus driver exports the alias of the driver that
+ would handle the device via <systemitem
+ class="filesystem">sysfs</systemitem>. E.g., the
+ <filename>/sys/bus/pci/devices/0000:00:0d.0/modalias</filename> file
+ might contain the string
+ <quote>pci:v00001319d00000801sv00001319sd00001319bc04sc01i00</quote>.
+ The default rules provided with Udev will cause <command>udevd</command>
+ to call out to <command>/sbin/modprobe</command> with the contents of the
+ <envar>MODALIAS</envar> uevent environment variable (which should be the
+ same as the contents of the <filename>modalias</filename> file in sysfs),
+ thus loading all modules whose aliases match this string after wildcard
+ expansion.</para>
+
+ <para>In this example, this means that, in addition to
+ <emphasis>snd-fm801</emphasis>, the obsolete (and unwanted)
+ <emphasis>forte</emphasis> driver will be loaded if it is
+ available. See below for ways in which the loading of unwanted drivers can
+ be prevented.</para>
+
+ <para>The kernel itself is also able to load modules for network
+ protocols, filesystems and NLS support on demand.</para>
+
+ </sect3>
+
+ <sect3>
+ <title>Handling Hotpluggable/Dynamic Devices</title>
+
+ <para>When you plug in a device, such as a Universal Serial Bus (USB) MP3
+ player, the kernel recognizes that the device is now connected and
+ generates a uevent. This uevent is then handled by
+ <command>udevd</command> as described above.</para>
+
+ </sect3>
+
+ </sect2>
+
+ <sect2>
+ <title>Problems with Loading Modules and Creating Devices</title>
+
+ <para>There are a few possible problems when it comes to automatically
+ creating device nodes.</para>
+
+ <sect3>
+ <title>A kernel module is not loaded automatically</title>
+
+ <para>Udev will only load a module if it has a bus-specific alias and the
+ bus driver properly exports the necessary aliases to <systemitem
+ class="filesystem">sysfs</systemitem>. In other cases, one should
+ arrange module loading by other means. With Linux-&linux-version;, Udev is
+ known to load properly-written drivers for INPUT, IDE, PCI, USB, SCSI,
+ SERIO, and FireWire devices.</para>
+
+ <para>To determine if the device driver you require has the necessary
+ support for Udev, run <command>modinfo</command> with the module name as
+ the argument. Now try locating the device directory under
+ <filename class="directory">/sys/bus</filename> and check whether there is
+ a <filename>modalias</filename> file there.</para>
+
+ <para>If the <filename>modalias</filename> file exists in <systemitem
+ class="filesystem">sysfs</systemitem>, the driver supports the device and
+ can talk to it directly, but doesn't have the alias, it is a bug in the
+ driver. Load the driver without the help from Udev and expect the issue
+ to be fixed later.</para>
+
+ <para>If there is no <filename>modalias</filename> file in the relevant
+ directory under <filename class="directory">/sys/bus</filename>, this
+ means that the kernel developers have not yet added modalias support to
+ this bus type. With Linux-&linux-version;, this is the case with ISA
+ busses. Expect this issue to be fixed in later kernel versions.</para>
+
+ <para>Udev is not intended to load <quote>wrapper</quote> drivers such as
+ <emphasis>snd-pcm-oss</emphasis> and non-hardware drivers such as
+ <emphasis>loop</emphasis> at all.</para>
+
+ </sect3>
+
+ <sect3>
+ <title>A kernel module is not loaded automatically, and Udev is not
+ intended to load it</title>
+
+ <para>If the <quote>wrapper</quote> module only enhances the functionality
+ provided by some other module (e.g., <emphasis>snd-pcm-oss</emphasis>
+ enhances the functionality of <emphasis>snd-pcm</emphasis> by making the
+ sound cards available to OSS applications), configure
+ <command>modprobe</command> to load the wrapper after Udev loads the
+ wrapped module. To do this, add a <quote>softdep</quote> line in any
+ <filename>/etc/modprobe.d/<replaceable>&lt;filename&gt;</replaceable>.conf</filename>
+ file. For example:</para>
+
+<screen role="nodump"><literal>softdep snd-pcm post: snd-pcm-oss</literal></screen>
+
+ <para>Note that the <quote>softdep</quote> command also allows
+ <literal>pre:</literal> dependencies, or a mixture of both
+ <literal>pre:</literal> and <literal>post:</literal>. See the
+ <filename>modprobe.d(5)</filename> manual page for more information
+ on <quote>softdep</quote> syntax and capabilities.</para>
+
+ <para>If the module in question is not a wrapper and is useful by itself,
+ configure the <command>modules</command> bootscript to load this
+ module on system boot. To do this, add the module name to the
+ <filename>/etc/sysconfig/modules</filename> file on a separate line.
+ This works for wrapper modules too, but is suboptimal in that case.</para>
+
+ </sect3>
+
+ <sect3>
+ <title>Udev loads some unwanted module</title>
+
+ <para>Either don't build the module, or blacklist it in a
+ <filename>/etc/modprobe.d/blacklist.conf</filename> file as done with the
+ <emphasis>forte</emphasis> module in the example below:</para>
+
+<screen role="nodump"><literal>blacklist forte</literal></screen>
+
+ <para>Blacklisted modules can still be loaded manually with the
+ explicit <command>modprobe</command> command.</para>
+
+ </sect3>
+
+ <sect3>
+ <title>Udev creates a device incorrectly, or makes a wrong symlink</title>
+
+ <para>This usually happens if a rule unexpectedly matches a device. For
+ example, a poorly-written rule can match both a SCSI disk (as desired)
+ and the corresponding SCSI generic device (incorrectly) by vendor.
+ Find the offending rule and make it more specific, with the help of the
+ <command>udevadm info</command> command.</para>
+
+ </sect3>
+
+ <sect3>
+ <title>Udev rule works unreliably</title>
+
+ <para>This may be another manifestation of the previous problem. If not,
+ and your rule uses <systemitem class="filesystem">sysfs</systemitem>
+ attributes, it may be a kernel timing issue, to be fixed in later kernels.
+ For now, you can work around it by creating a rule that waits for the used
+ <systemitem class="filesystem">sysfs</systemitem> attribute and appending
+ it to the <filename>/etc/udev/rules.d/10-wait_for_sysfs.rules</filename>
+ file (create this file if it does not exist). Please notify the LFS
+ Development list if you do so and it helps.</para>
+
+ </sect3>
+
+ <sect3>
+ <title>Udev does not create a device</title>
+
+ <para>Further text assumes that the driver is built statically into the
+ kernel or already loaded as a module, and that you have already checked
+ that Udev doesn't create a misnamed device.</para>
+
+ <para>Udev has no information needed to create a device node if a kernel
+ driver does not export its data to <systemitem
+ class="filesystem">sysfs</systemitem>.
+ This is most common with third party drivers from outside the kernel
+ tree. Create a static device node in
+ <filename>/lib/udev/devices</filename> with the appropriate major/minor
+ numbers (see the file <filename>devices.txt</filename> inside the kernel
+ documentation or the documentation provided by the third party driver
+ vendor). The static device node will be copied to
+ <filename class="directory">/dev</filename> by the
+ <command>udev</command> bootscript.</para>
+
+ </sect3>
+
+ <sect3>
+ <title>Device naming order changes randomly after rebooting</title>
+
+ <para>This is due to the fact that Udev, by design, handles uevents and
+ loads modules in parallel, and thus in an unpredictable order. This will
+ never be <quote>fixed</quote>. You should not rely upon the kernel device
+ names being stable. Instead, create your own rules that make symlinks with
+ stable names based on some stable attributes of the device, such as a
+ serial number or the output of various *_id utilities installed by Udev.
+ See <xref linkend="ch-scripts-symlinks"/> and
+ <xref linkend="ch-scripts-network"/> for examples.</para>
+
+ </sect3>
+
+ </sect2>
+
+ <sect2>
+ <title>Useful Reading</title>
+
+ <para>Additional helpful documentation is available at the following
+ sites:</para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>A Userspace Implementation of <systemitem class="filesystem">devfs</systemitem>
+ <ulink url="http://www.kroah.com/linux/talks/ols_2003_udev_paper/Reprint-Kroah-Hartman-OLS2003.pdf"/></para>
+ </listitem>
+
+ <listitem>
+ <para>The <systemitem class="filesystem">sysfs</systemitem> Filesystem
+ <ulink url="http://www.kernel.org/pub/linux/kernel/people/mochel/doc/papers/ols-2005/mochel.pdf"/></para>
+ </listitem>
+
+ </itemizedlist>
+
+ </sect2>
+
+</sect1>