1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
5 | %general-entities;
|
---|
6 | ]>
|
---|
7 |
|
---|
8 | <sect1 id="ch-tools-kernel" role="wrap">
|
---|
9 | <?dbhtml filename="kernel.html"?>
|
---|
10 |
|
---|
11 | <sect1info condition="script">
|
---|
12 | <productname>kernel</productname>
|
---|
13 | <productnumber>&linux-version;</productnumber>
|
---|
14 | <address>&linux-url;</address>
|
---|
15 | </sect1info>
|
---|
16 |
|
---|
17 | <title>Linux-&linux-version;</title>
|
---|
18 |
|
---|
19 | <indexterm zone="ch-tools-kernel">
|
---|
20 | <primary sortas="a-Linux">Linux</primary>
|
---|
21 | <secondary>tools</secondary>
|
---|
22 | </indexterm>
|
---|
23 |
|
---|
24 | <sect2 role="package">
|
---|
25 | <title/>
|
---|
26 |
|
---|
27 | <para>The Linux package contains the Linux kernel.</para>
|
---|
28 |
|
---|
29 | <segmentedlist>
|
---|
30 | <segtitle>&buildtime;</segtitle>
|
---|
31 | <segtitle>&diskspace;</segtitle>
|
---|
32 |
|
---|
33 | <seglistitem>
|
---|
34 | <seg>&linux-tmp-sbu;</seg>
|
---|
35 | <seg>&linux-tmp-du;</seg>
|
---|
36 | </seglistitem>
|
---|
37 | </segmentedlist>
|
---|
38 |
|
---|
39 | </sect2>
|
---|
40 |
|
---|
41 | <sect2 role="installation">
|
---|
42 | <title>Installation of the kernel</title>
|
---|
43 |
|
---|
44 | <para>Building the kernel involves a few steps—configuration,
|
---|
45 | compilation, and installation. Read the <filename>README</filename> file
|
---|
46 | in the kernel source tree for alternative methods to the way this book
|
---|
47 | configures the kernel.</para>
|
---|
48 |
|
---|
49 | <para>Prepare for compilation by running the following command:</para>
|
---|
50 |
|
---|
51 | <screen><userinput remap="pre">make mrproper</userinput></screen>
|
---|
52 |
|
---|
53 | <para>This ensures that the kernel tree is absolutely clean. The
|
---|
54 | kernel team recommends that this command be issued prior to each
|
---|
55 | kernel compilation. Do not rely on the source tree being clean after
|
---|
56 | un-tarring.</para>
|
---|
57 |
|
---|
58 | <para>There are several ways to configure the kernel options. Usually,
|
---|
59 | This is done through a menu-driven interface, for example:</para>
|
---|
60 |
|
---|
61 | <screen role="nodump"><userinput>make ARCH=<replaceable>x86</replaceable> CROSS_COMPILE=$LFS_TGT- menuconfig</userinput></screen>
|
---|
62 |
|
---|
63 | <variablelist>
|
---|
64 | <title>The meaning of make environment variables:</title>
|
---|
65 |
|
---|
66 | <varlistentry>
|
---|
67 | <term><command>ARCH=x86</command></term>
|
---|
68 | <listitem>
|
---|
69 | <para>Configure the kernel for running on the target machine.
|
---|
70 | Replace <replaceable>x86</replaceable> with a value suitable
|
---|
71 | for your target machine if it's not a 32-bit or 64-bit x86.</para>
|
---|
72 | </listitem>
|
---|
73 | </varlistentry>
|
---|
74 |
|
---|
75 | <varlistentry>
|
---|
76 | <term><command>CROSS_COMPILE=$LFS_TGT-</command></term>
|
---|
77 | <listitem>
|
---|
78 | <para>Build the kernel with Binutils and GCC built in
|
---|
79 | <xref linkend='chapter-cross-tools'/>.</para>
|
---|
80 | </listitem>
|
---|
81 | </varlistentry>
|
---|
82 |
|
---|
83 | <varlistentry>
|
---|
84 | <term><command>menuconfig</command></term>
|
---|
85 | <listitem>
|
---|
86 | <para>This launches an ncurses menu-driven interface. For other
|
---|
87 | (graphical) interfaces, type <command>make help</command>.</para>
|
---|
88 | </listitem>
|
---|
89 | </varlistentry>
|
---|
90 |
|
---|
91 | <varlistentry>
|
---|
92 | <term>(optional) <parameter>LANG=<host_LANG_value> LC_ALL=</parameter></term>
|
---|
93 | <listitem>
|
---|
94 | <para>This establishes the locale setting to the one used on the
|
---|
95 | host. This may be needed for a proper menuconfig ncurses interface
|
---|
96 | line drawing on a UTF-8 linux text console.</para>
|
---|
97 |
|
---|
98 | <para>If used, be sure to replace
|
---|
99 | <replaceable><host_LANG_value></replaceable> by the value of
|
---|
100 | the <envar>$LANG</envar> variable from your host. You can
|
---|
101 | alternatively use instead the host's value of <envar>$LC_ALL</envar>
|
---|
102 | or <envar>$LC_CTYPE</envar>.</para>
|
---|
103 | </listitem>
|
---|
104 | </varlistentry>
|
---|
105 |
|
---|
106 | </variablelist>
|
---|
107 |
|
---|
108 | <note>
|
---|
109 |
|
---|
110 | <para>A good starting place for setting up the kernel configuration is to
|
---|
111 | run <command>make ARCH=x86 CROSS_COMPILE=$LFS_TGT- defconfig</command>. This will set the base
|
---|
112 | configuration to a good state that takes your target system architecture
|
---|
113 | into account.</para>
|
---|
114 |
|
---|
115 | </note>
|
---|
116 |
|
---|
117 | <para>Read <xref linkend='ch-bootable-kernel'/> for more information
|
---|
118 | about kernel configuration. You should enable or disable some kernel
|
---|
119 | configuration options now:</para>
|
---|
120 |
|
---|
121 | <variablelist>
|
---|
122 | <title>Kernel configuration options and explanation:</title>
|
---|
123 |
|
---|
124 | <varlistentry>
|
---|
125 | <term>Set <parameter>CONFIG_MODULES=n</parameter></term>
|
---|
126 | <listitem>
|
---|
127 | <para>Modular kernel needs <command>modprobe</command> tool from
|
---|
128 | <application>Kmod</application> to load modules, which is not
|
---|
129 | installed in the temporary system.</para>
|
---|
130 | </listitem>
|
---|
131 | </varlistentry>
|
---|
132 |
|
---|
133 | <varlistentry>
|
---|
134 | <term>Set <parameter>CONFIG_EXTRA_FIRMWARE="<replaceable>a.bin b.bin</replaceable>"</parameter></term>
|
---|
135 | <listitem>
|
---|
136 | <para>Build firmware blobs into the kernel. Some drivers may
|
---|
137 | require the firmwares to be in-kernel if the driver is not built
|
---|
138 | as module.</para>
|
---|
139 | <note>
|
---|
140 | <para>
|
---|
141 | The kernel binaries with third-party blobs are not
|
---|
142 | distributable. If you distribute such a kernel binary to
|
---|
143 | others, you may violate GPL. It's recommended to remove the
|
---|
144 | temporary kernel image after you've successfully boot your LFS
|
---|
145 | system with the new kernel image, which will be installed in
|
---|
146 | <xref linkend="ch-bootable-kernel"/>.
|
---|
147 | </para>
|
---|
148 | </note>
|
---|
149 | </listitem>
|
---|
150 | </varlistentry>
|
---|
151 |
|
---|
152 | <varlistentry>
|
---|
153 | <term>Set <parameter>CONFIG_EXTRA_FIRMWARE_DIR="<replaceable>$LFS</replaceable>/lib/firmware"</parameter></term>
|
---|
154 | <listitem>
|
---|
155 | <para>The building system will search
|
---|
156 | <filename class="directory">/lib/firmware</filename> for firmware
|
---|
157 | blobs in <parameter>CONFIG_EXTRA_FIRMWARE</parameter>. Note that
|
---|
158 | you'll need to install the needed firmwares into
|
---|
159 | <filename class="directory">$LFS/lib/firmware</filename> first,
|
---|
160 | and manually replace <envar>$LFS</envar> with the value in
|
---|
161 | configuration. The firmwares in
|
---|
162 | <filename class="directory">$LFS/lib/filename</filename> will be
|
---|
163 | copied to the target machine along with the system, so kernel and
|
---|
164 | kernel modules which will be built in
|
---|
165 | <xref linkend="ch-bootable-kernel"/> can load them without
|
---|
166 | <parameter>CONFIG_EXTRA_FIRMWARE</parameter>.</para>
|
---|
167 | </listitem>
|
---|
168 | </varlistentry>
|
---|
169 |
|
---|
170 | <varlistentry>
|
---|
171 | <term>Set <parameter>CONFIG_EXT2=y</parameter>,
|
---|
172 | <parameter>CONFIG_EXT4=y</parameter>,
|
---|
173 | and <parameter>CONFIG_VFAT_FS=y</parameter></term>
|
---|
174 | <listitem>
|
---|
175 | <para>They are needed to access the filesystems we'll make for the
|
---|
176 | target system.</para>
|
---|
177 | </listitem>
|
---|
178 | </varlistentry>
|
---|
179 |
|
---|
180 | <varlistentry>
|
---|
181 | <term>Set <parameter>CONFIG_MODULE_SIG=n</parameter>,
|
---|
182 | <parameter>CONFIG_SECURITY=n</parameter>,
|
---|
183 | and <parameter>CONFIG_STACK_VALIDATION=n</parameter></term>
|
---|
184 | <listitem>
|
---|
185 | <para>They are unneeded for the temporary kernel, and they need
|
---|
186 | additional dependencies which may be unavailable on the host
|
---|
187 | distro. You can enable them building the kernel for the final LFS
|
---|
188 | system in Chapter 10 if you need these features.</para>
|
---|
189 | </listitem>
|
---|
190 | </varlistentry>
|
---|
191 | </variablelist>
|
---|
192 |
|
---|
193 | <para>Compile the kernel image:</para>
|
---|
194 |
|
---|
195 | <screen><userinput remap="make">make ARCH=x86 CROSS_COMPILE=$LFS_TGT-</userinput></screen>
|
---|
196 |
|
---|
197 | <para>Install the kernel image into the
|
---|
198 | <filename class="directory">$LFS/boot</filename> directory:</para>
|
---|
199 |
|
---|
200 | <screen><userinput remap="install">install -vm644 vmlinux $LFS/boot/vmlinux</userinput></screen>
|
---|
201 |
|
---|
202 | </sect2>
|
---|
203 |
|
---|
204 | <sect2 role="content">
|
---|
205 | <title/>
|
---|
206 |
|
---|
207 | <para>Details on this package are located in
|
---|
208 | <xref linkend="contents-kernel" role="."/></para>
|
---|
209 |
|
---|
210 | </sect2>
|
---|
211 |
|
---|
212 | </sect1>
|
---|