- Timestamp:
- 02/19/2005 10:16:42 PM (20 years ago)
- Branches:
- 10.0, 10.0-rc1, 10.1, 10.1-rc1, 11.0, 11.0-rc1, 11.0-rc2, 11.0-rc3, 11.1, 11.1-rc1, 11.2, 11.2-rc1, 11.3, 11.3-rc1, 12.0, 12.0-rc1, 12.1, 12.1-rc1, 12.2, 12.2-rc1, 6.1, 6.1.1, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.5-systemd, 7.6, 7.6-systemd, 7.7, 7.7-systemd, 7.8, 7.8-systemd, 7.9, 7.9-systemd, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, arm, bdubbs/gcc13, ml-11.0, multilib, renodr/libudev-from-systemd, s6-init, trunk, xry111/arm64, xry111/arm64-12.0, xry111/clfs-ng, xry111/lfs-next, xry111/loongarch, xry111/loongarch-12.0, xry111/loongarch-12.1, xry111/loongarch-12.2, xry111/mips64el, xry111/multilib, xry111/pip3, xry111/rust-wip-20221008, xry111/update-glibc
- Children:
- 3d31fc4
- Parents:
- 2f9131f
- Location:
- chapter07
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter07/bootscripts.xml
r2f9131f r81fd230 4 4 %general-entities; 5 5 ]> 6 <sect1 id="ch-scripts-bootscripts" xreflabel="Bootscripts"role="wrap">6 <sect1 id="ch-scripts-bootscripts" role="wrap"> 7 7 <title>LFS-Bootscripts-&lfs-bootscripts-version;</title> 8 8 <?dbhtml filename="bootscripts.html"?> … … 11 11 12 12 <sect2 role="package"><title/> 13 <para>The LFS-Bootscripts package contains a set of bootscripts.</para> 13 14 14 15 <segmentedlist> … … 18 19 </segmentedlist> 19 20 21 <segmentedlist> 22 <segtitle>LFS-Bootscripts installation depends on</segtitle> 23 <seglistitem><seg>Bash and Coreutils</seg></seglistitem> 24 </segmentedlist> 20 25 </sect2> 21 26 … … 23 28 <title>Installation of LFS-Bootscripts</title> 24 29 25 <para>Install ation of the bootscripts is very simple:</para>30 <para>Install the package:</para> 26 31 27 32 <screen><userinput>make install</userinput></screen> … … 29 34 </sect2> 30 35 31 32 36 <sect2 id="contents-bootscripts" role="content"><title>Contents of LFS-bootscripts</title> 33 37 34 <para>See testing</para> 38 <segmentedlist> 39 <segtitle>Installed scripts</segtitle> 40 <seglistitem><seg>checkfs, cleanfs, console, functions, halt, ifdown, ifup, 41 localnet, mountfs, mountkernfs, network, rc, reboot, sendsignals, setclock, static, 42 swap, sysklogd, template, and udev</seg></seglistitem> 43 </segmentedlist> 44 45 <variablelist><bridgehead renderas="sect3">Short Descriptions</bridgehead> 46 <?dbfo list-presentation="list"?> 47 48 <varlistentry id="checkfs-bootscripts"> 49 <term><command>checkfs</command></term> 50 <listitem> 51 <para>Checks the file systems before they are mounted (with the exception of journal 52 and network based file systems)</para> 53 <indexterm zone="ch-scripts-bootscripts checkfs-bootscripts"><primary sortas="d-checkfs">checkfs</primary></indexterm> 54 </listitem> 55 </varlistentry> 56 57 <varlistentry id="cleanfs-bootscripts"> 58 <term><command>cleanfs</command></term> 59 <listitem> 60 <para>Removes files that should not be 61 preserved between reboots, such as those in <filename class="directory">/var/run/</filename> and 62 <filename class="directory">/var/lock/</filename>; it re-creates <filename>/var/run/utmp</filename> 63 and removes the possibly present <filename>/etc/nologin</filename>, 64 <filename>/fastboot</filename>, and <filename>/forcefsck</filename> files</para> 65 <indexterm zone="ch-scripts-bootscripts cleanfs-bootscripts"><primary sortas="d-cleanfs">cleanfs</primary></indexterm> 66 </listitem> 67 </varlistentry> 68 69 <varlistentry id="console-bootscripts"> 70 <term><command>console</command></term> 71 <listitem> 72 <para>Loads the keymap table specified as proper for the keyboard 73 layout; it also sets the screen font</para> 74 <indexterm zone="ch-scripts-bootscripts console-bootscripts"><primary sortas="d-console">console</primary></indexterm> 75 </listitem> 76 </varlistentry> 77 78 <varlistentry id="functions-bootscripts"> 79 <term><command>functions</command></term> 80 <listitem> 81 <para>Contains functions shared among different scripts, such as error 82 and status checking</para> 83 <indexterm zone="ch-scripts-bootscripts functions-bootscripts"><primary sortas="d-functions">functions</primary></indexterm> 84 </listitem> 85 </varlistentry> 86 87 <varlistentry id="halt-bootscripts"> 88 <term><command>halt</command></term> 89 <listitem> 90 <para>Halts the system</para> 91 <indexterm zone="ch-scripts-bootscripts halt-bootscripts"><primary sortas="d-halt">halt</primary></indexterm> 92 </listitem> 93 </varlistentry> 94 95 <varlistentry id="hotplug-bootscripts"> 96 <term><command>hotplug</command></term> 97 <listitem> 98 <para>Load modules for system devices</para> 99 <indexterm zone="ch-scripts-bootscripts hotplug-bootscripts"><primary sortas="d-hotplug">hotplug</primary></indexterm> 100 </listitem> 101 </varlistentry> 102 103 <varlistentry id="ifdown-bootscripts"> 104 <term><command>ifdown</command></term> 105 <listitem> 106 <para>Assists the network script with network devices</para> 107 <indexterm zone="ch-scripts-bootscripts ifdown-bootscripts"><primary sortas="d-ifdown">ifdown</primary></indexterm> 108 </listitem> 109 </varlistentry> 110 111 <varlistentry id="ifup-bootscripts"> 112 <term><command>ifup</command></term> 113 <listitem> 114 <para>Assists the network script with network devices</para> 115 <indexterm zone="ch-scripts-bootscripts ifup-bootscripts"><primary sortas="d-ifup">ifup</primary></indexterm> 116 </listitem> 117 </varlistentry> 118 119 <varlistentry id="localnet-bootscripts"> 120 <term><command>localnet</command></term> 121 <listitem> 122 <para>Sets up the system's hostname and local loopback device</para> 123 <indexterm zone="ch-scripts-bootscripts localnet-bootscripts"><primary sortas="d-localnet">localnet</primary></indexterm> 124 </listitem> 125 </varlistentry> 126 127 <varlistentry id="mountfs-bootscripts"> 128 <term><command>mountfs</command></term> 129 <listitem> 130 <para>Mounts all file systems, except ones that are marked 131 <emphasis>noauto</emphasis> or are network based</para> 132 <indexterm zone="ch-scripts-bootscripts mountfs-bootscripts"><primary sortas="d-mountfs">mountfs</primary></indexterm> 133 </listitem> 134 </varlistentry> 135 136 <varlistentry id="mountkernfs-bootscripts"> 137 <term><command>mountkernfs</command></term> 138 <listitem> 139 <para>Is used to mount kernel-provided file systems, such as 140 <systemitem class="filesystem">proc</systemitem></para> 141 <indexterm zone="ch-scripts-bootscripts mountkernfs-bootscripts"><primary sortas="d-mountkernfs">mountkernfs</primary></indexterm> 142 </listitem> 143 </varlistentry> 144 145 <varlistentry id="network-bootscripts"> 146 <term><command>network</command></term> 147 <listitem> 148 <para>Sets up network interfaces, such as network cards, and sets up 149 the default gateway (where applicable)</para> 150 <indexterm zone="ch-scripts-bootscripts network-bootscripts"><primary sortas="d-network">network</primary></indexterm> 151 </listitem> 152 </varlistentry> 153 154 <varlistentry id="rc-bootscripts"> 155 <term><command>rc</command></term> 156 <listitem> 157 <para>The master run-level control script; it is responsible for 158 running all other scripts one-by-one, in a sequence determined by 159 the name of the symbolic links being processed</para> 160 <indexterm zone="ch-scripts-bootscripts rc-bootscripts"><primary sortas="d-rc">rc</primary></indexterm> 161 </listitem> 162 </varlistentry> 163 164 <varlistentry id="reboot-bootscripts"> 165 <term><command>reboot</command></term> 166 <listitem> 167 <para>Reboots the system</para> 168 <indexterm zone="ch-scripts-bootscripts reboot-bootscripts"><primary sortas="d-reboot">reboot</primary></indexterm> 169 </listitem> 170 </varlistentry> 171 172 <varlistentry id="sendsignals-bootscripts"> 173 <term><command>sendsignals</command></term> 174 <listitem> 175 <para>Makes sure every process is terminated before the system reboots 176 or halts</para> 177 <indexterm zone="ch-scripts-bootscripts sendsignals-bootscripts"><primary sortas="d-sendsignals">sendsignals</primary></indexterm> 178 </listitem> 179 </varlistentry> 180 181 <varlistentry id="setclock-bootscripts"> 182 <term><command>setclock</command></term> 183 <listitem> 184 <para>Resets the kernel clock to local time in case the hardware clock 185 is not set to UTC time</para> 186 <indexterm zone="ch-scripts-bootscripts setclock-bootscripts"><primary sortas="d-setclock">setclock</primary></indexterm> 187 </listitem> 188 </varlistentry> 189 190 <varlistentry id="static-bootscripts"> 191 <term><command>static</command></term> 192 <listitem> 193 <para>Provides the functionality needed to assign a static Internet 194 Protocol (IP) address to a network interface</para> 195 <indexterm zone="ch-scripts-bootscripts static-bootscripts"><primary sortas="d-static">static</primary></indexterm> 196 </listitem> 197 </varlistentry> 198 199 <varlistentry id="swap-bootscripts"> 200 <term><command>swap</command></term> 201 <listitem> 202 <para>Enables and disables swap files and partitions</para> 203 <indexterm zone="ch-scripts-bootscripts swap-bootscripts"><primary sortas="d-swap">swap</primary></indexterm> 204 </listitem> 205 </varlistentry> 206 207 <varlistentry id="syslog-ng-bootscripts"> 208 <term><command>syslog-ng</command></term> 209 <listitem> 210 <para>Starts and stops the system and kernel log daemons</para> 211 <indexterm zone="ch-scripts-bootscripts syslog-ng-bootscripts"><primary sortas="d-syslog-ng">syslog-ng</primary></indexterm> 212 </listitem> 213 </varlistentry> 214 215 <varlistentry id="template-bootscripts"> 216 <term><command>template</command></term> 217 <listitem> 218 <para>A template to create custom bootscripts for other 219 daemons</para> 220 <indexterm zone="ch-scripts-bootscripts template-bootscripts"><primary sortas="d-template">template</primary></indexterm> 221 </listitem> 222 </varlistentry> 223 224 <varlistentry id="udev-bootscripts"> 225 <term><command>udev</command></term> 226 <listitem> 227 <para>Sets up udev and create the devices nodes in <filename 228 class="directory">/dev</filename></para> 229 <indexterm zone="ch-scripts-bootscripts udev-bootscripts"><primary sortas="d-udev">udev</primary></indexterm> 230 </listitem> 231 </varlistentry> 232 </variablelist> 35 233 36 234 </sect2> 37 235 38 236 </sect1> 237 -
chapter07/console.xml
r2f9131f r81fd230 8 8 <?dbhtml filename="console.html"?> 9 9 10 <para>Create the configuration file:</para> 10 <indexterm zone="ch-scripts-console"> 11 <primary sortas="d-console">console</primary> 12 <secondary>configuring</secondary></indexterm> 13 14 <para>This section discusses how to configure the 15 <command>console</command> initscript that sets up the keyboard map 16 and the console font. If non-ASCII characters (British pound and Euro 17 character are examples of non-ASCII characters) will not be used and 18 the keyboard is a U.S. one, skip this section. Without the 19 configuration file, the console initscript will do nothing.</para> 20 21 <para>The <command>console</command> script uses the 22 <filename>/etc/sysconfig/console</filename> as a configuration file. 23 Decide which keymap and screen font will be used. The 24 language-specific HOWTO can help with this. A pre-made 25 <filename>/etc/sysconfig/console</filename> file with known settings 26 for several countries was installed with the LFS-Bootscripts package, 27 so the relevant section can be uncommented if the country is 28 supported. If still in doubt, look in the <filename 29 class="directory">/usr/share/kbd</filename> directory for valid 30 keymaps and screen fonts. Read the loadkeys and setfont manual pages 31 and determine the correct arguments for these programs. Once decided, 32 create the configuration file with the following command:</para> 11 33 12 34 <screen><userinput>cat >/etc/sysconfig/console <<"EOF" … … 15 37 EOF</userinput></screen> 16 38 17 <para>If you see that keycode 14 is Backspace and not Delete, 18 create the following keymap snippet to fix this issue:</para> 39 <para>For example, for Spanish users who also want to use the Euro 40 character (accessible by pressing AltGr+E), the following settings are 41 correct:</para> 42 43 <screen><userinput>cat >/etc/sysconfig/console <<"EOF" 44 <literal>KEYMAP="es euro2" 45 FONT="lat9-16 -u iso01"</literal> 46 EOF</userinput></screen> 47 48 <note><para>The <envar>FONT</envar> line above is correct only for the ISO 8859-15 49 character set. If using ISO 8859-1 and, therefore, a pound sign 50 instead of Euro, the correct <envar>FONT</envar> line would be:</para> 51 52 <screen><userinput>FONT="lat1-16"</userinput></screen></note> 53 54 <para>If the <envar>KEYMAP</envar> or <envar>FONT</envar> variable is not set, the 55 <command>console</command> initscript will not run the corresponding 56 program.</para> 57 58 <para>In some keymaps, the Backspace and Delete keys send characters 59 different from ones in the default keymap built into the kernel. This 60 confuses some applications. For example, 61 <application>Emacs</application> displays its help (instead of erasing 62 the character before the cursor) when Backspace is pressed. To check 63 if the keymap in use is effected (this works only for i386 64 keymaps):</para> 65 66 <screen><userinput>zgrep '\W14\W' <replaceable>[/path/to/your/keymap]</replaceable></userinput></screen> 67 68 <para>If the keycode 14 is Backspace instead of Delete, create the 69 following keymap snippet to fix this issue:</para> 19 70 20 71 <screen><userinput>mkdir -p /etc/kbd && cat > /etc/kbd/bs-sends-del <<"EOF" … … 28 79 EOF</userinput></screen> 29 80 30 <para>T hen tell the <command>console</command> script to load this snippet31 after the main keymap:</para>81 <para>Tell the <command>console</command> script to load this 82 snippet after the main keymap:</para> 32 83 33 84 <screen><userinput>cat >>/etc/sysconfig/console <<"EOF" … … 35 86 EOF</userinput></screen> 36 87 88 <para>To compile the keymap directly into the kernel instead of 89 setting it every time from the <command>console</command> bootscript, 90 follow the instructions given in <xref linkend="ch-bootable-kernel" role="."/> 91 Doing this ensures that the keyboard will always work as expected, 92 even when booting into maintenance mode (by passing 93 <parameter>init=/bin/sh</parameter> to the kernel), because the 94 <command>console</command> bootscript will not be run in that 95 situation. Additionally, the kernel will not set the screen font 96 automatically. This should not pose many problems because ASCII characters 97 will be handled correctly, and it is unlikely that a user would need 98 to rely on non-ASCII characters while in maintenance mode.</para> 99 100 <para>Since the kernel will set up the keymap, it is possible to omit 101 the <envar>KEYMAP</envar> variable from the 102 <filename>/etc/sysconfig/console</filename> configuration file. It can 103 also be left in place, if desired, without consequence. Keeping it 104 could be beneficial if running several different kernels where it is 105 difficult to ensure that the keymap is compiled into every one of 106 them.</para> 107 37 108 </sect1> 38 109 -
chapter07/hostname.xml
r2f9131f r81fd230 8 8 <?dbhtml filename="hostname.html"?> 9 9 10 <indexterm zone="ch-scripts-hostname"> 11 <primary sortas="d-localnet">localnet</primary> 12 <secondary>configuring</secondary></indexterm> 13 14 <para>Part of the localnet script is setting up the system's hostname. This 15 needs to be configured in the <filename>/etc/sysconfig/network</filename>.</para> 10 16 11 17 <para>Create the <filename>/etc/sysconfig/network</filename> file and enter a hostname by … … 14 20 <screen><userinput>echo "HOSTNAME=<replaceable>[lfs]</replaceable>" > /etc/sysconfig/network</userinput></screen> 15 21 22 <para><replaceable>[lfs]</replaceable> needs to be replaced with the 23 name the computer is to be called. Do not enter the Fully Qualified 24 Domain Name (FQDN) here. That information will be put in the 25 <filename>/etc/hosts</filename> file later.</para> 26 16 27 </sect1> 28 -
chapter07/hosts.xml
r2f9131f r81fd230 8 8 <?dbhtml filename="hosts.html"?> 9 9 10 <para>If a network card is to be configured, create the 11 <filename>/etc/hosts</filename> file by running:</para> 10 <indexterm zone="ch-scripts-hosts"><primary sortas="e-/etc/hosts">/etc/hosts</primary></indexterm> 11 12 <indexterm zone="ch-scripts-hosts"> 13 <primary sortas="d-localnet">localnet</primary> 14 <secondary>/etc/hosts</secondary></indexterm> 15 16 <indexterm zone="ch-scripts-hosts"> 17 <primary sortas="d-network">network</primary> 18 <secondary>/etc/hosts</secondary></indexterm> 19 20 <para>If a network card is to be configured, decide on the IP-address, 21 FQDN, and possible aliases for use in the 22 <filename>/etc/hosts</filename> file. The syntax is:</para> 23 24 <screen><IP address> myhost.example.org aliases</screen> 25 26 <para>Unless the computer is to be visible to the Internet (e.g., 27 there is a registered domain and a valid block of assigned IP 28 addresses—most users do not have this), make sure that the IP 29 address is in the private network IP address range. Valid ranges 30 are:</para> 31 32 <screen> Class Networks 33 A 10.0.0.0 34 B 172.16.0.0 through 172.31.0.0 35 C 192.168.0.0 through 192.168.255.0</screen> 36 37 <para>A valid IP address could be 192.168.1.1. A valid FQDN for this 38 IP could be www.linuxfromscratch.org (not recommended because this is 39 a valid registered domain address and could cause domain name server 40 issues).</para> 41 42 <para>Even if not using a network card, an FQDN is still required. 43 This is necessary for certain programs to operate correctly.</para> 44 45 <para>Create the <filename>/etc/hosts</filename> file by running:</para> 12 46 13 47 <screen><userinput>cat > /etc/hosts << "EOF" … … 19 53 # End /etc/hosts (network card version)</literal> 20 54 EOF</userinput></screen> 55 56 <para>The <replaceable>[192.168.1.1]</replaceable> and 57 <replaceable>[<HOSTNAME>.example.org]</replaceable> 58 values need to be changed for specific users or requirements (if 59 assigned an IP address by a network/system administrator and the 60 machine will be connected to an existing network).</para> 21 61 22 62 <para>If a network card is not going to be configured, create the … … 32 72 33 73 </sect1> 74 -
chapter07/inputrc.xml
r2f9131f r81fd230 8 8 <?dbhtml filename="inputrc.html"?> 9 9 10 <para>Create the /etc/inputrc file:</para> 10 <indexterm zone="ch-scripts-inputrc"><primary sortas="e-/etc/inputrc">/etc/inputrc</primary></indexterm> 11 12 <para>The <filename>/etc/inputrc</filename> file deals with mapping 13 the keyboard for specific situations. This file is the start-up file 14 used by <application>Readline</application>, the input-related 15 library used by <application>Bash</application> and most other 16 shells.</para> 17 18 <para>For more information, see the bash info page, section 19 <emphasis>Readline Init File</emphasis>. The readline info page is 20 also a good source of information.</para> 21 22 <para>Global values are set in <filename>/etc/inputrc</filename>. 23 Personal user values are set in <filename>~/.inputrc</filename>. The 24 <filename>~/.inputrc</filename> file will override the global settings 25 file. A later page sets up Bash to use 26 <filename>/etc/inputrc</filename> if there is no 27 <filename>.inputrc</filename> for a user when 28 <filename>/etc/profile</filename> is read (usually at login). To make 29 the system use both, or to negate global keyboard handling, it is a 30 good idea to place a default <filename>.inputrc</filename> into the 31 <filename class="directory">/etc/skel</filename> directory for use 32 with new users.</para> 33 34 <para>Below is a base <filename>/etc/inputrc</filename>, along with 35 comments to explain what the various options do. Note that comments 36 cannot be on the same line as commands.</para> 37 38 <para>To create the <filename>.inputrc</filename> in <filename 39 class="directory">/etc/skel</filename> using the command below, change 40 the command's output to <filename 41 class="directory">/etc/skel/.inputrc</filename> and be sure to 42 check/set permissions afterward. Copy that file to 43 <filename>/etc/inputrc</filename> and the home directory of any user 44 already existing on the system, including <emphasis>root</emphasis>, 45 that needs a private version of the file. Be certain to use the 46 <parameter>-p</parameter> parameter of <command>cp</command> to 47 maintain permissions and be sure to change owner and group 48 appropriately.</para> 11 49 12 50 <screen><userinput>cat > /etc/inputrc << "EOF" … … 57 95 58 96 </sect1> 97 -
chapter07/introduction.xml
r2f9131f r81fd230 8 8 <?dbhtml filename="introduction.html"?> 9 9 10 <para>See testing</para> 10 <para>This chapter details how to install the bootscripts and set them up 11 properly. Most of these scripts will work without modification, but a 12 few require additional configuration files because they deal with 13 hardware-dependent information.</para> 14 15 <para>System-V style init scripts are employed in this book because they are 16 widely used. For additional options, a hint detailing the BSD style 17 init setup is available at 18 <ulink 19 url="http://www.linuxfromscratch.org/hints/downloads/files/bsd-init.txt"/>. 20 Searching the LFS mailing lists for <quote>depinit</quote> will also offer 21 additional choices.</para> 22 23 <para>If using an alternate style of init scripts, skip this chapter 24 and move on to <xref linkend="chapter-bootable"/>.</para> 11 25 12 26 </sect1> 27 -
chapter07/network.xml
r2f9131f r81fd230 8 8 <?dbhtml filename="network.html"?> 9 9 10 <indexterm zone="ch-scripts-network"> 11 <primary sortas="d-network">network</primary> 12 <secondary>configuring</secondary></indexterm> 13 14 <para>This section only applies if a network card is to be 15 configured.</para> 16 17 <para>If a network card will not be used, there is likely no need to 18 create any configuration files relating to network cards. If that is 19 the case, remove the <filename class="symlink">network</filename> 20 symlinks from all run-level directories (<filename 21 class="directory">/etc/rc.d/rc*.d</filename>).</para> 10 22 11 23 <sect2> 12 24 <title>Creating Network Interface Configuration Files</title> 13 25 14 <para>The following command creates a sample <filename>ipv4</filename> file for the 15 <filename>eth0</filename> device:</para> 26 <!-- Edit Me --> 27 <para>Which interfaces are brought up and down by the network script 28 depends on the files and directories in the <filename 29 class="directory">/etc/sysconfig/network-devices</filename> hierarchy. 30 This directory should contain a directory for each interface to be configured, 31 such as <filename>ifconfig.xyz</filename>, where <quote>xyz</quote> is a 32 network interface name. Inside this directory would be files defining 33 the attributes to this interface, such as its IP address(es), subnet 34 masks, and so forth.</para> 35 <!-- --> 36 37 <para>If the <filename 38 class="directory">/etc/sysconfig/network-devices</filename> directory 39 is to be renamed or moved, make sure to edit the 40 <filename>/etc/sysconfig/rc</filename> file and update the 41 <quote>network_devices</quote> option by providing it with the new 42 path.</para> 43 44 <para>New files are created in this directory. The following 45 command creates a sample <filename>ipv4</filename> file for the 46 <emphasis>eth0</emphasis> device:</para> 16 47 17 48 <screen><userinput>cd /etc/sysconfig/network-devices && … … 26 57 EOF</userinput></screen> 27 58 59 <para>The values of these variables must be changed in every file to 60 match the proper setup. If the <envar>ONBOOT</envar> variable is 61 set to <quote>yes</quote> the network script will bring up the 62 Network Interface Card (NIC) during booting of the system. If set 63 to anything but <quote>yes</quote> the NIC will be ignored by the 64 network script and not brought up.</para> 65 66 <para>The <envar>SERVICE</envar> variable defines the method of 67 obtaining the IP address. The LFS bootscripts have a modular IP 68 assignment format, and creating additional files in the <filename 69 class="directory">/etc/sysconfig/network-devices/services</filename> 70 directory allows other IP assignment methods. This is commonly used 71 for Dynamic Host Configuration Protocol (DHCP), which is addressed in the BLFS book.</para> 72 73 <para>The <envar>GATEWAY</envar> variable should contain 74 the default gateway IP address, if one is present. If not, then comment out 75 the variable entirely.</para> 76 77 <para>The <envar>PREFIX</envar> variable needs to contain the 78 number of bits used in the subnet. Each octet in an IP address is 8 79 bits. If the subnet's netmask is 255.255.255.0, then it is using the 80 first three octets (24 bits) to specify the network number. If the 81 netmask is 255.255.255.240, it would be using the first 28 bits. 82 Prefixes longer than 24 bits are commonly used by DSL- and cable-based 83 Internet Service Providers (ISPs). In this example (PREFIX=24), the netmask 84 is 255.255.255.0. Adjust according to the specific subnet.</para> 85 28 86 </sect2> 29 87 30 88 <sect2 id="resolv.conf"> 31 89 <title>Creating the /etc/resolv.conf File</title> 90 <indexterm zone="resolv.conf"><primary sortas="e-/etc/resolv.conf">/etc/resolv.conf</primary></indexterm> 32 91 33 <para>Create the file by running the following:</para> 92 <para>If the system is going to be connected to the Internet, it will 93 need some means of Domain Name Service (DNS) name resolution to 94 resolve Internet domain names to IP addresses, and vice versa. This is 95 best achieved by placing the IP address of the DNS server, available 96 from the ISP or network administrator, into 97 <filename>/etc/resolv.conf</filename>. Create the file by running the 98 following:</para> 34 99 35 100 <screen><userinput>cat > /etc/resolv.conf << "EOF" … … 43 108 EOF</userinput></screen> 44 109 110 <para>Replace <replaceable>[IP address of the 111 nameserver]</replaceable> with the IP address of the DNS most 112 appropriate for the setup. There will often be more than one entry 113 (requirements demand secondary servers for fallback capability). If 114 you only need or want one DNS server, remove the second 115 <emphasis>nameserver</emphasis> line from the file. The IP address may 116 also be a router on the local network.</para> 45 117 </sect2> 46 118 47 119 </sect1> 120 -
chapter07/profile.xml
r2f9131f r81fd230 8 8 <?dbhtml filename="profile.html"?> 9 9 10 <indexterm zone="ch-scripts-profile"><primary sortas="e-/etc/profile">/etc/profile</primary></indexterm> 10 11 11 <para>Create the <filename>/etc/profile</filename> file:</para> 12 <para>The shell program <command>/bin/bash</command> (hereafter 13 referred to as <quote>the shell</quote>) uses a collection of startup 14 files to help create an environment to run in. Each file has a 15 specific use and may effect login and interactive environments 16 differently. The files in the <filename 17 class="directory">/etc</filename> directory provide global settings. 18 If an equivalent file exists in the home directory, it may override 19 the global settings.</para> 20 21 <para>An interactive login shell is started after a successful login, 22 using <command>/bin/login</command>, by reading the 23 <filename>/etc/passwd</filename> file. An interactive non-login shell 24 is started at the command-line (e.g., 25 <prompt>[prompt]$</prompt><command>/bin/bash</command>). A 26 non-interactive shell is usually present when a shell script is 27 running. It is non-interactive because it is processing a script and 28 not waiting for user input between commands.</para> 29 30 <para>For more information, see <command>info bash</command> - Nodes: 31 Bash Startup Files and Interactive Shells.</para> 32 33 <para>The files <filename>/etc/profile</filename> and 34 <filename>~/.bash_profile</filename> are read when the shell is 35 invoked as an interactive login shell.</para> 36 37 <para>A base <filename>/etc/profile</filename> below sets some 38 environment variables necessary for native language support. Setting 39 them properly results in:</para> 40 41 <itemizedlist> 42 <listitem><para>The output of programs translated into the native 43 language</para></listitem> 44 <listitem><para>Correct classification of characters into letters, 45 digits and other classes. This is necessary for Bash to properly 46 accept non-ASCII characters in command lines in non-English 47 locales</para></listitem> 48 <listitem><para>The correct alphabetical sorting order for the 49 country</para></listitem> 50 <listitem><para>Appropriate default paper size</para></listitem> 51 <listitem><para>Correct formatting of monetary, time, and date 52 values</para></listitem> 53 </itemizedlist> 54 55 <para>This script also sets the <envar>INPUTRC</envar> 56 environment variable that makes <application>Bash</application> and 57 <application>Readline</application> use the 58 <filename>/etc/inputrc</filename> file created earlier.</para> 59 60 <para>Replace <replaceable>[ll]</replaceable> below with the 61 two-letter code for the desired language (e.g., <quote>en</quote>) and 62 <replaceable>[CC]</replaceable> with the two-letter code for the 63 appropriate country (e.g., <quote>GB</quote>). It may also be 64 necessary to specify (and this is actually the preferred form) the 65 character encoding (e.g. <quote>iso8859-1</quote>) after a dot (so 66 that the result is <quote>en_GB.iso8859-1</quote>). Issue the 67 following command for more information:</para> 68 69 <screen><userinput>man 3 setlocale</userinput></screen> 70 71 <para>The list of all locales supported by Glibc can be obtained by running 72 the following command:</para> 73 74 <screen><userinput>locale -a</userinput></screen> 75 76 <para>Once the proper locale settings have been determined, create the 77 <filename>/etc/profile</filename> file:</para> 12 78 13 79 <screen><userinput>cat > /etc/profile << "EOF" … … 21 87 EOF</userinput></screen> 22 88 89 <note><para>The <quote>C</quote> (default) and <quote>en_US</quote> 90 (the recommended one for United States English users) locales are 91 different.</para></note> 92 93 <para>Setting the keyboard layout, screen font, and 94 locale-related environment variables are the only internationalization 95 steps needed to support locales that use ordinary single-byte 96 encodings and left-to-right writing direction. More complex cases 97 (including UTF-8 based locales) require additional steps and 98 additional patches because many applications tend to not work properly 99 under such conditions. These steps and patches are not included in 100 the LFS book and such locales are not supported by LFS in any 101 way.</para> 102 23 103 </sect1> 104 -
chapter07/setclock.xml
r2f9131f r81fd230 8 8 <?dbhtml filename="setclock.html"?> 9 9 10 <indexterm zone="ch-scripts-setclock"> 11 <primary sortas="d-setclock">setclock</primary> 12 <secondary>configuring</secondary></indexterm> 13 14 <para>The <command>setclock</command> script reads the time from the hardware clock, 15 also known as BIOS or the Complementary Metal Oxide Semiconductor 16 (CMOS) clock. If the hardware clock is set to UTC, this script will convert the hardware clock's time to 17 the local time using the <filename>/etc/localtime</filename> file 18 (which tells the <command>hwclock</command> program which timezone the 19 user is in). There is no way to 20 detect whether or not the hardware clock is set to UTC time, so this 21 needs to be manually configured.</para> 22 23 <para>If you cannot remember whether or not the hardware 24 clock is set to UTC time, find out by running 25 the <userinput>hwclock --localtime --show</userinput> command. This will tell 26 what the current time is according to the hardware clock. If this time 27 matches whatever your watch says, then the hardware clock is set to 28 local time. If the output from <command>hwclock</command> is not local 29 time, chances are it is set to UTC time. Verify this by adding or 30 subtracting the proper amount of hours for the timezone to this 31 <command>hwclock</command> time. For example, if you live in the MST 32 timezone, which is also known as GMT -0700, add seven hours to the local 33 time. Then, account for Daylight Savings Time, which requires 34 subtracting an hour (or only add six in the first place) during the summer 35 months.</para> 36 37 <para>Change the value of the <envar>UTC</envar> variable below 38 to a value of <parameter>0</parameter> (zero) if the hardware clock 39 is <emphasis>not</emphasis> set to UTC time.</para> 10 40 11 41 <para>Create a new file <filename>/etc/sysconfig/clock</filename> by running … … 20 50 EOF</userinput></screen> 21 51 52 <para>A good hint explaining how to deal with time on LFS is available 53 at <ulink url="&hints-root;time.txt"/>. It explains issues such as 54 time zones, UTC, and the <envar>TZ</envar> environment variable.</para> 55 22 56 </sect1> 57 -
chapter07/udev.xml
r2f9131f r81fd230 12 12 <secondary>usage</secondary></indexterm> 13 13 14 15 <para>See testing</para> 14 <para>In <xref linkend="chapter-building-system"/>, we installed the Udev 15 package. Before we go into the details regarding how this works, 16 a brief history of previous methods of handling devices is in 17 order.</para> 18 19 <para>Linux systems in general traditionally use a static device 20 creation method, whereby a great many device nodes are created under 21 <filename class="directory">/dev</filename> (sometimes literally 22 thousands of nodes), regardless of whether the corresponding hardware 23 devices actually exist. This is typically done via a 24 <command>MAKEDEV</command> script, which contains a number of 25 calls to the <command>mknod</command> program with the relevant major and minor device 26 numbers for every possible device that might exist in the world. Using 27 the udev method, only those devices which are detected by the kernel 28 get device nodes created for them. Because these device nodes will be 29 created each time the system boots, they will be stored on a 30 <systemitem class="filesystem">ramfs</systemitem> (a file system that 31 resides entirely in memory and does not take up any disk space). 32 Device nodes do not require much disk space, so the memory that is 33 used in negligable.</para> 34 35 <sect2> 36 <title>History</title> 37 38 <para>In February 2000, a new filesystem called <systemitem 39 class="filesystem">devfs</systemitem> was merged into the 2.3.46 40 kernel and was made available during the 2.4 series of 41 stable kernels. Although it was present in the kernel source itself, 42 this method of creating devices dynamically never received 43 overwhelming support from the core kernel developers.</para> 44 45 <para>The main problem with the approach adopted by <systemitem 46 class="filesystem">devfs</systemitem> was the way it handled 47 device detection, creation, and naming. The latter issue, that of 48 device node naming, was perhaps the most critical. It is generally 49 accepted that if device names are allowed to be configurable, then 50 the device naming policy should be up to a system administrator, not 51 imposed on them by any particular developer(s). The <systemitem 52 class="filesystem">devfs</systemitem> file system also suffers from race 53 conditions that are inherent in its design and cannot be fixed 54 without a substantial revision to the kernel. It has also been marked 55 as deprecated due to a lack of recent maintenance.</para> 56 57 <para>With the development of the unstable 2.5 kernel tree, later 58 released as the 2.6 series of stable kernels, a new virtual filesystem 59 called <systemitem class="filesystem">sysfs</systemitem> came to be. 60 The job of <systemitem class="filesystem">sysfs</systemitem> is to 61 export a view of the system's structure to userspace processes. With 62 this userspace visible representation, the possibility of seeing a 63 userspace replacement for <systemitem 64 class="filesystem">devfs</systemitem> became much more 65 realistic.</para> 66 </sect2> 67 68 <sect2> 69 <title>Udev Implementation</title> 70 71 <para>The <systemitem class="filesystem">sysfs</systemitem> filesystem 72 was mentioned briefly above. One may wonder how <systemitem 73 class="filesystem">sysfs</systemitem> knows about the devices present 74 on a system and what device numbers should be used. Drivers that 75 have been compiled into the kernel directly register their objects 76 with <systemitem class="filesystem">sysfs</systemitem> as they are 77 detected by the kernel. For drivers compiled as modules, this will 78 happen when the module is loaded. Once the <systemitem 79 class="filesystem">sysfs</systemitem> filesystem is mounted (on 80 <filename class="directory">/sys</filename>), the data which the 81 built-in drivers registered with <systemitem 82 class="filesystem">sysfs</systemitem> are available to userspace 83 processes and to <command>udev</command> for device node creation.</para> 84 85 <para>The <command>S10udev</command> initscript takes care of creating 86 these device nodes when Linux is booted. This script starts with 87 registering <command>/sbin/udev</command> as a hotplug event handler. 88 Hotplug events (discussed below) should not be generated during this 89 stage, but <command>udev</command> is registered just in case they do 90 occur. The <command>udevstart</command> program then walks through 91 the <systemitem class="filesystem">/sys</systemitem> filesystem and 92 creates devices under <filename class="directory">/dev</filename> that 93 match the descriptions. For example, 94 <filename>/sys/class/tty/vcs/dev</filename> contains the string 95 <quote>7:0</quote> This string is used by <command>udevstart</command> 96 to create <filename>/dev/vcs</filename> with major number 97 <emphasis>7</emphasis> and minor <emphasis>0</emphasis>. The 98 permissions of each and every device that <command>udevstart</command> 99 creates are set using files from the <filename 100 class="directory">/etc/udev.d/permissions.d/</filename> directory. 101 These are numbered in a similar fashion to the LFS bootscripts. If 102 <command>udev</command> cannot find a permissions file for the device 103 it is creating, it will default permissions to 104 <emphasis>600</emphasis> and ownership to 105 <emphasis>root:root</emphasis>. The names of the nodes created under 106 the <filename class="directory">/dev</filename> directory are 107 configured according to the rules specified in the files within the 108 <filename class="directory">/etc/udev/rules.d/</filename> 109 directory.</para> 110 111 <para>Once the above stage is complete, all devices that were already 112 present and have compiled-in drivers will be available for use. What 113 about those devices that have modular drivers?</para> 114 115 <para>Earlier, we mentioned the concept of a <quote>hotplug event 116 handler.</quote> When a new device connection is detected by the 117 kernel, the kernel will generate a hotplug event and look at the file 118 <filename>/proc/sys/kernel/hotplug</filename> to find out the 119 userspace program that handles the device's connection. The 120 <command>udev</command> initscript registered <command>udev</command> 121 as this handler. When these hotplug events are generated, the kernel 122 will tell <command>udev</command> to check the <filename 123 class="directory">/sys</filename> filesystem for the information 124 pertaining to this new device and create the <filename 125 class="directory">/dev</filename> entry for it.</para> 126 127 <para>This brings us to one problem that exists with 128 <command>udev</command>, and likewise with <systemitem 129 class="filesystem">devfs</systemitem> before it. It is commonly 130 referred to as the <quote>chicken and egg</quote> problem. Most Linux 131 distrubtions handle loading modules via entries in 132 <filename>/etc/modules.conf</filename>. Access to a device node causes 133 the appropriate kernel module to load. With <command>udev</command>, 134 this method will not work because the device node does not exist until 135 the module is loaded. To solve this, the 136 <command>S05modules</command> bootscript was added to the 137 lfs-bootscripts package, along with the 138 <filename>/etc/sysconfig/modules</filename> file. By 139 adding module 140 names to the <filename>modules</filename> file, these modules will be 141 loaded when the computer is starting up. This allows 142 <command>udev</command> to detect the devices and create the 143 appropriate device nodes.</para> 144 145 <para>Note that on slower machines or for drivers that create a lot 146 of device nodes, the process of creating devices may take a few 147 seconds to complete. This means that some device nodes may not be 148 immediately accessible.</para> 149 </sect2> 150 151 <sect2> 152 <title>Handling Hotpluggable/Dynamic Devices</title> 153 154 <para>When you plug in a device, such a Universal Serial Bus (USB) MP3 player, the kernel 155 recognizes that the device is now connected and generates a hotplug 156 event. If the driver is already loaded (either because it was compiled 157 into the kernel or because it was loaded via the 158 <command>S05modules</command> bootscript), <command>udev</command> will 159 be called upon to create the relevant device node(s) according to the 160 <systemitem class="filesystem">sysfs</systemitem> data available in 161 <filename class="directory">/sys</filename>. If the driver for the 162 just plugged in device is available as a module but currently unloaded, 163 then attaching the device to the system will only cause the kernel's 164 bus driver to generate a hotplug event that notifies userspace of the 165 new device connection and it not being attached to a driver. In 166 effect, nothing happens and the device itself is not usable 167 yet.</para> 168 169 <para>If building a system that has a lot of drivers compiled as 170 modules rather than directly built into the kernel, using the 171 <command>S05modules</command> may not be practical. The Hotplug 172 package (see <ulink url="http://linux-hotplug.sourceforge.net/"/>) can 173 be beneficial in these cases. When the Hotplug package is installed, 174 it will respond to the aforementioned kernel's bus driver hotplug 175 events. The Hotplug package will load the appropriate module and make 176 this device available by creating the device node(s) for it.</para> 177 </sect2> 178 179 <sect2> 180 <title>Problems with Creating Devices</title> 181 182 <para>There are a few known problems when it comes to automatically creating 183 devices nodes:</para> 184 185 <para>1) A kernel driver may not export its data to <systemitem 186 class="filesystem">sysfs</systemitem>.</para> 187 188 <para>This is most common with third party drivers from outside the 189 kernel tree. These drivers will not end up having their device nodes 190 created. Use the 191 <filename>/etc/sysconfig/createfiles</filename> configuration file to 192 manually create the devices. Consult the 193 <filename>devices.txt</filename> file inside the kernel documentation 194 or the documentation for that driver to find the proper major/minor 195 numbers.</para> 196 197 <para>2) A non-hardware device is required. This is most common with 198 the Advanced Linux Sound Architecture (ALSA) project's Open Sound 199 System (OSS) compatibility module. These types of devices can be 200 handled in one of two ways:</para> 201 202 <itemizedlist> 203 204 <listitem><para>Adding the module names to 205 <filename>/etc/sysconfig/modules</filename></para></listitem> 206 <listitem><para>Using an 207 <quote>install</quote> line in 208 <filename>/etc/modprobe.conf</filename>. This tells the 209 <command>modprobe</command> command <quote>when loading this module, 210 also load this other module, at the same time.</quote> For example:</para> 211 212 <screen><userinput>install snd-pcm modprobe -i snd-pcm ; modprobe \ 213 snd-pcm-oss ; true</userinput></screen> 214 215 <para>This will cause the system to load both the 216 <emphasis>snd-pcm</emphasis> and <emphasis>snd-pcm-oss</emphasis> 217 modules when any request is made to load the driver 218 <emphasis>snd-pcm</emphasis>.</para></listitem> 219 </itemizedlist> 220 </sect2> 221 222 <sect2> 223 <title>Useful Reading</title> 224 225 <para>Additional helpful documentation is available at the following 226 sites:</para> 227 228 <itemizedlist> 229 <listitem><para remap="verbatim">A Userspace Implementation of devfs 230 <ulink url="http://www.kroah.com/linux/talks/ols_2003_udev_paper/Reprint-Kroah-Hartman-OLS2003.pdf"><phrase 231 condition="pdf">http://www.kroah.com/linux/talks/ols_2003_udev_paper/ 232 Reprint-Kroah-Hartman-OLS2003.pdf</phrase></ulink></para></listitem> 233 234 <listitem><para remap="verbatim">udev FAQ 235 <ulink url="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev-FAQ"/></para></listitem> 236 237 <listitem><para remap="verbatim">The Linux Kernel Driver Model 238 <ulink url="http://public.planetmirror.com/pub/lca/2003/proceedings/papers/Patrick_Mochel/Patrick_Mochel.pdf"><phrase 239 condition="pdf">http://public.planetmirror.com/pub/lca/2003/proceedings/papers/ 240 Patrick_Mochel/Patrick_Mochel.pdf</phrase></ulink></para></listitem> 241 </itemizedlist> 242 </sect2> 16 243 17 244 </sect1> -
chapter07/usage.xml
r2f9131f r81fd230 8 8 <?dbhtml filename="usage.html"?> 9 9 10 <indexterm zone="ch-scripts-usage"> 11 <primary sortas="a-Bootscripts">Bootscripts</primary> 12 <secondary>usage</secondary></indexterm> 10 13 11 <para>See testing</para> 14 <para>Linux uses a special booting facility named SysVinit that is 15 based on a concept of <emphasis>run-levels</emphasis>. It can be quite 16 different from one system to another, so it cannot be assumed that 17 because things worked in <insert distro name>, they should work 18 the same in LFS too. LFS has its own way of doing things, but it 19 respects generally accepted standards.</para> 20 21 <para>SysVinit (which will be referred to as <quote>init</quote> from 22 now on) works using a run-levels scheme. There are seven (from 0 to 6) 23 run-levels (actually, there are more run-levels, but they are for 24 special cases and are generally not used. The init man page describes 25 those details), and each one of those corresponds to the actions the 26 computer is supposed to perform when it starts up. The default 27 run-level is 3. Here are the descriptions of the different run-levels 28 as they are implemented:</para> 29 30 <literallayout>0: halt the computer 31 1: single-user mode 32 2: multi-user mode without networking 33 3: multi-user mode with networking 34 4: reserved for customization, otherwise does the same as 3 35 5: same as 4, it is usually used for GUI login (like X's <command>xdm</command> or KDE's <command>kdm</command>) 36 6: reboot the computer</literallayout> 37 38 <para>The command used to change run-levels is <command>init 39 <replaceable>[runlevel]</replaceable></command>, where 40 <replaceable>[runlevel]</replaceable> is the target run-level. For 41 example, to reboot the computer, a user would issue the <command>init 42 6</command> command. The <command>reboot</command> command is an 43 alias for it, as is the <command>halt</command> command an alias for 44 <command>init 0</command>.</para> 45 46 <para>There are a number of directories under <filename 47 class="directory">/etc/rc.d</filename> that look like <filename 48 class="directory">rc?.d</filename> (where ? is the number of the 49 run-level) and <filename class="directory">rcsysinit.d</filename>, all 50 containing a number of symbolic links. Some begin with a 51 <emphasis>K</emphasis>, the others begin with an 52 <emphasis>S</emphasis>, and all of them have two numbers following the 53 initial letter. The K means to stop (kill) a service and the S means 54 to start a service. The numbers determine the order in which the 55 scripts are run, from 00 to 99—the lower the number the earlier it 56 gets executed. When init switches to another run-level, the 57 appropriate services get killed and others get started.</para> 58 59 <para>The real scripts are in <filename 60 class="directory">/etc/rc.d/init.d</filename>. They do the actual 61 work, and the symlinks all point to them. Killing links and starting 62 links point to the same script in <filename 63 class="directory">/etc/rc.d/init.d</filename>. This is because the 64 scripts can be called with different parameters like 65 <parameter>start</parameter>, <parameter>stop</parameter>, 66 <parameter>restart</parameter>, <parameter>reload</parameter>, and 67 <parameter>status</parameter>. When a K link is encountered, the 68 appropriate script is run with the <parameter>stop</parameter> 69 argument. When an S link is encountered, the appropriate script is run 70 with the <parameter>start</parameter> argument.</para> 71 72 <para>There is one exception to this explanation. Links that start 73 with an <emphasis>S</emphasis> in the <filename 74 class="directory">rc0.d</filename> and <filename 75 class="directory">rc6.d</filename> directories will not cause anything 76 to be started. They will be called with the parameter 77 <parameter>stop</parameter> to stop something. The logic behind this 78 is that when a user is going to reboot or halt the system, nothing 79 needs to be started. The system only needs to be stopped.</para> 80 81 <para>These are descriptions of what the arguments make the scripts 82 do:</para> 83 84 <variablelist> 85 <varlistentry> 86 <term><parameter>start</parameter></term> 87 <listitem><para>The service is started.</para></listitem> 88 </varlistentry> 89 90 <varlistentry> 91 <term><parameter>stop</parameter></term> 92 <listitem><para>The service is stopped.</para></listitem> 93 </varlistentry> 94 95 <varlistentry> 96 <term><parameter>restart</parameter></term> 97 <listitem><para>The service is stopped and then started again.</para></listitem> 98 </varlistentry> 99 100 <varlistentry> 101 <term><parameter>reload</parameter></term> 102 <listitem><para>The configuration of the service is updated. 103 This is used after the configuration file of a service was modified, when 104 the service does not need to be restarted.</para></listitem> 105 </varlistentry> 106 107 <varlistentry> 108 <term><parameter>status</parameter></term> 109 <listitem><para>Tells if the service is running and with which PIDs.</para></listitem> 110 </varlistentry> 111 </variablelist> 112 113 <para>Feel free to modify the way the boot process works (after all, 114 it is your own LFS system). The files given here are an example of how 115 it can be done.</para> 12 116 13 117 </sect1> 118
Note:
See TracChangeset
for help on using the changeset viewer.