Changeset f3317d4 for chapter07


Ignore:
Timestamp:
02/15/2013 09:14:37 PM (11 years ago)
Author:
Krejzi <krejzi@…>
Branches:
7.5-systemd, 7.6-systemd, 7.7-systemd, 7.8-systemd, 7.9-systemd
Children:
b588d62
Parents:
4a4e017
Message:

Move Chapter 7 in place for Systemd.

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/systemd/BOOK@10159 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

Location:
chapter07
Files:
3 deleted
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • chapter07/chapter07.xml

    r4a4e017 rf3317d4  
    1717  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="udev.xml"/>
    1818  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="symlinks.xml"/>
    19   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="bootscripts.xml"/>
    20   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="usage.xml"/>
    2119  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="hostname.xml"/>
    2220  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="setclock.xml"/>
    2321  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="console.xml"/>
    24   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="sysklogd.xml"/>
    25   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="profile.xml"/>
     22  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="locale.xml"/>
    2623  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="inputrc.xml"/>
    2724
  • chapter07/hostname.xml

    r4a4e017 rf3317d4  
    1616  </indexterm>
    1717
    18   <para>Part of the job of the <command>localnet</command> script is setting the
    19   system's hostname. This needs to be configured in the
    20   <filename>/etc/sysconfig/network</filename> file.</para>
     18  <para>Systemd reads <filename>/etc/hostname</filename> to determine which
     19  hostname should be set.</para>
    2120
    22   <para>Create the <filename>/etc/sysconfig/network</filename> file and enter a
     21  <para>Create the <filename>/etc/hostname</filename> file and enter a
    2322  hostname by running:</para>
    2423
    25 <screen><userinput>echo "HOSTNAME=<replaceable>&lt;lfs&gt;</replaceable>" &gt; /etc/sysconfig/network</userinput></screen>
     24<screen><userinput>echo "<replaceable>&lt;lfs&gt;</replaceable>" &gt; /etc/hostname</userinput></screen>
    2625
    2726  <para><replaceable>&lt;lfs&gt;</replaceable> needs to be replaced with the name given
  • chapter07/introduction.xml

    r4a4e017 rf3317d4  
    3535  </itemizedlist>
    3636
    37   <para>The next sections detail how to install and configure the LFS system
    38   scripts needed during the boot process. Most of these scripts will work
    39   without modification, but a few require additional configuration files
    40   because they deal with hardware-dependent information.</para>
    41 
    42   <para>System-V style init scripts are employed in this book because they are
    43   widely used and relatively simple. For additional options, a hint detailing
    44   the BSD style init setup is available at <ulink
    45   url="&hints-root;bsd-init.txt"/>.  Searching the LFS mailing lists for
    46   <quote>depinit</quote>, <quote>upstart</quote>, or <quote>systemd</quote>
    47   will also offer additional information.</para>
    48 
    49   <para>If using an alternative style of init scripts, skip these sections.</para>
     37  <para>Third, configuring hostname, keyboard layout and system clock.</para>
    5038
    5139  <itemizedlist>
    52      <listitem>
    53        <para><xref linkend="ch-scripts-bootscripts" role="."/></para>
    54      </listitem>
    55      <listitem>
    56        <para><xref linkend="ch-scripts-usage" role="."/></para>
    57      </listitem>
    5840     <listitem>
    5941       <para><xref linkend="ch-scripts-hostname" role="."/></para>
     
    6547       <para><xref linkend="ch-scripts-console" role="."/></para>
    6648     </listitem>
    67      <listitem>
    68        <para><xref linkend="ch-scripts-sysklogd" role="."/></para>
    69      </listitem>
    7049  </itemizedlist>
    7150
     
    7655  <itemizedlist>
    7756     <listitem>
    78        <para><xref linkend="ch-scripts-profile" role="."/></para>
     57       <para><xref linkend="ch-scripts-locale" role="."/></para>
    7958     </listitem>
    8059     <listitem>
  • chapter07/locale.xml

    r4a4e017 rf3317d4  
    66]>
    77
    8 <sect1 id="ch-scripts-profile">
    9   <?dbhtml filename="profile.html"?>
     8<sect1 id="ch-scripts-locale">
     9  <?dbhtml filename="locale.html"?>
    1010
    11   <title>The Bash Shell Startup Files</title>
     11  <title>Configuring the System Locale</title>
    1212
    13   <indexterm zone="ch-scripts-profile">
    14     <primary sortas="e-/etc/profile">/etc/profile</primary>
     13  <indexterm zone="ch-scripts-locale">
     14    <primary sortas="e-etc-locale-conf">/etc/locale.conf</primary>
    1515  </indexterm>
    1616
    17   <para>The shell program <command>/bin/bash</command> (hereafter referred to
    18   as <quote>the shell</quote>) uses a collection of startup files to help
    19   create an environment to run in. Each file has a specific use and may affect
    20   login and interactive environments differently. The files in the <filename
    21   class="directory">/etc</filename> directory provide global settings. If an
    22   equivalent file exists in the home directory, it may override the global
    23   settings.</para>
    24 
    25   <para>An interactive login shell is started after a successful login, using
    26   <command>/bin/login</command>, by reading the <filename>/etc/passwd</filename>
    27   file. An interactive non-login shell is started at the command-line (e.g.,
    28   <prompt>[prompt]$</prompt><command>/bin/bash</command>). A non-interactive
    29   shell is usually present when a shell script is running. It is non-interactive
    30   because it is processing a script and not waiting for user input between
    31   commands.</para>
    32 
    33   <para>For more information, see <command>info bash</command> under the
    34   <emphasis>Bash Startup Files and Interactive Shells</emphasis> section.</para>
    35 
    36   <para>The files <filename>/etc/profile</filename> and
    37   <filename>~/.bash_profile</filename> are read when the shell is
    38   invoked as an interactive login shell.</para>
    39 
    40   <para>The base <filename>/etc/profile</filename> below sets some
     17  <para>The <filename>/etc/locale.conf</filename> below sets some
    4118  environment variables necessary for native language support. Setting
    4219  them properly results in:</para>
     
    136113
    137114  <para>Once the proper locale settings have been determined, create the
    138   <filename>/etc/profile</filename> file:</para>
     115  <filename>/etc/locale.conf</filename> file:</para>
    139116
    140 <screen><userinput>cat &gt; /etc/profile &lt;&lt; "EOF"
    141 <literal># Begin /etc/profile
    142 
    143 export LANG=<replaceable>&lt;ll&gt;_&lt;CC&gt;.&lt;charmap&gt;&lt;@modifiers&gt;</replaceable>
    144 
    145 # End /etc/profile</literal>
     117<screen><userinput>cat &gt; /etc/locale.conf &lt;&lt; "EOF"
     118<literal>LANG=<replaceable>&lt;ll&gt;_&lt;CC&gt;.&lt;charmap&gt;&lt;@modifiers&gt;</replaceable></literal>
    146119EOF</userinput></screen>
    147120
  • chapter07/network.xml

    r4a4e017 rf3317d4  
    1717  <para>This section only applies if a network card is to be
    1818  configured.</para>
    19 
    20   <para>If a network card will not be used, there is likely no need to create
    21   any configuration files relating to network cards. If that is the case, you
    22   will need to remove the <filename class="symlink">network</filename> symlinks
    23   from all run-level directories (<filename
    24   class="directory">/etc/rc.d/rc*.d</filename>) after the bootscripts are
    25   installed in <xref linkend="ch-scripts-bootscripts"/>.</para>
    26 
    27   <sect2 id='stable-net-names'>
    28     <title>Creating stable names for network interfaces</title>
    29 
    30     <para>If there is only one network interface in the system to be
    31     configured, this section is optional, although it will never be wrong to do
    32     it.  In many cases (e.g. a laptop with a wireless and a wired interface),
    33     accomplishing the configuration in this section is necessary.</para>
    34 
    35     <para>With Udev and modular network drivers, the network interface numbering
    36     is not persistent across reboots by default, because the drivers are loaded
    37     in parallel and, thus, in random order. For example, on a computer having
    38     two network cards made by Intel and Realtek, the network card manufactured
    39     by Intel may become <filename class="devicefile">eth0</filename> and the
    40     Realtek card becomes  <filename class="devicefile">eth1</filename>. In some
    41     cases, after a reboot the cards get renumbered the other way around. To
    42     avoid this, Udev comes with a script and some rules to assign stable names
    43     to network cards based on their MAC address.</para>
    44 
    45     <para>The rules were pre-generated in the build instructions for
    46     <application>udev (systemd)</application> in the last chapter.  Inspect the
    47     <filename>/etc/udev/rules.d/70-persistent-net.rules</filename> file, to
    48     find out which name was assigned to which network device:</para>
    49 
    50 <screen role="nodump"><userinput>cat /etc/udev/rules.d/70-persistent-net.rules</userinput></screen>
    51 
    52     <note><para>In some cases such as when MAC addresess have been assigned to
    53     a network card manually or in a virtual environment such as Xen,
    54     the network rules file may not have been generated because addresses
    55     are not consistently assigned.  In these cases, just continue to
    56     the next section.</para></note>
    57 
    58     <para>The file begins with a comment block followed by two lines for each
    59     NIC. The first line for each NIC is a commented description showing its
    60     hardware IDs (e.g. its PCI vendor and device IDs, if it's a PCI card),
    61     along with its driver in parentheses, if the driver can be found. Neither
    62     the hardware ID nor the driver is used to determine which name to give an
    63     interface; this information is only for reference. The second line is the
    64     Udev rule that matches this NIC and actually assigns it a name.</para>
    65 
    66     <para>All Udev rules are made up of several keys, separated by commas and
    67     optional whitespace. This rule's keys and an explanation of each of them
    68     are as follows:</para>
    69 
    70     <itemizedlist>
    71       <listitem>
    72         <para><literal>SUBSYSTEM=="net"</literal> - This tells Udev to ignore
    73         devices that are not network cards.</para>
    74       </listitem>
    75       <listitem>
    76         <para><literal>ACTION=="add"</literal> - This tells Udev to ignore this
    77         rule for a uevent that isn't an add ("remove" and "change" uevents also
    78         happen, but don't need to rename network interfaces).</para>
    79       </listitem>
    80       <listitem>
    81         <para><literal>DRIVERS=="?*"</literal> - This exists so that Udev will
    82         ignore VLAN or bridge sub-interfaces (because these sub-interfaces do
    83         not have drivers). These sub-interfaces are skipped because the name
    84         that would be assigned would collide with their parent devices.</para>
    85       </listitem>
    86       <listitem>
    87         <para><literal>ATTR{address}</literal> - The value of this key is the
    88         NIC's MAC address.</para>
    89       </listitem>
    90       <listitem>
    91         <para><literal>ATTR{type}=="1"</literal> - This ensures the rule only
    92         matches the primary interface in the case of certain wireless drivers,
    93         which create multiple virtual interfaces. The secondary interfaces are
    94         skipped for the same reason that VLAN and bridge sub-interfaces are
    95         skipped: there would be a name collision otherwise.</para>
    96       </listitem>
    97       <listitem>
    98         <para><literal>KERNEL=="eth*"</literal> - This key was added to the
    99         Udev rule generator to handle machines that have multiple network
    100         interfaces, all with the same MAC address (the PS3 is one such
    101         machine).  If the independent interfaces have different basenames,
    102         this key will allow Udev to tell them apart.  This is generally not
    103         necessary for most Linux From Scratch users, but does not hurt.</para>
    104       </listitem>
    105       <listitem>
    106         <para><literal>NAME</literal> - The value of this key is the name that
    107         Udev will assign to this interface.</para>
    108       </listitem>
    109     </itemizedlist>
    110 
    111     <para>The value of <literal>NAME</literal> is the important part. Make sure
    112     you know which name has been assigned to each of your network cards before
    113     proceeding, and be sure to use that <literal>NAME</literal> value when
    114     creating your configuration files below.</para>
    115 
    116   </sect2>
    11719
    11820  <sect2>
  • chapter07/symlinks.xml

    r4a4e017 rf3317d4  
    1010
    1111  <title>Creating Custom Symlinks to Devices</title>
    12 
    13   <sect2>
    14 
    15     <title>CD-ROM symlinks</title>
    16 
    17     <para>Some software that you may want to install later (e.g., various
    18     media players) expect the <filename class="symlink">/dev/cdrom</filename>
    19     and <filename class="symlink">/dev/dvd</filename> symlinks to exist, and
    20     to point to a CD-ROM or DVD-ROM device. Also, it may be convenient to put
    21     references to those symlinks into <filename>/etc/fstab</filename>. Udev
    22     comes with a script that will generate rules files to create these symlinks
    23     for you, depending on the capabilities of each device, but you need to
    24     decide which of two modes of operation you wish to have the script use.</para>
    25 
    26     <para>First, the script can operate in <quote>by-path</quote> mode (used by
    27     default for USB and FireWire devices), where the rules it creates depend on
    28     the physical path to the CD or DVD device. Second, it can operate in
    29     <quote>by-id</quote> mode (default for IDE and SCSI devices), where the
    30     rules it creates depend on identification strings stored in the CD or DVD
    31     device itself. The path is determined by Udev's <command>path_id</command>
    32     script, and the identification strings are read from the hardware by its
    33     <command>ata_id</command> or <command>scsi_id</command> programs, depending
    34     on which type of device you have.</para>
    35 
    36     <para>There are advantages to each approach; the correct approach to use
    37     will depend on what kinds of device changes may happen. If you expect the
    38     physical path to the device (that is, the ports and/or slots that it plugs
    39     into) to change, for example because you plan on moving the drive to a
    40     different IDE port or a different USB connector, then you should use the
    41     <quote>by-id</quote> mode. On the other hand, if you expect the device's
    42     identification to change, for example because it may die, and you would
    43     replace it with a different device with the same capabilities and which
    44     is plugged into the same connectors, then you should use the
    45     <quote>by-path</quote> mode.</para>
    46 
    47     <para>If either type of change is possible with your drive, then choose a
    48     mode based on the type of change you expect to happen more often.</para>
    49 
    50 <!-- If you use by-id mode, the symlinks will survive even the transition
    51      to libata for IDE drives, but that is not for the book. -->
    52 
    53     <important><para>External devices (for example, a USB-connected CD drive)
    54     should not use by-path persistence, because each time the device is plugged
    55     into a new external port, its physical path will change. All
    56     externally-connected devices will have this problem if you write Udev rules
    57     to recognize them by their physical path; the problem is not limited to CD
    58     and DVD drives.</para></important>
    59 
    60     <para>If you wish to see the values that the Udev scripts will use, then
    61     for the appropriate CD-ROM device, find the corresponding directory under
    62     <filename class="directory">/sys</filename> (e.g., this can be
    63     <filename class="directory">/sys/block/hdd</filename>) and
    64     run a command similar to the following:</para>
    65 
    66 <screen role="nodump"><userinput>udevadm test /sys/block/hdd</userinput></screen>
    67 
    68     <para>Look at the lines containing the output of various *_id programs.
    69     The <quote>by-id</quote> mode will use the ID_SERIAL value if it exists and
    70     is not empty, otherwise it will use a combination of ID_MODEL and
    71     ID_REVISION. The <quote>by-path</quote> mode will use the ID_PATH value.</para>
    72 
    73     <para>If the default mode is not suitable for your situation, then the
    74     following modification can be made to the
    75     <filename>/lib/udev/rules.d/75-cd-aliases-generator.rules</filename> file,
    76     as follows (where <replaceable>mode</replaceable> is one of
    77     <quote>by-id</quote> or <quote>by-path</quote>):</para>
    78 
    79 <screen role="nodump"><userinput>sed -i -e 's/"write_cd_rules"/"write_cd_rules <replaceable>mode</replaceable>"/' \
    80     /lib/udev/rules.d/75-cd-aliases-generator.rules</userinput></screen>
    81 
    82     <para>Note that it is not necessary to create the rules files or symlinks
    83     at this time, because you have bind-mounted the host's
    84     <filename class="directory">/dev</filename> directory into the LFS system,
    85     and we assume the symlinks exist on the host. The rules and symlinks will
    86     be created the first time you boot your LFS system.</para>
    87 
    88     <para>However, if you have multiple CD-ROM devices, then the symlinks
    89     generated at that time may point to different devices than they point to on
    90     your host, because devices are not discovered in a predictable order. The
    91     assignments created when you first boot the LFS system will be stable, so
    92     this is only an issue if you need the symlinks on both systems to point to
    93     the same device. If you need that, then inspect (and possibly edit) the
    94     generated <filename>/etc/udev/rules.d/70-persistent-cd.rules</filename>
    95     file after booting, to make sure the assigned symlinks match what you need.</para>
    96 
    97   </sect2>
    9812
    9913  <sect2>
  • chapter07/udev.xml

    r4a4e017 rf3317d4  
    120120      whatever <systemitem class="filesystem">devtmpfs</systemitem> used
    121121      initially.</para> </sect3>
    122 
    123     <sect3>
    124       <title>Udev Bootscripts</title>
    125 
    126       <para>The first LFS bootscript,
    127       <filename>/etc/init.d/mountvirtfs</filename> will copy any devices
    128       located in <filename class="directory">/lib/udev/devices</filename> to
    129       <filename class="directory">/dev</filename>. This is necessary because
    130       some devices, directories, and symlinks are needed before the dynamic
    131       device handling processes are available during the early stages of
    132       booting a system, or are required by <command>udevd</command> itself.
    133       Creating static device nodes in <filename
    134       class="directory">/lib/udev/devices</filename> also provides an easy
    135       workaround for devices that are not supported by the dynamic device
    136       handling infrastructure.</para>
    137 
    138       <para>The <filename>/etc/rc.d/init.d/udev</filename> initscript starts
    139       <command>udevd</command>, triggers any "coldplug" devices that have
    140       already been created by the kernel and waits for any rules to complete.
    141       The script also unsets the uevent handler from the default of
    142       <filename>/sbin/hotplug </filename>.  This is done because the kernel no
    143       longer needs to call out to an external binary.  Instead
    144       <command>udevd</command> will listen on a netlink socket for uevents that
    145       the kernel raises.</para>
    146 
    147       <para>The <command>/etc/rc.d/init.d/udev_retry</command> initscript takes
    148       care of re-triggering events for subsystems whose rules may rely on
    149       filesystems that are not mounted until the <command>mountfs</command>
    150       script is run (in particular, <filename class="directory">/usr</filename>
    151       and <filename class="directory">/var</filename> may cause this).  This
    152       script runs after the <command>mountfs</command> script, so those rules
    153       (if re-triggered) should succeed the second time around.  It is
    154       configured from the <filename>/etc/sysconfig/udev_retry</filename> file;
    155       any words in this file other than comments are considered subsystem names
    156       to trigger at retry time.  To find the subsystem of a device, use
    157       <command>udevadm info --attribute-walk &lt;device&gt;</command> where
    158       &lt;device&gt; is a an absolure path in /dev or /sys such as /dev/sr0 or
    159       /sys/class/rtc.</para>
    160 
    161     </sect3>
    162122
    163123    <sect3>
Note: See TracChangeset for help on using the changeset viewer.