Changeset f3317d4
- Timestamp:
- 02/15/2013 09:14:37 PM (11 years ago)
- Branches:
- 7.5-systemd, 7.6-systemd, 7.7-systemd, 7.8-systemd, 7.9-systemd
- Children:
- b588d62
- Parents:
- 4a4e017
- Location:
- chapter07
- Files:
-
- 3 deleted
- 6 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
chapter07/chapter07.xml
r4a4e017 rf3317d4 17 17 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="udev.xml"/> 18 18 <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"/>21 19 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="hostname.xml"/> 22 20 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="setclock.xml"/> 23 21 <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"/> 26 23 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="inputrc.xml"/> 27 24 -
chapter07/hostname.xml
r4a4e017 rf3317d4 16 16 </indexterm> 17 17 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> 21 20 22 <para>Create the <filename>/etc/ sysconfig/network</filename> file and enter a21 <para>Create the <filename>/etc/hostname</filename> file and enter a 23 22 hostname by running:</para> 24 23 25 <screen><userinput>echo " HOSTNAME=<replaceable><lfs></replaceable>" > /etc/sysconfig/network</userinput></screen>24 <screen><userinput>echo "<replaceable><lfs></replaceable>" > /etc/hostname</userinput></screen> 26 25 27 26 <para><replaceable><lfs></replaceable> needs to be replaced with the name given -
chapter07/introduction.xml
r4a4e017 rf3317d4 35 35 </itemizedlist> 36 36 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> 50 38 51 39 <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>58 40 <listitem> 59 41 <para><xref linkend="ch-scripts-hostname" role="."/></para> … … 65 47 <para><xref linkend="ch-scripts-console" role="."/></para> 66 48 </listitem> 67 <listitem>68 <para><xref linkend="ch-scripts-sysklogd" role="."/></para>69 </listitem>70 49 </itemizedlist> 71 50 … … 76 55 <itemizedlist> 77 56 <listitem> 78 <para><xref linkend="ch-scripts- profile" role="."/></para>57 <para><xref linkend="ch-scripts-locale" role="."/></para> 79 58 </listitem> 80 59 <listitem> -
chapter07/locale.xml
r4a4e017 rf3317d4 6 6 ]> 7 7 8 <sect1 id="ch-scripts- profile">9 <?dbhtml filename=" profile.html"?>8 <sect1 id="ch-scripts-locale"> 9 <?dbhtml filename="locale.html"?> 10 10 11 <title> The Bash Shell Startup Files</title>11 <title>Configuring the System Locale</title> 12 12 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> 15 15 </indexterm> 16 16 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 41 18 environment variables necessary for native language support. Setting 42 19 them properly results in:</para> … … 136 113 137 114 <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> 139 116 140 <screen><userinput>cat > /etc/profile << "EOF" 141 <literal># Begin /etc/profile 142 143 export LANG=<replaceable><ll>_<CC>.<charmap><@modifiers></replaceable> 144 145 # End /etc/profile</literal> 117 <screen><userinput>cat > /etc/locale.conf << "EOF" 118 <literal>LANG=<replaceable><ll>_<CC>.<charmap><@modifiers></replaceable></literal> 146 119 EOF</userinput></screen> 147 120 -
chapter07/network.xml
r4a4e017 rf3317d4 17 17 <para>This section only applies if a network card is to be 18 18 configured.</para> 19 20 <para>If a network card will not be used, there is likely no need to create21 any configuration files relating to network cards. If that is the case, you22 will need to remove the <filename class="symlink">network</filename> symlinks23 from all run-level directories (<filename24 class="directory">/etc/rc.d/rc*.d</filename>) after the bootscripts are25 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 be31 configured, this section is optional, although it will never be wrong to do32 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 numbering36 is not persistent across reboots by default, because the drivers are loaded37 in parallel and, thus, in random order. For example, on a computer having38 two network cards made by Intel and Realtek, the network card manufactured39 by Intel may become <filename class="devicefile">eth0</filename> and the40 Realtek card becomes <filename class="devicefile">eth1</filename>. In some41 cases, after a reboot the cards get renumbered the other way around. To42 avoid this, Udev comes with a script and some rules to assign stable names43 to network cards based on their MAC address.</para>44 45 <para>The rules were pre-generated in the build instructions for46 <application>udev (systemd)</application> in the last chapter. Inspect the47 <filename>/etc/udev/rules.d/70-persistent-net.rules</filename> file, to48 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 to53 a network card manually or in a virtual environment such as Xen,54 the network rules file may not have been generated because addresses55 are not consistently assigned. In these cases, just continue to56 the next section.</para></note>57 58 <para>The file begins with a comment block followed by two lines for each59 NIC. The first line for each NIC is a commented description showing its60 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. Neither62 the hardware ID nor the driver is used to determine which name to give an63 interface; this information is only for reference. The second line is the64 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 and67 optional whitespace. This rule's keys and an explanation of each of them68 are as follows:</para>69 70 <itemizedlist>71 <listitem>72 <para><literal>SUBSYSTEM=="net"</literal> - This tells Udev to ignore73 devices that are not network cards.</para>74 </listitem>75 <listitem>76 <para><literal>ACTION=="add"</literal> - This tells Udev to ignore this77 rule for a uevent that isn't an add ("remove" and "change" uevents also78 happen, but don't need to rename network interfaces).</para>79 </listitem>80 <listitem>81 <para><literal>DRIVERS=="?*"</literal> - This exists so that Udev will82 ignore VLAN or bridge sub-interfaces (because these sub-interfaces do83 not have drivers). These sub-interfaces are skipped because the name84 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 the88 NIC's MAC address.</para>89 </listitem>90 <listitem>91 <para><literal>ATTR{type}=="1"</literal> - This ensures the rule only92 matches the primary interface in the case of certain wireless drivers,93 which create multiple virtual interfaces. The secondary interfaces are94 skipped for the same reason that VLAN and bridge sub-interfaces are95 skipped: there would be a name collision otherwise.</para>96 </listitem>97 <listitem>98 <para><literal>KERNEL=="eth*"</literal> - This key was added to the99 Udev rule generator to handle machines that have multiple network100 interfaces, all with the same MAC address (the PS3 is one such101 machine). If the independent interfaces have different basenames,102 this key will allow Udev to tell them apart. This is generally not103 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 that107 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 sure112 you know which name has been assigned to each of your network cards before113 proceeding, and be sure to use that <literal>NAME</literal> value when114 creating your configuration files below.</para>115 116 </sect2>117 19 118 20 <sect2> -
chapter07/symlinks.xml
r4a4e017 rf3317d4 10 10 11 11 <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., various18 media players) expect the <filename class="symlink">/dev/cdrom</filename>19 and <filename class="symlink">/dev/dvd</filename> symlinks to exist, and20 to point to a CD-ROM or DVD-ROM device. Also, it may be convenient to put21 references to those symlinks into <filename>/etc/fstab</filename>. Udev22 comes with a script that will generate rules files to create these symlinks23 for you, depending on the capabilities of each device, but you need to24 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 by27 default for USB and FireWire devices), where the rules it creates depend on28 the physical path to the CD or DVD device. Second, it can operate in29 <quote>by-id</quote> mode (default for IDE and SCSI devices), where the30 rules it creates depend on identification strings stored in the CD or DVD31 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 its33 <command>ata_id</command> or <command>scsi_id</command> programs, depending34 on which type of device you have.</para>35 36 <para>There are advantages to each approach; the correct approach to use37 will depend on what kinds of device changes may happen. If you expect the38 physical path to the device (that is, the ports and/or slots that it plugs39 into) to change, for example because you plan on moving the drive to a40 different IDE port or a different USB connector, then you should use the41 <quote>by-id</quote> mode. On the other hand, if you expect the device's42 identification to change, for example because it may die, and you would43 replace it with a different device with the same capabilities and which44 is plugged into the same connectors, then you should use the45 <quote>by-path</quote> mode.</para>46 47 <para>If either type of change is possible with your drive, then choose a48 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 transition51 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 plugged55 into a new external port, its physical path will change. All56 externally-connected devices will have this problem if you write Udev rules57 to recognize them by their physical path; the problem is not limited to CD58 and DVD drives.</para></important>59 60 <para>If you wish to see the values that the Udev scripts will use, then61 for the appropriate CD-ROM device, find the corresponding directory under62 <filename class="directory">/sys</filename> (e.g., this can be63 <filename class="directory">/sys/block/hdd</filename>) and64 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 and70 is not empty, otherwise it will use a combination of ID_MODEL and71 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 the74 following modification can be made to the75 <filename>/lib/udev/rules.d/75-cd-aliases-generator.rules</filename> file,76 as follows (where <replaceable>mode</replaceable> is one of77 <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 symlinks83 at this time, because you have bind-mounted the host's84 <filename class="directory">/dev</filename> directory into the LFS system,85 and we assume the symlinks exist on the host. The rules and symlinks will86 be created the first time you boot your LFS system.</para>87 88 <para>However, if you have multiple CD-ROM devices, then the symlinks89 generated at that time may point to different devices than they point to on90 your host, because devices are not discovered in a predictable order. The91 assignments created when you first boot the LFS system will be stable, so92 this is only an issue if you need the symlinks on both systems to point to93 the same device. If you need that, then inspect (and possibly edit) the94 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>98 12 99 13 <sect2> -
chapter07/udev.xml
r4a4e017 rf3317d4 120 120 whatever <systemitem class="filesystem">devtmpfs</systemitem> used 121 121 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 devices128 located in <filename class="directory">/lib/udev/devices</filename> to129 <filename class="directory">/dev</filename>. This is necessary because130 some devices, directories, and symlinks are needed before the dynamic131 device handling processes are available during the early stages of132 booting a system, or are required by <command>udevd</command> itself.133 Creating static device nodes in <filename134 class="directory">/lib/udev/devices</filename> also provides an easy135 workaround for devices that are not supported by the dynamic device136 handling infrastructure.</para>137 138 <para>The <filename>/etc/rc.d/init.d/udev</filename> initscript starts139 <command>udevd</command>, triggers any "coldplug" devices that have140 already been created by the kernel and waits for any rules to complete.141 The script also unsets the uevent handler from the default of142 <filename>/sbin/hotplug </filename>. This is done because the kernel no143 longer needs to call out to an external binary. Instead144 <command>udevd</command> will listen on a netlink socket for uevents that145 the kernel raises.</para>146 147 <para>The <command>/etc/rc.d/init.d/udev_retry</command> initscript takes148 care of re-triggering events for subsystems whose rules may rely on149 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). This152 script runs after the <command>mountfs</command> script, so those rules153 (if re-triggered) should succeed the second time around. It is154 configured from the <filename>/etc/sysconfig/udev_retry</filename> file;155 any words in this file other than comments are considered subsystem names156 to trigger at retry time. To find the subsystem of a device, use157 <command>udevadm info --attribute-walk <device></command> where158 <device> is a an absolure path in /dev or /sys such as /dev/sr0 or159 /sys/class/rtc.</para>160 161 </sect3>162 122 163 123 <sect3>
Note:
See TracChangeset
for help on using the changeset viewer.