[673b0d8] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
---|
| 3 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 4 | %general-entities;
|
---|
| 5 | ]>
|
---|
[a001133] | 6 | <sect1 id="ch-bootable-kernel" xreflabel="Linux" role="wrap">
|
---|
[673b0d8] | 7 | <title>Linux-&linux-version;</title>
|
---|
| 8 | <?dbhtml filename="kernel.html"?>
|
---|
| 9 |
|
---|
| 10 | <indexterm zone="ch-bootable-kernel"><primary sortas="a-Linux">Linux</primary></indexterm>
|
---|
[6370fa6] | 11 |
|
---|
[a001133] | 12 | <sect2 role="package"><title/>
|
---|
[5888299] | 13 | <para>The Linux package contains the kernel and the header files.</para>
|
---|
| 14 |
|
---|
[a001133] | 15 | <segmentedlist>
|
---|
| 16 | <segtitle>&buildtime;</segtitle>
|
---|
| 17 | <segtitle>&diskspace;</segtitle>
|
---|
| 18 | <seglistitem><seg>All default options: 4.20 SBU</seg>
|
---|
| 19 | <seg>All default options: 181 MB</seg></seglistitem>
|
---|
| 20 | </segmentedlist>
|
---|
| 21 |
|
---|
| 22 | <segmentedlist>
|
---|
| 23 | <segtitle>Linux installation depends on</segtitle>
|
---|
| 24 | <seglistitem><seg>Bash, Binutils, Coreutils, Findutils,
|
---|
| 25 | GCC, Glibc, Grep, Gzip, Make, Modutils, Perl, Sed</seg></seglistitem>
|
---|
| 26 | </segmentedlist>
|
---|
| 27 | </sect2>
|
---|
| 28 |
|
---|
| 29 | <sect2 role="installation">
|
---|
[2081905] | 30 | <title>Installation of the kernel</title>
|
---|
| 31 |
|
---|
| 32 | <para>Building the kernel involves a few steps: configuration, compilation, and
|
---|
| 33 | installation. If you don't like the way this book configures the kernel, view
|
---|
| 34 | the <filename>README</filename> file in the kernel source tree for alternative
|
---|
| 35 | methods.</para>
|
---|
| 36 |
|
---|
| 37 | <para>Prepare for compilation by running the following command:</para>
|
---|
| 38 |
|
---|
| 39 | <screen><userinput>make mrproper</userinput></screen>
|
---|
| 40 |
|
---|
| 41 | <para>This ensures that the kernel tree is absolutely clean. The kernel team
|
---|
| 42 | recommends that this command be issued prior to <emphasis>each</emphasis>
|
---|
| 43 | kernel compilation. You shouldn't rely on the source tree being clean after
|
---|
[673b0d8] | 44 | un-tarring.</para>
|
---|
[2081905] | 45 |
|
---|
[5ea02778] | 46 | <para>Fix an exploitable bug in FPU exception handling code:</para>
|
---|
| 47 |
|
---|
| 48 | <screen><userinput>patch -Np1 -i ../linux-&linux-version;-fpu-1.patch</userinput></screen>
|
---|
| 49 |
|
---|
[b9e738a] | 50 | <para>Also, assure that the kernel does not attempt to pass hotplugging events
|
---|
| 51 | to userspace until userspace specifies that it is ready:</para>
|
---|
| 52 |
|
---|
| 53 | <screen><userinput>sed -i 's@/sbin/hotplug@/bin/true@' kernel/kmod.c</userinput></screen>
|
---|
| 54 |
|
---|
[2081905] | 55 | <para>Configure the kernel via a menu-driven interface:</para>
|
---|
| 56 |
|
---|
| 57 | <screen><userinput>make menuconfig</userinput></screen>
|
---|
| 58 |
|
---|
| 59 | <para><userinput>make oldconfig</userinput> may be more appropriate in some
|
---|
| 60 | situations. See the <filename>README</filename> file for more
|
---|
| 61 | information.</para>
|
---|
| 62 |
|
---|
| 63 | <para>If you wish, you may skip kernel configuration by simply copying the
|
---|
| 64 | kernel config file, <filename>.config</filename>, from your host system
|
---|
[673b0d8] | 65 | (assuming it is available) to the unpacked <filename class="directory">linux-&linux-version;</filename>
|
---|
| 66 | directory. However, we
|
---|
[2081905] | 67 | don't recommend this option. You're much better off exploring all the
|
---|
| 68 | configuration menus and creating your own kernel configuration from
|
---|
| 69 | scratch.</para>
|
---|
| 70 |
|
---|
| 71 | <para>For POSIX shared memory support, ensure that the kernel config option
|
---|
[673b0d8] | 72 | <quote>Virtual memory file system support</quote> is enabled. It resides within
|
---|
| 73 | the <quote>File systems</quote> menu and is normally enabled by default.</para>
|
---|
[2081905] | 74 |
|
---|
[72b0264] | 75 | <para>LFS bootscripts make the assumption that you either compile
|
---|
[a56c4bb] | 76 | both "Support for Host-side USB" and
|
---|
| 77 | "USB device filesystem" directly into the kernel, or don't compile them at
|
---|
| 78 | all. Bootscripts will not work properly if it is a module (usbcore.ko).</para>
|
---|
[72b0264] | 79 |
|
---|
[9dfc02f] | 80 | <note><para>NPTL requires the kernel to be compiled with GCC 3.x, in this case
|
---|
| 81 | &gcc-version;. Compiling with 2.95.x is known to cause failures in the glibc
|
---|
| 82 | testsuite, so do <emphasis>not</emphasis> compile the kernel with gcc 2.95.x
|
---|
| 83 | unless you know what you're getting yourself into.</para></note>
|
---|
[2081905] | 84 |
|
---|
[9dfc02f] | 85 | <para>Compile the kernel image and modules:</para>
|
---|
[2081905] | 86 |
|
---|
[9dfc02f] | 87 | <screen><userinput>make</userinput></screen>
|
---|
[2081905] | 88 |
|
---|
[a56c4bb] | 89 | <para>If you intend to use kernel modules, you may need an
|
---|
[9dfc02f] | 90 | <filename>/etc/modprobe.conf</filename> file. Information pertaining
|
---|
[2081905] | 91 | to modules and to kernel configuration in general may be found in the
|
---|
| 92 | kernel documentation, which is found in the
|
---|
[a56c4bb] | 93 | <filename>linux-&linux-version;/Documentation</filename> directory.
|
---|
| 94 | The
|
---|
| 95 | modprobe.conf man page
|
---|
| 96 | <!-- removed for review from tldp.org
|
---|
| 97 | and the kernel HOWTO at
|
---|
| 98 | <ulink url="http://www.tldp.org/HOWTO/Kernel-HOWTO.html"/> -->
|
---|
| 99 | may also be of
|
---|
[2081905] | 100 | interest to you.</para>
|
---|
| 101 |
|
---|
[a56c4bb] | 102 | <para>Be very suspicious while reading other documentation, because it
|
---|
| 103 | usually applies to 2.4.x kernels only. As far as the editors know, kernel
|
---|
| 104 | configuration issues specific to Hotplug and Udev
|
---|
| 105 | are documented nowhere. The problem is that Udev will create a device node
|
---|
| 106 | only if Hotplug or a user-written script inserts the corresponding module
|
---|
| 107 | into the kernel, and not all modules are detectable by Hotplug. Note
|
---|
| 108 | that statements like
|
---|
| 109 | <screen>alias char-major-XXX some-module</screen>
|
---|
| 110 | in <filename>/etc/modprobe.conf</filename> file don't work with
|
---|
| 111 | Udev, and other aliases are often unnecessary with Hotplug.</para>
|
---|
| 112 |
|
---|
| 113 | <para>Because of all those compilcations with Hotplug, Udev and modules, we
|
---|
| 114 | strongly recommend you to start with a completely non-modular kernel
|
---|
| 115 | configuration, especially if this is the first time you use Udev.</para>
|
---|
| 116 |
|
---|
| 117 | <para>Install the modules, if your kernel configuration uses them:</para>
|
---|
[2081905] | 118 |
|
---|
[9dfc02f] | 119 | <screen><userinput>make modules_install</userinput></screen>
|
---|
[2081905] | 120 |
|
---|
[b157558] | 121 | <para>If you have a lot of modules and very little space, you may want to
|
---|
| 122 | consider stripping and compressing the modules. For most people such compression
|
---|
| 123 | isn't worth the trouble, but if you're really pressed for space, then have a look at
|
---|
| 124 | <ulink url="http://www.linux-mips.org/archives/linux-mips/2002-04/msg00031.html"/>.</para>
|
---|
| 125 |
|
---|
[2081905] | 126 | <para>Kernel compilation has finished but more steps are required to complete
|
---|
| 127 | the installation. Some files need to be copied to the <filename>/boot</filename>
|
---|
| 128 | directory.</para>
|
---|
| 129 |
|
---|
| 130 | <para>The path to the kernel image may vary depending on the platform you're
|
---|
| 131 | using. Issue the following command to install the kernel:</para>
|
---|
| 132 |
|
---|
[9dfc02f] | 133 | <screen><userinput>cp arch/i386/boot/bzImage /boot/lfskernel-&linux-version;</userinput></screen>
|
---|
[2081905] | 134 |
|
---|
| 135 | <para><filename>System.map</filename> is a symbol file for the kernel. It maps
|
---|
[673b0d8] | 136 | the function entry points of every function in the kernel API (Application Programming Interface), as well as the
|
---|
[2081905] | 137 | addresses of the kernel data structures for the running kernel. Issue the
|
---|
| 138 | following command to install the map file:</para>
|
---|
| 139 |
|
---|
[9dfc02f] | 140 | <screen><userinput>cp System.map /boot/System.map-&linux-version;</userinput></screen>
|
---|
[2081905] | 141 |
|
---|
| 142 | <para><filename>.config</filename> is the kernel configuration file that was
|
---|
| 143 | produced by the <command>make menuconfig</command> step above. It contains all
|
---|
| 144 | the config selections for the kernel that was just compiled. It's a good idea
|
---|
| 145 | to keep this file for future reference:</para>
|
---|
| 146 |
|
---|
[9dfc02f] | 147 | <screen><userinput>cp .config /boot/config-&linux-version;</userinput></screen>
|
---|
[2081905] | 148 |
|
---|
| 149 | <para>It is important to note that the files in the kernel source directory are
|
---|
| 150 | not owned by <emphasis>root</emphasis>. Whenever you unpack a package as user
|
---|
| 151 | <emphasis>root</emphasis> (like we did here inside chroot), the files end up
|
---|
| 152 | having the user and group IDs of whatever they were on the packager's computer.
|
---|
| 153 | This is usually not a problem for any other package you install because you
|
---|
| 154 | remove the source tree after the installation. But the Linux source tree is
|
---|
| 155 | often kept around for a long time, so there's a chance that whatever user ID
|
---|
| 156 | the packager used will be assigned to somebody on your machine and then that
|
---|
| 157 | person would have write access to the kernel source.</para>
|
---|
| 158 |
|
---|
| 159 | <para>If you are going to keep the kernel source tree around, you may want to
|
---|
| 160 | run <userinput>chown -R 0:0</userinput> on the
|
---|
[132b753] | 161 | <filename>linux-&linux-version;</filename> directory to ensure all files are
|
---|
[2081905] | 162 | owned by user <emphasis>root</emphasis>.</para>
|
---|
| 163 |
|
---|
| 164 | </sect2>
|
---|
[6910868] | 165 |
|
---|
[673b0d8] | 166 |
|
---|
[c6cb3aa] | 167 | <sect2 id="contents-kernel" role="content"><title>Contents of Linux</title>
|
---|
[673b0d8] | 168 |
|
---|
[c6cb3aa] | 169 | <segmentedlist>
|
---|
| 170 | <segtitle>Installed files</segtitle>
|
---|
| 171 | <seglistitem><seg>the kernel, the kernel headers,
|
---|
| 172 | and the System.map</seg></seglistitem>
|
---|
| 173 | </segmentedlist>
|
---|
[673b0d8] | 174 |
|
---|
[c6cb3aa] | 175 | <variablelist><title>Short descriptions</title>
|
---|
[673b0d8] | 176 |
|
---|
[b8a819f] | 177 | <varlistentry id="kernel">
|
---|
| 178 | <term>The <emphasis>kernel</emphasis></term>
|
---|
[c6cb3aa] | 179 | <listitem>
|
---|
[673b0d8] | 180 | <indexterm zone="ch-bootable-kernel kernel"><primary sortas="b-kernel">kernel</primary></indexterm>
|
---|
[3966ace] | 181 | <para>is the engine of your Linux system.
|
---|
[673b0d8] | 182 | When switching on your box, the kernel is the first part of your operating
|
---|
| 183 | system that gets loaded. It detects and initializes all the components of your
|
---|
| 184 | computer's hardware, then makes these components available as a tree of files
|
---|
| 185 | to the software, and turns a single CPU into a multi-tasking machine capable
|
---|
| 186 | of running scores of programs seemingly at the same time.</para>
|
---|
[c6cb3aa] | 187 | </listitem>
|
---|
| 188 | </varlistentry>
|
---|
[673b0d8] | 189 |
|
---|
[b8a819f] | 190 | <varlistentry id="kernel-headers">
|
---|
| 191 | <term>The <emphasis>kernel headers</emphasis></term>
|
---|
[c6cb3aa] | 192 | <listitem>
|
---|
[673b0d8] | 193 | <indexterm zone="ch-bootable-kernel kernel-headers"><primary sortas="e-kernel-headers">kernel headers</primary></indexterm>
|
---|
[c6cb3aa] | 194 | <para>define the interface to the
|
---|
[673b0d8] | 195 | services that the kernel provides. The headers in your system's
|
---|
| 196 | <filename>include</filename> directory should <emphasis>always</emphasis> be
|
---|
| 197 | the ones against which Glibc was compiled and should therefore
|
---|
| 198 | <emphasis>not</emphasis> be replaced when upgrading the kernel.</para>
|
---|
[c6cb3aa] | 199 | </listitem>
|
---|
| 200 | </varlistentry>
|
---|
[673b0d8] | 201 |
|
---|
[b8a819f] | 202 | <varlistentry id="System.map">
|
---|
| 203 | <term><filename>System.map</filename></term>
|
---|
[c6cb3aa] | 204 | <listitem>
|
---|
[673b0d8] | 205 | <indexterm zone="ch-bootable-kernel System.map"><primary sortas="e-/boot/System.map">/boot/System.map</primary></indexterm>
|
---|
[c6cb3aa] | 206 | <para>is a list of addresses and symbols. It maps the entry points and addresses
|
---|
| 207 | of all the functions and data structures in the kernel.</para>
|
---|
| 208 | </listitem>
|
---|
| 209 | </varlistentry>
|
---|
| 210 | </variablelist>
|
---|
[673b0d8] | 211 |
|
---|
| 212 | </sect2>
|
---|
| 213 |
|
---|
[6370fa6] | 214 | </sect1>
|
---|