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