diff options
author | Archaic <archaic@linuxfromscratch.org> | 2006-04-13 18:45:33 +0000 |
---|---|---|
committer | Archaic <archaic@linuxfromscratch.org> | 2006-04-13 18:45:33 +0000 |
commit | d2c332bc21267f5e01cb545d3f01cae1dcacdae3 (patch) | |
tree | 1514dfbf9b2db00d013d0f64558eef3fcdc1b402 /chapter06 | |
parent | dd7ed7b42feb0b8c450dcf2314e11cbfb0de03c6 (diff) |
Merged the udev_update branch to trunk.
git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@7509 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
Diffstat (limited to 'chapter06')
-rw-r--r-- | chapter06/changingowner.xml | 40 | ||||
-rw-r--r-- | chapter06/chapter06.xml | 6 | ||||
-rw-r--r-- | chapter06/chroot.xml | 18 | ||||
-rw-r--r-- | chapter06/createfiles.xml | 116 | ||||
-rw-r--r-- | chapter06/creatingdirs.xml | 2 | ||||
-rw-r--r-- | chapter06/devices.xml | 93 | ||||
-rw-r--r-- | chapter06/hotplug.xml | 223 | ||||
-rw-r--r-- | chapter06/introduction.xml | 7 | ||||
-rw-r--r-- | chapter06/iproute2.xml | 4 | ||||
-rw-r--r-- | chapter06/kernfs.xml | 79 | ||||
-rw-r--r-- | chapter06/pkgmgt.xml | 8 | ||||
-rw-r--r-- | chapter06/udev.xml | 233 |
12 files changed, 356 insertions, 473 deletions
diff --git a/chapter06/changingowner.xml b/chapter06/changingowner.xml deleted file mode 100644 index 83deca414..000000000 --- a/chapter06/changingowner.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" - "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [ - <!ENTITY % general-entities SYSTEM "../general.ent"> - %general-entities; -]> - -<sect1 id="ch-system-changingowner"> - <?dbhtml filename="changingowner.html"?> - - <title>Changing Ownership</title> - - <para>Currently, the <filename class="directory">/tools</filename> directory - is owned by the user <systemitem class="username">lfs</systemitem>, a user - that exists only on the host system. Although the <filename - class="directory">/tools</filename> directory can be deleted once the LFS - system has been finished, it can be retained to build additional LFS systems. - If the <filename class="directory">/tools</filename> directory is kept as is, - the files are owned by a user ID without a corresponding account. This is - dangerous because a user account created later could get this same user ID - and would own the <filename class="directory">/tools</filename> directory - and all the files therein, thus exposing these files to possible malicious - manipulation.</para> - - <para>To avoid this issue, add the <systemitem class="username">lfs</systemitem> - user to the new LFS system later when creating the - <filename>/etc/passwd</filename> file, taking care to assign it the same user - and group IDs as on the host system. Alternatively, assign the contents of - the <filename class="directory">/tools</filename> directory to user - <systemitem class="username">root</systemitem> by running the following - command:</para> - -<screen><userinput>chown -R 0:0 /tools</userinput></screen> - - <para>The command uses <parameter>0:0</parameter> instead of - <parameter>root:root</parameter>, because <command>chown</command> - is unable to resolve the name <quote>root</quote> until the - <filename>passwd</filename> file has been created.</para> - -</sect1> diff --git a/chapter06/chapter06.xml b/chapter06/chapter06.xml index 4186fd7bb..5715d6be9 100644 --- a/chapter06/chapter06.xml +++ b/chapter06/chapter06.xml @@ -12,14 +12,11 @@ <title>Installing Basic System Software</title> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="introduction.xml"/> - <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="pkgmgt.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="kernfs.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="pkgmgt.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="chroot.xml"/> - <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="changingowner.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="creatingdirs.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="createfiles.xml"/> - <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="pwdgroup.xml"/> - <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="devices.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="linux-libc-headers.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="man-pages.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="glibc.xml"/> @@ -53,7 +50,6 @@ <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="grep.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="groff.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="gzip.xml"/> - <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="hotplug.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="inetutils.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="iproute2.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="kbd.xml"/> diff --git a/chapter06/chroot.xml b/chapter06/chroot.xml index ca3e86a92..ea213033e 100644 --- a/chapter06/chroot.xml +++ b/chapter06/chroot.xml @@ -44,16 +44,18 @@ reason, hashing is switched off by passing the <parameter>+h</parameter> option to <command>bash</command>.</para> - <para>It is important that all the commands throughout the remainder of this - chapter and the following chapters are run from within the chroot environment. - If you leave this environment for any reason (rebooting for example), remember - to first mount the <systemitem class="filesystem">proc</systemitem> and - <systemitem class="filesystem">devpts</systemitem> file systems (discussed - in the previous section) and enter chroot again before continuing with the - installations.</para> - <para>Note that the <command>bash</command> prompt will say <computeroutput>I have no name!</computeroutput> This is normal because the <filename>/etc/passwd</filename> file has not been created yet.</para> + <note> + <para>It is important that all the commands throughout the remainder of this + chapter and the following chapters are run from within the chroot + environment. If you leave this environment for any reason (rebooting for + example), ensure that the virtual kernel filesystems are mounted as + explained in <xref linkend="ch-system-bindmount"/> and <xref + linkend="ch-system-kernfsmount"/> and enter chroot again before continuing + with the installation.</para> + </note> + </sect1> diff --git a/chapter06/createfiles.xml b/chapter06/createfiles.xml index ae22a241d..0cfc7596f 100644 --- a/chapter06/createfiles.xml +++ b/chapter06/createfiles.xml @@ -8,7 +8,31 @@ <sect1 id="ch-system-createfiles"> <?dbhtml filename="createfiles.html"?> - <title>Creating Essential Symlinks</title> + <title>Creating Essential Files and Symlinks</title> + + <indexterm zone="ch-system-createfiles"> + <primary sortas="e-/etc/passwd">/etc/passwd</primary> + </indexterm> + + <indexterm zone="ch-system-createfiles"> + <primary sortas="e-/etc/group">/etc/group</primary> + </indexterm> + + <indexterm zone="ch-system-createfiles"> + <primary sortas="e-/var/run/utmp">/var/run/utmp</primary> + </indexterm> + + <indexterm zone="ch-system-createfiles"> + <primary sortas="e-/var/log/btmp">/var/log/btmp</primary> + </indexterm> + + <indexterm zone="ch-system-createfiles"> + <primary sortas="e-/var/log/lastlog">/var/log/lastlog</primary> + </indexterm> + + <indexterm zone="ch-system-createfiles"> + <primary sortas="e-/var/log/wtmp">/var/log/wtmp</primary> + </indexterm> <para>Some programs use hard-wired paths to programs which do not exist yet. In order to satisfy these programs, create a number of symbolic links which will be @@ -20,4 +44,94 @@ ln -sv /tools/bin/perl /usr/bin ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib ln -sv bash /bin/sh</userinput></screen> + <para>A proper Linux system maintains a list of the mounted file systems in + the file <filename>/etc/mtab</filename>. Normally, this file would be + created when we mount a new file system. Since we will not be mounting any + file systems inside our chroot environment, create an empty file for + utilities that expect the presence of <filename>/etc/mtab</filename>:</para> + +<screen><userinput>touch /etc/mtab</userinput></screen> + + <para>In order for user <systemitem class="username">root</systemitem> to be + able to login and for the name <quote>root</quote> to be recognized, there + must be relevant entries in the <filename>/etc/passwd</filename> and + <filename>/etc/group</filename> files.</para> + + <para>Create the <filename>/etc/passwd</filename> file by running the following + command:</para> + +<screen><userinput>cat > /etc/passwd << "EOF" +<literal>root:x:0:0:root:/root:/bin/bash</literal> +EOF</userinput></screen> + + <para>The actual password for <systemitem class="username">root</systemitem> + (the <quote>x</quote> used here is just a placeholder) will be set later.</para> + + <para>Create the <filename>/etc/group</filename> file by running the following + command:</para> + +<screen><userinput>cat > /etc/group << "EOF" +<literal>root:x:0: +bin:x:1: +sys:x:2: +kmem:x:3: +tty:x:4: +tape:x:5: +daemon:x:6: +floppy:x:7: +disk:x:8: +lp:x:9: +dialout:x:10: +audio:x:11: +video:x:12: +utmp:x:13: +usb:x:14: +cdrom:x:15:</literal> +EOF</userinput></screen> + + <para>The created groups are not part of any standard—they are groups + decided on in part by the requirements of the Udev configuration in this + chapter, and in part by common convention employed by a number of existing + Linux distributions. The Linux Standard Base (LSB, available at <ulink + url="http://www.linuxbase.org"/>) recommends only that, besides the group + <systemitem class="groupname">root</systemitem> with a Group ID (GID) of 0, + a group <systemitem class="groupname">bin</systemitem> with a GID of 1 be + present. All other group names and GIDs can be chosen freely by the system + administrator since well-written programs do not depend on GID numbers, but + rather use the group's name.</para> + + <para>To remove the <quote>I have no name!</quote> prompt, start a new + shell. Since a full Glibc was installed in <xref + linkend="chapter-temporary-tools"/> and the + <filename>/etc/passwd</filename> and <filename>/etc/group</filename> + files have been created, user name and group name resolution will now + work.</para> + +<screen role="nodump"><userinput>exec /tools/bin/bash --login +h</userinput></screen> + + <para>Note the use of the <parameter>+h</parameter> directive. This tells + <command>bash</command> not to use its internal path hashing. Without this + directive, <command>bash</command> would remember the paths to binaries it has + executed. To ensure the use of the newly compiled binaries as soon as they are + installed, the <parameter>+h</parameter> directive will be used for the duration + of this chapter.</para> + + <para>The <command>login</command>, <command>agetty</command>, and + <command>init</command> programs (and others) use a number of log + files to record information such as who was logged into the system and + when. However, these programs will not write to the log files if they + do not already exist. Initialize the log files and give them + proper permissions:</para> + +<screen><userinput>touch /var/run/utmp /var/log/{btmp,lastlog,wtmp} +chgrp -v utmp /var/run/utmp /var/log/lastlog +chmod -v 664 /var/run/utmp /var/log/lastlog</userinput></screen> + + <para>The <filename>/var/run/utmp</filename> file records the users + that are currently logged in. The <filename>/var/log/wtmp</filename> + file records all logins and logouts. The + <filename>/var/log/lastlog</filename> file records when + each user last logged in. The <filename>/var/log/btmp</filename> file + records the bad login attempts.</para> + </sect1> diff --git a/chapter06/creatingdirs.xml b/chapter06/creatingdirs.xml index b9a269ebc..4e602b356 100644 --- a/chapter06/creatingdirs.xml +++ b/chapter06/creatingdirs.xml @@ -13,7 +13,7 @@ <para>It is time to create some structure in the LFS file system. Create a standard directory tree by issuing the following commands:</para> -<screen><userinput>install -dv /{bin,boot,dev,etc/opt,home,lib,mnt} +<screen><userinput>install -dv /{bin,boot,etc/opt,home,lib,mnt} install -dv /{sbin,srv,usr/local,var,opt} install -dv /root -m 0750 install -dv /tmp /var/tmp -m 1777 diff --git a/chapter06/devices.xml b/chapter06/devices.xml deleted file mode 100644 index 51821fe84..000000000 --- a/chapter06/devices.xml +++ /dev/null @@ -1,93 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" - "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [ - <!ENTITY % general-entities SYSTEM "../general.ent"> - %general-entities; -]> - -<sect1 id="ch-system-devices"> - <?dbhtml filename="devices.html"?> - - <title>Populating /dev</title> - - <indexterm zone="ch-system-devices"> - <primary sortas="e-/dev/">/dev/*</primary> - </indexterm> - - <sect2> - <title>Creating Initial Device Nodes</title> - - <para>When the kernel boots the system, it requires the presence of a few - device nodes, in particular the <filename class="devicefile">console</filename> - and <filename class="devicefile">null</filename> devices. The device nodes - will be created on the hard disk so that they are available before - <command>udev</command> has been started, and additionally when Linux is - started in single user mode (hence the restrictive permissions on - <filename class="devicefile">console</filename>). Create the devices by - running the following commands:</para> - -<screen><userinput>mknod -m 600 /dev/console c 5 1 -mknod -m 666 /dev/null c 1 3</userinput></screen> - - </sect2> - - <sect2> - <title>Mounting tmpfs and Populating /dev</title> - - <para>The recommended method of populating the <filename - class="directory">/dev</filename> directory with devices is to mount a - virtual filesystem (such as <systemitem class="filesystem">tmpfs</systemitem>) - on the <filename class="directory">/dev</filename> directory, and allow the - devices to be created dynamically on that virtual filesystem as they are - detected or accessed. This is generally done during the boot process. Since - this new system has not been booted, it is necessary to do what the - LFS-Bootscripts package would otherwise do by mounting <filename - class="directory">/dev</filename>:</para> - -<screen><userinput>mount -nvt tmpfs none /dev</userinput></screen> - - <para>The Udev package is what actually creates the devices in the <filename - class="directory">/dev</filename> directory. Since it will not be installed - until later on in the process, manually create the minimal set of device nodes - needed to complete the building of this system:</para> - -<screen><userinput>mknod -m 622 /dev/console c 5 1 -mknod -m 666 /dev/null c 1 3 -mknod -m 666 /dev/zero c 1 5 -mknod -m 666 /dev/ptmx c 5 2 -mknod -m 666 /dev/tty c 5 0 -mknod -m 444 /dev/random c 1 8 -mknod -m 444 /dev/urandom c 1 9 -chown -v root:tty /dev/{console,ptmx,tty}</userinput></screen> - - <para>There are some symlinks and directories required by LFS that are - created during system startup by the LFS-Bootscripts package. Since this - is a chroot environment and not a booted environment, those symlinks and - directories need to be created here:</para> - -<screen><userinput>ln -sv /proc/self/fd /dev/fd -ln -sv /proc/self/fd/0 /dev/stdin -ln -sv /proc/self/fd/1 /dev/stdout -ln -sv /proc/self/fd/2 /dev/stderr -ln -sv /proc/kcore /dev/core -mkdir -v /dev/pts -mkdir -v /dev/shm</userinput></screen> - - <para>Finally, mount the proper virtual (kernel) file systems on the - newly-created directories:</para> - -<screen><userinput>mount -vt devpts -o gid=4,mode=620 none /dev/pts -mount -vt tmpfs none /dev/shm</userinput></screen> - - <para>The <command>mount</command> commands executed above may result - in the following warning message:</para> - -<screen><computeroutput>can't open /etc/fstab: No such file or directory.</computeroutput></screen> - - <para>This file—<filename>/etc/fstab</filename>—has not - been created yet but is also not required for the file systems to be - properly mounted. As such, the warning can be safely ignored.</para> - - </sect2> - -</sect1> diff --git a/chapter06/hotplug.xml b/chapter06/hotplug.xml deleted file mode 100644 index d66e0c7e7..000000000 --- a/chapter06/hotplug.xml +++ /dev/null @@ -1,223 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" - "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [ - <!ENTITY % general-entities SYSTEM "../general.ent"> - %general-entities; -]> - -<sect1 id="ch-system-hotplug" role="wrap"> - <?dbhtml filename="hotplug.html"?> - - <title>Hotplug-&hotplug-version;</title> - - <indexterm zone="ch-system-hotplug"> - <primary sortas="a-Hotplug">Hotplug</primary> - </indexterm> - - <sect2 role="package"> - <title/> - - <para>The Hotplug package contains scripts that react upon hotplug events - generated by the kernel. Such events correspond to every change in the kernel - state visible in the <systemitem class="filesystem">sysfs</systemitem> - filesystem, e.g., the addition and removal of hardware. This package also - detects existing hardware during boot and inserts the relevant modules into the - running kernel.</para> - - <segmentedlist> - <segtitle>&buildtime;</segtitle> - <segtitle>&diskspace;</segtitle> - - <seglistitem> - <seg>0.01 SBU</seg> - <seg>460 KB</seg> - </seglistitem> - </segmentedlist> - - <segmentedlist> - <segtitle>&dependencies;</segtitle> - - <seglistitem> - <seg>Bash, Coreutils, Findutils, Gawk, and Make</seg> - </seglistitem> - </segmentedlist> - - </sect2> - - <sect2 role="installation"> - <title>Installation of Hotplug</title> - - <para>This package does not come with a test suite.</para> - - <para>Install the Hotplug package:</para> - -<screen><userinput>make install</userinput></screen> - - <para>Copy a file that the <quote>install</quote> target omits.</para> - -<screen><userinput>cp -v etc/hotplug/pnp.distmap /etc/hotplug</userinput></screen> - - <para>Remove the init script that Hotplug installs since we are going to be - using the script included in the LFS-Bootscripts package:</para> - -<screen><userinput>rm -rfv /etc/init.d</userinput></screen> - - <para>Network device hotplugging is not yet supported by the LFS-Bootscripts - package. For that reason, remove the network hotplug agent:</para> - -<screen><userinput>rm -fv /etc/hotplug/net.agent</userinput></screen> - - <para>Create a directory for storing firmware that can be loaded by - <command>hotplug</command>:</para> - -<screen><userinput>mkdir -v /lib/firmware</userinput></screen> - - </sect2> - - - <sect2 id="contents-hotplug" role="content"> - <title>Contents of Hotplug</title> - - <segmentedlist> - <segtitle>Installed program</segtitle> - <segtitle>Installed scripts</segtitle> - <segtitle>Installed files</segtitle> - - <seglistitem> - <seg>hotplug</seg> - <seg>/etc/hotplug/*.rc, /etc/hotplug/*.agent</seg> - <seg>/etc/hotplug/hotplug.functions, /etc/hotplug/blacklist, - /etc/hotplug/{pci,usb}, /etc/hotplug/usb.usermap, /etc/hotplug.d, - and /var/log/hotplug/events</seg> - </seglistitem> - </segmentedlist> - - <variablelist> - <bridgehead renderas="sect3">Short Descriptions</bridgehead> - <?dbfo list-presentation="list"?> - <?dbhtml list-presentation="table"?> - - <varlistentry id="hotplug"> - <term><command>hotplug</command></term> - <listitem> - <para>This script is called by default by the Linux kernel when - something changes in its internal state (e.g., a new device is - added or an existing device is removed)</para> - <indexterm zone="ch-system-hotplug hotplug"> - <primary sortas="b-hotplug">hotplug</primary> - </indexterm> - </listitem> - </varlistentry> - - <varlistentry id="hotplug-rc"> - <term><command>/etc/hotplug/*.rc</command></term> - <listitem> - <para>These scripts are used for cold plugging, i.e., detecting and - acting upon hardware already present during system startup. They are - called by the <filename>hotplug</filename> initscript included in - the LFS-Bootscripts package. The <command>*.rc</command> scripts try - to recover hotplug events that were lost during system boot because, - for example, the root filesystem was not mounted by the kernel</para> - <indexterm zone="ch-system-hotplug hotplug-rc"> - <primary sortas="d-/etc/hotplug/*.rc">/etc/hotplug/*.rc</primary> - </indexterm> - </listitem> - </varlistentry> - - <varlistentry id="hotplug-agent"> - <term><command>/etc/hotplug/*.agent</command></term> - <listitem> - <para>These scripts are called by <command>hotplug</command> in response - to different types of hotplug events generated by the kernel. Their - action is to insert corresponding kernel modules and call any - user-provided scripts</para> - <indexterm zone="ch-system-hotplug hotplug-agent"> - <primary sortas="d-/etc/hotplug/*.agent">/etc/hotplug/*.agent</primary> - </indexterm> - </listitem> - </varlistentry> - - <varlistentry id="hotplug-blacklist"> - <term><filename>/etc/hotplug/blacklist</filename></term> - <listitem> - <para>This file contains the list of modules that should never be - inserted into the kernel by the Hotplug scripts</para> - <indexterm zone="ch-system-hotplug hotplug-blacklist"> - <primary sortas="e-/etc/hotplug/blacklist">/etc/hotplug/blacklist</primary> - </indexterm> - </listitem> - </varlistentry> - - <varlistentry id="hotplug-functions"> - <term><filename>/etc/hotplug/hotplug.functions</filename></term> - <listitem> - <para>This file contains common functions used by other scripts in the - Hotplug package</para> - <indexterm zone="ch-system-hotplug hotplug-functions"> - <primary sortas="e-/etc/hotplug/hotplug.functions">/etc/hotplug/hotplug.functions</primary> - </indexterm> - </listitem> - </varlistentry> - - <varlistentry id="hotplug-subdirs"> - <term><filename class="directory">/etc/hotplug/{pci,usb}</filename></term> - <listitem> - <para>These directories contain user-written handlers for hotplug - events</para> - <indexterm zone="ch-system-hotplug hotplug-subdirs"> - <primary sortas="e-/etc/hotplug/{pci,usb}">/etc/hotplug/{pci,usb}</primary> - </indexterm> - </listitem> - </varlistentry> - - <varlistentry id="hotplug-usb.usermap"> - <term><filename>/etc/hotplug/usb.usermap</filename></term> - <listitem> - <para>This file contains rules that determine which user-defined handlers to - call for each USB device, based on its vendor ID and other - attributes</para> - <indexterm zone="ch-system-hotplug hotplug-usb.usermap"> - <primary sortas="e-/etc/hotplug/usb.usermap">/etc/hotplug/usb.usermap</primary> - </indexterm> - </listitem> - </varlistentry> - - <varlistentry id="hotplug-hotplug.d"> - <term><filename class="directory">/etc/hotplug.d</filename></term> - <listitem> - <para>This directory contains programs (or symlinks to them) that are - interested in receiving hotplug events. For example, Udev puts its - symlink here during installation</para> - <indexterm zone="ch-system-hotplug hotplug-hotplug.d"> - <primary sortas="e-/etc/hotplug.d">/etc/hotplug.d</primary> - </indexterm> - </listitem> - </varlistentry> - - <varlistentry id="hotplug-firmware"> - <term><filename class="directory">/lib/firmware</filename></term> - <listitem> - <para>This directory contains the firmware for devices that need to - have their firmware loaded before use</para> - <indexterm zone="ch-system-hotplug hotplug-firmware"> - <primary sortas="e-/lib/firmware">/lib/firmware</primary> - </indexterm> - </listitem> - </varlistentry> - - <varlistentry id="hotplug-events"> - <term><filename>/var/log/hotplug/events</filename></term> - <listitem> - <para>This file contains all the events that <command>hotplug</command> - has called since bootup</para> - <indexterm zone="ch-system-hotplug hotplug-events"> - <primary sortas="e-/var/log/hotplug/events">/var/log/hotplug/events</primary> - </indexterm> - </listitem> - </varlistentry> - - </variablelist> - - </sect2> - -</sect1> diff --git a/chapter06/introduction.xml b/chapter06/introduction.xml index 5e9cfd5c3..588d84780 100644 --- a/chapter06/introduction.xml +++ b/chapter06/introduction.xml @@ -55,11 +55,4 @@ there is a list of programs and libraries (along with brief descriptions of these) that the package installs.</para> - <note> - <para>At this point, you may wish to keep your finished temporary - tools for use in future LFS builds by creating a tarball of the - <filename class="directory">/tools</filename> directory and - storing it in a safe location.</para> - </note> - </sect1> diff --git a/chapter06/iproute2.xml b/chapter06/iproute2.xml index 84e4244e0..fdf93aa08 100644 --- a/chapter06/iproute2.xml +++ b/chapter06/iproute2.xml @@ -25,8 +25,8 @@ <segtitle>&diskspace;</segtitle> <seglistitem> - <seg>0.1 SBU</seg> - <seg>4.3 MB</seg> + <seg>0.2 SBU</seg> + <seg>4.8 MB</seg> </seglistitem> </segmentedlist> diff --git a/chapter06/kernfs.xml b/chapter06/kernfs.xml index 2bdf9f9c3..3c9e68c0b 100644 --- a/chapter06/kernfs.xml +++ b/chapter06/kernfs.xml @@ -8,33 +8,72 @@ <sect1 id="ch-system-kernfs"> <?dbhtml filename="kernfs.html"?> - <title>Mounting Virtual Kernel File Systems</title> + <title>Preparing Virtual Kernel File Systems</title> - <para>Various file systems exported by the kernel are used to communicate to and - from the kernel itself. These file systems are virtual in that no disk space is - used for them. The content of the file systems resides in memory.</para> + <indexterm zone="ch-system-kernfs"> + <primary sortas="e-/dev/">/dev/*</primary> + </indexterm> - <para>Begin by creating directories onto which the file systems will be - mounted:</para> + <para>Various file systems exported by the kernel are used to communicate to + and from the kernel itself. These file systems are virtual in that no disk + space is used for them. The content of the file systems resides in + memory.</para> -<screen><userinput>mkdir -pv $LFS/{proc,sys}</userinput></screen> + <para>Begin by creating directories onto which the file systems will be + mounted:</para> - <para>Now mount the file systems:</para> +<screen><userinput>mkdir -pv $LFS/{dev,proc,sys}</userinput></screen> -<screen><userinput>mount -vt proc proc $LFS/proc -mount -vt sysfs sysfs $LFS/sys</userinput></screen> + <sect2> + <title>Creating Initial Device Nodes</title> + + <para>When the kernel boots the system, it requires the presence of a few + device nodes, in particular the <filename + class="devicefile">console</filename> and <filename + class="devicefile">null</filename> devices. The device nodes will be created + on the hard disk so that they are available before <command>udev</command> + has been started, and additionally when Linux is started in single user mode + (hence the restrictive permissions on <filename + class="devicefile">console</filename>). Create the devices by running the + following commands:</para> + +<screen><userinput>mknod -m 600 $LFS/dev/console c 5 1 +mknod -m 666 $LFS/dev/null c 1 3</userinput></screen> + + </sect2> + + <sect2 id="ch-system-bindmount"> + <title>Mounting and Populating /dev</title> - <para>Remember that if for any reason you stop working on the LFS - system and start again later, it is important to check that these file - systems are mounted again before entering the chroot - environment.</para> + <para>The recommended method of populating the <filename + class="directory">/dev</filename> directory with devices is to mount a + virtual filesystem (such as <systemitem + class="filesystem">tmpfs</systemitem>) on the <filename + class="directory">/dev</filename> directory, and allow the devices to be + created dynamically on that virtual filesystem as they are detected or + accessed. This is generally done during the boot process by Udev. Since + this new system does not yet have Udev and has not yet been booted, it is + necessary to mount and populate <filename + class="directory">/dev</filename> manually. This is accomplished by bind + mounting the host system's <filename class="directory">/dev</filename> + directory. A bind mount is a special type of mount that allows you to + create a mirror of a directory or mount point to some other location. Use + the following command to achieve this:</para> - <para>Additional file systems will soon be mounted from within the - chroot environment. To keep the host up to date, perform a <quote>fake - mount</quote> for each of these now:</para> +<screen><userinput>mount --bind /dev $LFS/dev</userinput></screen> + + </sect2> + + <sect2 id="ch-system-kernfsmount"> + <title>Mounting Virtual Kernel File Systems</title> + + <para>Now mount the remaining virtual kernel filesystems:</para> + +<screen><userinput>mount -vt devpts devpts $LFS/dev/pts +mount -vt tmpfs shm $LFS/dev/shm +mount -vt proc proc $LFS/proc +mount -vt sysfs sysfs $LFS/sys</userinput></screen> -<screen><userinput>mount -vft tmpfs tmpfs $LFS/dev -mount -vft tmpfs tmpfs $LFS/dev/shm -mount -vft devpts -o gid=4,mode=620 devpts $LFS/dev/pts</userinput></screen> + </sect2> </sect1> diff --git a/chapter06/pkgmgt.xml b/chapter06/pkgmgt.xml index 76ea123e2..4ce94106d 100644 --- a/chapter06/pkgmgt.xml +++ b/chapter06/pkgmgt.xml @@ -39,14 +39,6 @@ the <ulink url="&hints-root;">Hints subproject</ulink> and see if one of them fits your need.</para> - <note> - <para>As no particular package management technique is mentioned in LFS, - the commands in the remainder of this book must be performed while logged in - as user <systemitem class="username">root</systemitem> and no longer as user - <systemitem class="username">lfs</systemitem>. Also, double check that - <envar>$LFS</envar> is set.</para> - </note> - <sect2> <title>Upgrade Issues</title> diff --git a/chapter06/udev.xml b/chapter06/udev.xml index 96d2ec579..f78ab1cec 100644 --- a/chapter06/udev.xml +++ b/chapter06/udev.xml @@ -26,7 +26,7 @@ <seglistitem> <seg>0.1 SBU</seg> - <seg>3.8 MB</seg> + <seg>4.8 MB</seg> </seglistitem> </segmentedlist> @@ -43,19 +43,31 @@ <sect2 role="installation"> <title>Installation of Udev</title> + <para>Create some devices and directories that Udev cannot handle due to + them being required very early in the boot process:</para> + +<screen><userinput>install -dv /lib/{firmware,udev/devices/{pts,shm}} +mknod -m0666 /lib/udev/devices/null c 1 3 +ln -sv /proc/self/fd /lib/udev/devices/fd +ln -sv /proc/self/fd/0 /lib/udev/devices/stdin +ln -sv /proc/self/fd/1 /lib/udev/devices/stdout +ln -sv /proc/self/fd/2 /lib/udev/devices/stderr +ln -sv /proc/kcore /lib/udev/devices/core</userinput></screen> + <para>Compile the package:</para> -<screen><userinput>make EXTRAS=extras/run_directory</userinput></screen> +<screen><userinput>make EXTRAS="extras/ata_id extras/cdrom_id extras/edd_id \ + extras/firmware extras/floppy extras/scsi_id \ + extras/usb_id extras/volume_id"</userinput></screen> <variablelist> <title>The meaning of the make option:</title> <varlistentry> - <term><parameter>EXTRAS=extras/run_directory</parameter></term> + <term><parameter>EXTRAS=...</parameter></term> <listitem> - <para>This builds the <command>udev_run_devd</command> and - <command>udev_run_hotplugd</command> binaries, which are required - for correct handling of hotpluggable devices.</para> + <para>This builds several helper binaries that can aid in writing custom + Udev rules.</para> </listitem> </varlistentry> @@ -66,7 +78,10 @@ <para>Install the package:</para> -<screen><userinput>make DESTDIR=/ EXTRAS=extras/run_directory install</userinput></screen> +<screen><userinput>make DESTDIR=/ \ + EXTRAS="extras/ata_id extras/cdrom_id extras/edd_id \ + extras/firmware extras/floppy extras/scsi_id \ + extras/usb_id extras/volume_id" install</userinput></screen> <variablelist> <title>The meaning of the make parameter:</title> @@ -87,16 +102,78 @@ <screen><userinput>cp -v ../&udev-config-file; /etc/udev/rules.d/25-lfs.rules</userinput></screen> + <para>Create some rules that work around broken sysfs attribute creation + timing in linux-2.6.15:</para> + +<screen><userinput>cat >> /etc/udev/rules.d/10-wait_for_sysfs.rules << "EOF" +ACTION=="add", DEVPATH=="/devices/*", ENV{PHYSDEVBUS}=="?*", WAIT_FOR_SYSFS="bus" +ACTION=="add", SUBSYSTEM=="net", WAIT_FOR_SYSFS="address" +EOF</userinput></screen> + <para>Install the documentation that explains how to create Udev rules:</para> <screen><userinput>install -m644 -D -v docs/writing_udev_rules/index.html /usr/share/doc/udev-&udev-version;/index.html</userinput></screen> - <!-- Not for the LiveCD --> - <!-- Edit Me --> - <para>Run the <command>udevstart</command> program to create our full - complement of device nodes.</para> - -<screen><userinput>/sbin/udevstart</userinput></screen> + <important> + + <para>When Udev is started by the LFS-Bootscripts, a replay of all kernel + device events happens. These events tell Udev what devices exist. + Sometimes the Udev bootscript doesn't wait long enough for + <command>udevd</command> to process all of the replayed events and + consequently the devices for those missed events are not created before the + script exits. Since <command>udevd</command> is still running in the + background, the devices will be created a few milliseconds later, but the + next bootscript to run may require a device to exist before it has been + created. To avoid such missed events, and to avoid hardcoding an overly + long wait time, It is recommended that you run the following commands to + aid the LFS development team in debugging these missed events and finding + an acceptable solution more quickly.</para> + + <para>First, create a simple C file:</para> + +<screen><userinput>cat > bug.c << EOF +<literal>/* Simple event recorder */ +#define _GNU_SOURCE +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdlib.h> +#include <argz.h> +int main(int argc, char * argv[]) +{ + char * envz; + size_t len; + int bug; + bug = open("/dev/bug", O_WRONLY | O_APPEND); + if (bug == -1) + return 0; + setenv("_SEPARATOR", "--------------------------------------", 1); + argz_create(environ, &envz, &len); + argz_stringify(envz, len, '\n'); + envz[len-1]='\n'; + write(bug, envz, len); + close(bug); + free(envz); + return 0; +}</literal> +EOF</userinput></screen> + + <para>Now compile it:</para> + +<screen><userinput>gcc -o /lib/udev/bug bug.c</userinput></screen> + + <para>The next step adds a simple logging rule to run this program.</para> + +<screen><userinput>cat > /etc/udev/rules.d/90-bug.rules << "EOF" +<literal>ACTION=="add", RUN+="bug"</literal> +EOF</userinput></screen> + + <para>When booting the new LFS system, if any events are missed, a warning + message will appear and a <filename>/dev/bugreport</filename> file will be + created. The warning message will tell you where to send feedback.</para> + + </important> </sect2> @@ -108,8 +185,9 @@ <segtitle>Installed directory</segtitle> <seglistitem> - <seg>udev, udev_run_devd, udev_run_hotplugd, udevcontrol, udevd, - udevinfo, udevmonitor, udevsend, udevstart, and udevtest</seg> + <seg>ata_id, cdrom_id, create_floppy_devices, edd_id, firmware_helper, + scsi_id, udevcontrol, udevd, udevinfo, udevmonitor, udevtest, usb_id + and vol_id</seg> <seg>/etc/udev</seg> </seglistitem> </segmentedlist> @@ -119,38 +197,66 @@ <?dbfo list-presentation="list"?> <?dbhtml list-presentation="table"?> - <varlistentry id="udev"> - <term><command>udev</command></term> + <varlistentry id="ata_id"> + <term><command>ata_id</command></term> + <listitem> + <para>Provides Udev with a unique string and + additional information (uuid, label) for an ATA drive</para> + <indexterm zone="ch-system-udev ata_id"> + <primary sortas="b-ata_id">ata_id</primary> + </indexterm> + </listitem> + </varlistentry> + + <varlistentry id="cdrom_id"> + <term><command>cdrom_id</command></term> + <listitem> + <para>Provides Udev with the capabilities of a + CD-ROM or DVD-ROM drive</para> + <indexterm zone="ch-system-udev cdrom_id"> + <primary sortas="b-cdrom_id">cdrom_id</primary> + </indexterm> + </listitem> + </varlistentry> + + <varlistentry id="create_floppy_devices"> + <term><command>create_floppy_devices</command></term> <listitem> - <para>Creates device nodes in <filename class="directory">/dev</filename> - or renames network interfaces (not in LFS) in response to hotplug - events</para> - <indexterm zone="ch-system-udev udev"> - <primary sortas="b-udev">udev</primary> + <para>Creates all possible floppy devices based on the CMOS type</para> + <indexterm zone="ch-system-udev create_floppy_devices"> + <primary sortas="b-create_floppy_devices">create_floppy_devices</primary> </indexterm> </listitem> </varlistentry> - <varlistentry id="udev_run_devd"> - <term><command>udev_run_devd</command></term> + <varlistentry id="edd_id"> + <term><command>edd_id</command></term> <listitem> - <para>Executes programs and scripts in the <filename - class="directory">/etc/dev.d/</filename> directory in response to - hotplug events</para> - <indexterm zone="ch-system-udev udev_run_devd"> - <primary sortas="b-udev_run_devd">udev_run_devd</primary> + <para>Provides Udev with the EDD ID for a BIOS disk drive</para> + <indexterm zone="ch-system-udev edd_id"> + <primary sortas="b-edd_id">edd_id</primary> </indexterm> </listitem> </varlistentry> - <varlistentry id="udev_run_hotplugd"> - <term><command>udev_run_hotplugd</command></term> + <varlistentry id="firmware_helper"> + <term><command>firmware_helper</command></term> <listitem> - <para>Executes programs and scripts in the <filename - class="directory">/etc/hotplug.d/</filename> directory in response - to hotplug events</para> - <indexterm zone="ch-system-udev udev_run_hotplugd"> - <primary sortas="b-udev_run_hotplugd">udev_run_hotplugd</primary> + <para>Uploads firmware to devices</para> + <indexterm zone="ch-system-udev firmware_helper"> + <primary sortas="b-firmware_helper">firmware_helper</primary> + </indexterm> + </listitem> + </varlistentry> + + <varlistentry id="scsi_id"> + <term><command>scsi_id</command></term> + <listitem> + <para>Provides Udev with a unique SCSI identifier + based on the data returned from sending a SCSI INQUIRY command to + the specified device</para> + <indexterm zone="ch-system-udev scsi_id"> + <primary sortas="b-scsi_id">scsi_id</primary> </indexterm> </listitem> </varlistentry> @@ -169,8 +275,9 @@ <varlistentry id="udevd"> <term><command>udevd</command></term> <listitem> - <para>A daemon that reorders hotplug events before submitting them to - <command>udev</command>, thus avoiding various race conditions</para> + <para>A daemon that listens for uevents on the netlink socket, + creates devices and runs the configured external programs in + response to these uevents</para> <indexterm zone="ch-system-udev udevd"> <primary sortas="b-udevd">udevd</primary> </indexterm> @@ -180,7 +287,7 @@ <varlistentry id="udevinfo"> <term><command>udevinfo</command></term> <listitem> - <para>Allows users to query the <command>udev</command> database for + <para>Allows users to query the Udev database for information on any device currently present on the system; it also provides a way to query any device in the <systemitem class="filesystem">sysfs</systemitem> tree to help create udev @@ -194,48 +301,44 @@ <varlistentry id="udevmonitor"> <term><command>udevmonitor</command></term> <listitem> - <para>Prints the event received from the kernel and the event which - <command>udev</command> sends out after rule processing</para> + <para>Prints the event received from the kernel and the environment + which Udev sends out after rule processing</para> <indexterm zone="ch-system-udev udevmonitor"> <primary sortas="b-udevmonitor">udevmonitor</primary> </indexterm> </listitem> </varlistentry> - <varlistentry id="udevsend"> - <term><command>udevsend</command></term> + <varlistentry id="udevtest"> + <term><command>udevtest</command></term> <listitem> - <para>Delivers hotplug events to <command>udevd</command></para> - <indexterm zone="ch-system-udev udevsend"> - <primary sortas="b-udevsend">udevsend</primary> + <para>Simulates a uevent for the given device, and prints out the + name of the node the real <command>udevd</command> would have created, + or the name of the renamed network interface</para> + <indexterm zone="ch-system-udev udevtest"> + <primary sortas="b-udevtest">udevtest</primary> </indexterm> </listitem> </varlistentry> - <varlistentry id="udevstart"> - <term><command>udevstart</command></term> + <varlistentry id="usb_id"> + <term><command>usb_id</command></term> <listitem> - <para>Creates device nodes in <filename class="directory">/dev</filename> - that correspond to drivers compiled directly into the kernel; it - performs that task by simulating hotplug events presumably dropped by - the kernel before invocation of this program (e.g., because the root - filesystem has not been mounted) and submitting such synthetic hotplug - events to <command>udev</command></para> - <indexterm zone="ch-system-udev udevstart"> - <primary sortas="b-udevstart">udevstart</primary> + <para>Provides Udev with information about USB + devices</para> + <indexterm zone="ch-system-udev usb_id"> + <primary sortas="b-usb_id">usb_id</primary> </indexterm> </listitem> </varlistentry> - <varlistentry id="udevtest"> - <term><command>udevtest</command></term> + <varlistentry id="vol_id"> + <term><command>vol_id</command></term> <listitem> - <para>Simulates a <command>udev</command> run for the given device, - and prints out the name of the node the real <command>udev</command> - would have created or (not in LFS) the name of the renamed network - interface</para> - <indexterm zone="ch-system-udev udevtest"> - <primary sortas="b-udevtest">udevtest</primary> + <para>Provides Udev with the label and uuid of a + filesystem</para> + <indexterm zone="ch-system-udev vol_id"> + <primary sortas="b-vol_id">vol_id</primary> </indexterm> </listitem> </varlistentry> @@ -243,7 +346,7 @@ <varlistentry id="etc-udev"> <term><filename class="directory">/etc/udev</filename></term> <listitem> - <para>Contains <command>udev</command> configuation files, + <para>Contains Udev configuation files, device permissions, and rules for device naming</para> <indexterm zone="ch-system-udev etc-udev"> <primary sortas="e-/etc/udev">/etc/udev</primary> |