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