1 |
<?xml version='1.0' encoding='UTF-8'?> |
2 |
<!DOCTYPE sections SYSTEM "/dtd/book.dtd"> |
3 |
|
4 |
<!-- The content of this document is licensed under the CC-BY-SA license --> |
5 |
<!-- See http://creativecommons.org/licenses/by-sa/2.5 --> |
6 |
|
7 |
<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-install-x86+amd64-kernel.xml,v 1.57 2014/08/07 16:15:41 swift Exp $ --> |
8 |
|
9 |
<sections> |
10 |
|
11 |
<abstract> |
12 |
The Linux kernel is the core of every distribution. This chapter |
13 |
explains how to configure your kernel. |
14 |
</abstract> |
15 |
|
16 |
<version>27</version> |
17 |
<date>2014-08-07</date> |
18 |
|
19 |
<section> |
20 |
<title>Installing the Sources</title> |
21 |
<subsection> |
22 |
<title>Choosing a Kernel</title> |
23 |
<body> |
24 |
|
25 |
<p> |
26 |
The core around which all distributions are built is the Linux kernel. It is the |
27 |
layer between the user programs and your system hardware. Gentoo provides its |
28 |
users several possible kernel sources. A full listing with description is |
29 |
available at the <uri link="https://wiki.gentoo.org/wiki/Kernel/Overview">Gentoo Kernel |
30 |
Guide</uri>. |
31 |
</p> |
32 |
|
33 |
<p> |
34 |
For <keyval id="arch"/>-based systems we have <c>gentoo-sources</c> |
35 |
(kernel source patched for extra features). |
36 |
</p> |
37 |
|
38 |
<p> |
39 |
Choose your kernel source and install it using <c>emerge</c>. |
40 |
</p> |
41 |
|
42 |
<pre caption="Installing a kernel source"> |
43 |
# <i>emerge gentoo-sources</i> |
44 |
</pre> |
45 |
|
46 |
<p> |
47 |
When you take a look in <path>/usr/src</path> you should see a symlink called |
48 |
<path>linux</path> pointing to your kernel source. In this case, the installed |
49 |
kernel source points to <c>gentoo-sources-<keyval id="kernel-version"/></c>. |
50 |
Your version may be different, so keep this in mind. |
51 |
</p> |
52 |
|
53 |
<pre caption="Viewing the kernel source symlink"> |
54 |
# <i>ls -l /usr/src/linux</i> |
55 |
lrwxrwxrwx 1 root root 12 Oct 13 11:04 /usr/src/linux -> linux-<keyval id="kernel-version"/> |
56 |
</pre> |
57 |
|
58 |
<p> |
59 |
Now it is time to configure and compile your kernel source. You can use |
60 |
<c>genkernel</c> for this, which will build a generic kernel as used by the |
61 |
Installation CD. We explain the "manual" configuration first though, as it is |
62 |
the best way to optimize your environment. |
63 |
</p> |
64 |
|
65 |
<p> |
66 |
If you want to manually configure your kernel, continue now with <uri |
67 |
link="#manual">Default: Manual Configuration</uri>. If you want to use |
68 |
<c>genkernel</c> you should read <uri link="#genkernel">Alternative: Using |
69 |
genkernel</uri> instead. |
70 |
</p> |
71 |
|
72 |
</body> |
73 |
</subsection> |
74 |
</section> |
75 |
<section id="manual"> |
76 |
<title>Default: Manual Configuration</title> |
77 |
<subsection> |
78 |
<title>Introduction</title> |
79 |
<body> |
80 |
|
81 |
<p> |
82 |
Manually configuring a kernel is often seen as the most difficult procedure a |
83 |
Linux user ever has to perform. Nothing is less true -- after configuring a |
84 |
couple of kernels you don't even remember that it was difficult ;) |
85 |
</p> |
86 |
|
87 |
<p> |
88 |
However, one thing <e>is</e> true: you must know your system when you start |
89 |
configuring a kernel manually. Most information can be gathered by emerging |
90 |
pciutils (<c>emerge pciutils</c>) which contains <c>lspci</c>. You will now |
91 |
be able to use <c>lspci</c> within the chrooted environment. You may safely |
92 |
ignore any <e>pcilib</e> warnings (like pcilib: cannot open |
93 |
/sys/bus/pci/devices) that <c>lspci</c> throws out. Alternatively, you can run |
94 |
<c>lspci</c> from a <e>non-chrooted</e> environment. The results are the same. |
95 |
You can also run <c>lsmod</c> to see what kernel modules the Installation CD |
96 |
uses (it might provide you with a nice hint on what to enable). |
97 |
</p> |
98 |
|
99 |
<p> |
100 |
Now go to your kernel source directory and execute <c>make menuconfig</c>. This |
101 |
will fire up an ncurses-based configuration menu. |
102 |
</p> |
103 |
|
104 |
<pre caption="Invoking menuconfig"> |
105 |
# <i>cd /usr/src/linux</i> |
106 |
# <i>make menuconfig</i> |
107 |
</pre> |
108 |
|
109 |
<p> |
110 |
You will be greeted with several configuration sections. We'll first list some |
111 |
options you must activate (otherwise Gentoo will not function, or not function |
112 |
properly without additional tweaks). We also have a <uri |
113 |
link="https://wiki.gentoo.org/wiki/Kernel/Gentoo_Kernel_Configuration_Guide">Gentoo |
114 |
Kernel Configuration Guide</uri> on the Gentoo wiki that might help you further. |
115 |
</p> |
116 |
|
117 |
</body> |
118 |
</subsection> |
119 |
<subsection> |
120 |
<title>Activating Required Options</title> |
121 |
<body> |
122 |
|
123 |
<p> |
124 |
Make sure that every driver that is vital to the booting of your system (such as |
125 |
SCSI controller, ...) is compiled <e>in</e> the kernel and not as a module, |
126 |
otherwise your system will not be able to boot completely. |
127 |
</p> |
128 |
|
129 |
</body> |
130 |
<body test="func:keyval('arch')='AMD64'"> |
131 |
|
132 |
<p> |
133 |
We shall then select the exact processor type. The x86_64 kernel maintainer |
134 |
strongly recommends users enable MCE features so that they are able to be |
135 |
notified of any hardware problems. On x86_64, these errors are not printed to |
136 |
<c>dmesg</c> like on other architectures, but to <path>/dev/mcelog</path>. This |
137 |
requires the <c>app-admin/mcelog</c> package. Make sure you select IA32 |
138 |
Emulation if you want to be able to run 32-bit programs. Gentoo will install a |
139 |
multilib system (mixed 32-bit/64-bit computing) by default, so this option is |
140 |
required. |
141 |
</p> |
142 |
|
143 |
<note> |
144 |
If you plan to use a non-multilib profile (for a pure 64-bit system), then you |
145 |
don't have to select IA32 Emulation support. However, you'll also need to follow |
146 |
the <uri link="?part=1&chap=6#doc_chap2_sect4">instructions</uri> for |
147 |
switching to a <uri link="https://wiki.gentoo.org/wiki/AMD64/FAQ">non-multilib |
148 |
profile</uri>, as well as choosing the correct <uri |
149 |
link="?part=1&chap=10#doc_chap2_sect2">bootloader</uri>. |
150 |
</note> |
151 |
|
152 |
<pre caption="Selecting processor type and features"> |
153 |
Processor type and features ---> |
154 |
[ ] Machine Check / overheating reporting |
155 |
[ ] Intel MCE Features |
156 |
[ ] AMD MCE Features |
157 |
Processor family (AMD-Opteron/Athlon64) ---> |
158 |
( ) Opteron/Athlon64/Hammer/K8 |
159 |
( ) Intel P4 / older Netburst based Xeon |
160 |
( ) Core 2/newer Xeon |
161 |
( ) Intel Atom |
162 |
( ) Generic-x86-64 |
163 |
Executable file formats / Emulations ---> |
164 |
[*] IA32 Emulation |
165 |
</pre> |
166 |
|
167 |
</body> |
168 |
<body test="func:keyval('arch')='x86'"> |
169 |
|
170 |
<p> |
171 |
Now select the correct processor family: |
172 |
</p> |
173 |
|
174 |
<pre caption="Selecting correct processor family"> |
175 |
Processor type and features ---> |
176 |
<comment>(Change according to your system)</comment> |
177 |
(<i>Athlon/Duron/K7</i>) Processor family |
178 |
</pre> |
179 |
|
180 |
</body> |
181 |
<body> |
182 |
|
183 |
<p> |
184 |
Next select <e>Maintain a devtmpfs file system to mount at /dev</e> so that |
185 |
critical device files are already available early in the boot process. |
186 |
</p> |
187 |
|
188 |
<pre caption="Enabling devtmpfs support"> |
189 |
Device Drivers ---> |
190 |
Generic Driver Options ---> |
191 |
[*] Maintain a devtmpfs filesystem to mount at /dev |
192 |
[ ] Automount devtmpfs at /dev, after the kernel mounted the rootfs |
193 |
</pre> |
194 |
|
195 |
<p> |
196 |
Now go to <c>File Systems</c> and select support for the filesystems you use. |
197 |
<e>Don't</e> compile the file system you use for the root filesystem as module, |
198 |
otherwise your Gentoo system will not be able to mount your partition. Also |
199 |
select <c>Virtual memory</c> and <c>/proc file system</c>. |
200 |
</p> |
201 |
|
202 |
<pre caption="Selecting necessary file systems"> |
203 |
File systems ---> |
204 |
<comment>(Select one or more of the following options as needed by your system)</comment> |
205 |
<*> Second extended fs support |
206 |
<*> Ext3 journalling file system support |
207 |
<*> The Extended 4 (ext4) filesystem |
208 |
<*> Reiserfs support |
209 |
<*> JFS filesystem support |
210 |
<*> XFS filesystem support |
211 |
... |
212 |
Pseudo Filesystems ---> |
213 |
[*] /proc file system support |
214 |
[*] Virtual memory file system support (former shm fs) |
215 |
|
216 |
<comment>(Enable GPT partition label support if you used that previously)</comment> |
217 |
-*- Enable the block layer ---> |
218 |
... |
219 |
Partition Types ---> |
220 |
[*] Advanced partition selection |
221 |
... |
222 |
[*] EFI GUID Partition support |
223 |
</pre> |
224 |
|
225 |
<p> |
226 |
If you are using PPPoE to connect to the Internet or you are using a dial-up |
227 |
modem, you will need the following options in the kernel: |
228 |
</p> |
229 |
|
230 |
<pre caption="Selecting PPPoE necessary drivers"> |
231 |
Device Drivers ---> |
232 |
Network device support ---> |
233 |
<*> PPP (point-to-point protocol) support |
234 |
<*> PPP support for async serial ports |
235 |
<*> PPP support for sync tty ports |
236 |
</pre> |
237 |
|
238 |
<p> |
239 |
The two compression options won't harm but are not definitely needed, neither |
240 |
does the <c>PPP over Ethernet</c> option, that might only be used by <c>ppp</c> |
241 |
when configured to do kernel mode PPPoE. |
242 |
</p> |
243 |
|
244 |
<p> |
245 |
If you require it, don't forget to include support in the kernel for your |
246 |
ethernet card. |
247 |
</p> |
248 |
|
249 |
<p test="func:keyval('arch')='x86'"> |
250 |
If you have an Intel CPU that supports HyperThreading (tm), or you have a |
251 |
multi-CPU system, you should activate "Symmetric multi-processing support": |
252 |
</p> |
253 |
|
254 |
<p test="func:keyval('arch')='AMD64'"> |
255 |
If you have a multi-CPU Opteron or a multi-core (e.g. AMD64 X2) system, you |
256 |
should activate "Symmetric multi-processing support": |
257 |
</p> |
258 |
|
259 |
<pre caption="Activating SMP support"> |
260 |
Processor type and features ---> |
261 |
[*] Symmetric multi-processing support |
262 |
</pre> |
263 |
|
264 |
<note> |
265 |
In multi-core systems, each core counts as one processor. |
266 |
</note> |
267 |
|
268 |
<p test="func:keyval('arch')='x86'"> |
269 |
If you have more than 4GB of RAM, you need to enable "High Memory Support |
270 |
(64G)". |
271 |
</p> |
272 |
|
273 |
<p> |
274 |
If you use USB Input Devices (like Keyboard or Mouse) don't forget to enable |
275 |
those as well: |
276 |
</p> |
277 |
|
278 |
<pre caption="Activating USB Support for Input Devices"> |
279 |
Device Drivers ---> |
280 |
[*] HID Devices ---> |
281 |
<*> USB Human Interface Device (full HID) support |
282 |
</pre> |
283 |
|
284 |
</body> |
285 |
<body test="func:keyval('arch')='x86'"> |
286 |
|
287 |
<p> |
288 |
If you want PCMCIA support for your laptop, don't forget to enable |
289 |
support for the PCMCIA card bridge present in your system: |
290 |
</p> |
291 |
|
292 |
<pre caption="Enabling PCMCIA support"> |
293 |
Bus options (PCI etc.) ---> |
294 |
PCCARD (PCMCIA/CardBus) support ---> |
295 |
<*> PCCard (PCMCIA/CardBus) support |
296 |
<comment>(select 16 bit if you need support for older PCMCIA cards. Most people want this.)</comment> |
297 |
<*> 16-bit PCMCIA support |
298 |
[*] 32-bit CardBus support |
299 |
<comment>(select the relevant bridges below)</comment> |
300 |
*** PC-card bridges *** |
301 |
<*> CardBus yenta-compatible bridge support (NEW) |
302 |
<*> Cirrus PD6729 compatible bridge support (NEW) |
303 |
<*> i82092 compatible bridge support (NEW) |
304 |
</pre> |
305 |
|
306 |
<p> |
307 |
When you've finished configuring the kernel, continue with <uri |
308 |
link="#compiling">Compiling and Installing</uri>. |
309 |
</p> |
310 |
|
311 |
</body> |
312 |
</subsection> |
313 |
<subsection id="compiling"> |
314 |
<title>Compiling and Installing</title> |
315 |
<body> |
316 |
|
317 |
<p> |
318 |
Now that your kernel is configured, it is time to compile and install it. Exit |
319 |
the configuration and start the compilation process: |
320 |
</p> |
321 |
|
322 |
<pre caption="Compiling the kernel"> |
323 |
# <i>make && make modules_install</i> |
324 |
</pre> |
325 |
|
326 |
<p> |
327 |
When the kernel has finished compiling, copy the kernel image to |
328 |
<path>/boot</path>. This is handled by the <c>make install</c> command: |
329 |
</p> |
330 |
|
331 |
<pre caption="Installing the kernel"> |
332 |
# <i>make install</i> |
333 |
</pre> |
334 |
|
335 |
<p> |
336 |
This will copy the kernel image into <path>/boot</path> together with the |
337 |
<path>System.map</path> file and the kernel configuration file. |
338 |
</p> |
339 |
|
340 |
</body> |
341 |
</subsection> |
342 |
<subsection> |
343 |
<include href="hb-install-initramfs.xml"/> |
344 |
</subsection> |
345 |
|
346 |
</section> |
347 |
<section id="genkernel"> |
348 |
<title>Alternative: Using genkernel</title> |
349 |
<body> |
350 |
|
351 |
<p> |
352 |
If you are reading this section, you have chosen to use our <c>genkernel</c> |
353 |
script to configure your kernel for you. |
354 |
</p> |
355 |
|
356 |
<p> |
357 |
Now that your kernel source tree is installed, it's now time to compile your |
358 |
kernel by using our <c>genkernel</c> script to automatically build a kernel for |
359 |
you. <c>genkernel</c> works by configuring a kernel nearly identically to the |
360 |
way our Installation CD kernel is configured. This means that when you use |
361 |
<c>genkernel</c> to build your kernel, your system will generally detect all |
362 |
your hardware at boot-time, just like our Installation CD does. Because |
363 |
genkernel doesn't require any manual kernel configuration, it is an ideal |
364 |
solution for those users who may not be comfortable compiling their own kernels. |
365 |
</p> |
366 |
|
367 |
<p> |
368 |
Now, let's see how to use genkernel. First, emerge the genkernel ebuild: |
369 |
</p> |
370 |
|
371 |
<pre caption="Emerging genkernel"> |
372 |
# <i>emerge genkernel</i> |
373 |
</pre> |
374 |
|
375 |
<p> |
376 |
Next, edit the <path>/etc/fstab</path> file so that the line containing |
377 |
<path>/boot</path> as second field has the first field pointing to the right |
378 |
device. If the partitioning example from the handbook is followed, then this |
379 |
device is most likely <path><keyval id="/boot"/></path> with the ext2 file |
380 |
system. This would make the entry in the file look like so: |
381 |
</p> |
382 |
|
383 |
<pre caption="Editing /etc/fstab for the /boot entry"> |
384 |
# <i>nano -w /etc/fstab</i> |
385 |
... |
386 |
<keyval id="/boot"/> /boot ext2 defaults 0 2 |
387 |
</pre> |
388 |
|
389 |
<p> |
390 |
The remainder of the <path>/etc/fstab</path> will be updated in the next section, |
391 |
but as <c>genkernel</c> reads this information we need to update the |
392 |
<path>/boot</path> line up front. |
393 |
</p> |
394 |
|
395 |
<p> |
396 |
Now, compile your kernel sources by running <c>genkernel all</c>. Be aware |
397 |
though, as <c>genkernel</c> compiles a kernel that supports almost all |
398 |
hardware, this compilation will take quite a while to finish! |
399 |
</p> |
400 |
|
401 |
<p> |
402 |
Note that, if your boot partition doesn't use ext2 or ext3 as filesystem you |
403 |
might need to manually configure your kernel using <c>genkernel --menuconfig |
404 |
all</c> and add support for your filesystem <e>in</e> the kernel (i.e. |
405 |
<e>not</e> as a module). Users of LVM2 will probably want to add <c>--lvm</c> |
406 |
as an argument as well. |
407 |
</p> |
408 |
|
409 |
<pre caption="Running genkernel"> |
410 |
# <i>genkernel all</i> |
411 |
</pre> |
412 |
|
413 |
<p> |
414 |
Once <c>genkernel</c> completes, a kernel, full set of modules and |
415 |
<e>initial ram disk</e> (initramfs) will be created. We will use the kernel |
416 |
and initrd when configuring a boot loader later in this document. Write |
417 |
down the names of the kernel and initrd as you will need it when writing |
418 |
the bootloader configuration file. The initrd will be started immediately after |
419 |
booting to perform hardware autodetection (just like on the Installation CD) |
420 |
before your "real" system starts up. |
421 |
</p> |
422 |
|
423 |
<pre caption="Checking the created kernel image name and initrd"> |
424 |
# <i>ls /boot/kernel* /boot/initramfs*</i> |
425 |
</pre> |
426 |
|
427 |
</body> |
428 |
</section> |
429 |
<section id="kernel_modules"> |
430 |
<title>Kernel Modules</title> |
431 |
|
432 |
<subsection> |
433 |
<include href="hb-install-kernelmodules.xml"/> |
434 |
</subsection> |
435 |
|
436 |
</section> |
437 |
</sections> |