/[gentoo]/xml/htdocs/doc/en/genkernel.xml
Gentoo

Diff of /xml/htdocs/doc/en/genkernel.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.3 Revision 1.40
1<?xml version='1.0' encoding="UTF-8"?> 1<?xml version="1.0" encoding="UTF-8"?>
2<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/genkernel.xml,v 1.40 2013/08/18 16:00:59 swift Exp $ -->
2<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> 3<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
3 4
4<guide link="/doc/en/xml-guide.xml"> 5<guide>
5<title>Gentoo Linux Genkernel Guide</title> 6<title>Gentoo Linux Genkernel Guide</title>
6 7
7<author title="Author"> 8<author title="Author">
8 <mail link="plasmaroo@gentoo.org">Tim Yamin</mail> 9 <mail link="plasmaroo@gentoo.org">Tim Yamin</mail>
9</author> 10</author>
11<!-- folajimi@speakeasy.net -->
12<author title="Contributor">
13 Jimi Ayodele
14</author>
15<!-- thseiler@gmail.com -->
16<author title="NFS Support">
17 Thomas Seiler
18</author>
19<author title="Editor">
20 <mail link="nightmorph"/>
21</author>
22<author title="Contributor">
23 <mail link="sping"/>
24</author>
10 25
11<abstract> 26<abstract>
12This guide intends to provide a reference of all the functions 27This guide intends to provide a reference of all the functions provided by
13provided by Genkernel. 28genkernel.
14</abstract> 29</abstract>
15 30
31<!-- The content of this document is licensed under the CC-BY-SA license -->
32<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
33<license/>
34
16<version>1.0</version> 35<version>10</version>
17<date>February 15, 2003</date> 36<!-- Latest real content change: 2012-06-29 -->
37<date>2013-08-18</date>
18 38
19<chapter> 39<chapter>
20<title>Introduction</title> 40<title>Introduction</title>
21<section> 41<section>
42<title>Rationale</title>
43<body>
44
45<p>
46For users who don't want to manually compile their kernels, genkernel is a tool
47to automate this process. It can help you create a kernel image akin to those
48available on Gentoo Installation CDs, which are designed to auto-detect the
49hardware configuration of your system. Some users may also be interested in
50using genkernel for hardware requiring initialization and a working kernel
51before the system starts up.
52</p>
53
54</body>
55</section>
56<section>
57<title>Target Audience</title>
58<body>
59
60<p>
61If you are either uncertain about how to compile a kernel, or are just
62unfamiliar with your hardware configuration, genkernel is a very handy tool.
63It is designed to take the pain out of the kernel compiling process, and
64supports most hardware by default.
65</p>
66
67<p>
68However, if you know what drivers are required by your system, you may be able
69to further reduce the time taken to compile the kernel. This is possible since
70you can direct genkernel to only build drivers relevant to your hardware.
71Oftentimes, the number of drivers required by your system will be fewer
72(implying a shorter kernel compilation time) than the default configuration
73provides.
74</p>
75
76</body>
77</section>
78<section>
79<title>Installing genkernel</title>
80<body>
81
82<p>
83To obtain genkernel, run <c>emerge genkernel</c> from the command line. Consult
84<c>genkernel --help</c> for help on how to use the version of genkernel
85installed on your system.
86</p>
87
88</body>
89</section>
90</chapter>
91
92<chapter>
93<title>Working with genkernel</title>
94<section>
95<title>How to use genkernel</title>
96<body>
97
98<p>
99Although there are several ways to run genkernel, the least-intrusive approach
100is provided by <c>genkernel all</c>. Here, a generic configuration which works
101well for most systems is used. As was mentioned earlier, this approach is not
102without drawbacks; most of the modules created are useless to the average user
103and may increase compile time. Below is an illustration of a more efficient
104approach, achieved by passing certain flags to genkernel as root:
105</p>
106
107<pre caption="Running genkernel (with flags)">
108# <i>genkernel --splash --no-install --no-clean --menuconfig all</i>
109</pre>
110
111<p>
112The above operation causes genkernel to create a framebuffer splash-enabled
113kernel (<c>--splash</c>) that will have to be manually installed
114(<c>--no-install</c>). While preparing the kernel source tree, genkernel will
115refrain from cleaning out any preexisting object files present in the source
116tree (<c>--no-clean</c>). A menu-driven kernel configuration utility will be
117displayed that allows the user to select which modules will be built for the
118system (<c>--menuconfig</c>).
119</p>
120
121<p>
122There are other flags which alter the result provided by genkernel. For
123instance, replacing <c>--no-install</c> with the <c>--install</c> flag allows
124genkernel to automatically install the new kernel in the <path>/boot</path>
125directory, and will create symlinks for you if <c>--symlink</c> is specified.
126Using the <c>--mountboot</c> flag allows genkernel to mount your
127<path>/boot</path> partition automatically, if necessary.
128</p>
129
130<p>
131Remember, genkernel is designed to make kernel compilation easy and
132stress-free. For this reason, genkernel features several flags to ease the
133kernel compilation effort. For example, there are flags to help with kernel
134configuration, while others affect the actual compilation. Some flags even help
135debug the compilation process. For those interested in further optimization,
136there are flags that affect kernel assembling, packaging and even kernel
137initialization.
138</p>
139
140<p>
141The rest of this chapter examines the functionality of various flags,
142configuration variables, and actions available for genkernel. For a more
143complete list, please refer to <c>man genkernel</c> and the comments in
144<path>/etc/genkernel.conf</path>. Some of the flags have variants which
145perform a converse operation. The converse variants carry the <b><c>no-</c></b>
146prefix, and their effects are enclosed within the square brackets, [].
147</p>
148
149</body>
150</section>
151<section>
152<title>Configuration Flags</title>
153<body>
154
155<p>
156The configuration flags listed below exist to help you decide what features
157should be enabled or disabled in the kernel prior to compilation. You can even
158choose whether or not the configuration file created in the process should be
159saved. The following are the primary configuration flags:
160</p>
161
162<ul>
163 <li>
164 <b>--<c>no-</c>menuconfig</b>: Activates <e>[or deactivates]</e> the
165 <c>make menuconfig</c> command (which invokes an interactive, menu-based
166 kernel configuration utility), before building the kernel.
167 </li>
168 <li>
169 <b>--gconfig</b>: Provides a kernel configuration utility which depends on
170 the GTK+ libraries. The advantage of this option is that most users find it
171 easier and clearer to configure the kernel using this tool, since it relies
172 on the X-windowing system. The disadvantage of this option is that you
173 <b>need</b> the X-windowing system to use it, so it will not work on the
174 command line.
175 </li>
176 <li>
177 <b>--xconfig</b>: Provides a kernel configuration utility which depends on
178 the QT libraries. The advantage of this option is that most users find it
179 easier and clearer to configure the kernel using this tool, since it relies
180 on the X-windowing system. The disadvantage of this option is that you
181 <b>need</b> the X-windowing system to use it, so it will not work on the
182 command line.
183 </li>
184 <li>
185 <b>--<c>no-</c>save-config</b>: Saves <e>[or does not save]</e> the kernel
186 configuration to a file in the <path>/etc/kernels/</path> directory for
187 later use.
188 </li>
189</ul>
190
191</body>
192</section>
193<section>
194<title>Compilation Flags</title>
195<body>
196
197<p>
198The following flags usually take effect during the actual compilation:
199</p>
200
201<ul>
202 <li>
203 <b>--kerneldir=<path>/path/to/sources/</path></b>: Specifies an alternative
204 kernel source location, rather than the default
205 <path>/usr/src/linux/</path> location.
206 </li>
207 <li>
208 <b>--kernel-config=<path>/path/to/config-file</path></b>: Specifies what
209 alternative kernel configuration will be used, rather than the default
210 <path>/path/to/sources/.config</path> file.
211 </li>
212 <li>
213 <b>--module-prefix=<path>/path/to/prefix-directory/</path></b>: Specifies a
214 prefix to the directory where kernel modules will be installed (default
215 path is the <path>/lib/modules/</path> directory.)
216 </li>
217</ul>
218
219<ul>
220 <li>
221 <b>--<c>no-</c>clean</b>: Activates <e>[or deactivates]</e> the <c>make
222 clean</c> command before compiling your kernel. The <c>make clean</c>
223 command removes all object files and dependencies from the kernel's source
224 tree.
225 </li>
226 <li>
227 <b>--<c>no-</c>mrproper</b>: Activates <e>[or deactivates]</e> the <c>make
228 mrproper</c> command before kernel compilation. Like the <c>make clean</c>
229 command, <c>make mrproper</c> removes all object files and dependencies
230 from the kernel's source tree. However, any previous configuration files
231 (in <path>/path/to/sources/.config</path> or
232 <path>/path/to/sources/.config.old</path>) will <b>also</b> be purged from
233 the kernel's source tree.
234 </li>
235 <li>
236 <b>--oldconfig</b>: Issues the <c>make oldconfig</c> command, which
237 attempts to collect configuration information for the system's architecture
238 from a generic script in <path>/usr/share/genkernel/</path>. This is a
239 non-interactive process; no user input is entertained. Also, if
240 <c>--oldconfig</c> is used in conjunction with <c>--clean</c>, the latter
241 flag is negated, resulting in the activation of the <c>--no-clean</c> flag.
242 </li>
243</ul>
244
245<ul>
246 <li>
247 <b>--callback="<c>echo hello</c>"</b>: Calls the specified arguments
248 (<c>echo hello</c>, in this case) after the kernel and the relevant modules
249 have been built, but before building the initrd image. This may be useful
250 if you want to install external modules in the initrd image by emerging the
251 relevant item(s) with the callback feature, and then redefining a genkernel
252 module group.
253 </li>
254</ul>
255
256<ul>
257 <li>
258 <b>--<c>no-</c>install</b>: Activates <e>[or deactivates]</e> the <c>make
259 install</c> command, which installs your new kernel image, configuration
260 file, initrd image and system map onto your mounted boot partition. Any
261 compiled modules will be installed as well.
262 </li>
263 <li>
264 <b>--no-ramdisk-modules</b>: Refrains from copying any modules to the
265 genkernel-created initrd image. This flag is an exception to the rule about
266 the <c>no-</c> prefix; omission of this prefix creates an invalid genkernel
267 flag.
268 </li>
269 <li>
270 <b>--all-ramdisk-modules</b>: Copies all available modules to the
271 genkernel-created initrd image.
272 </li>
273 <li>
274 <b>--genzimage</b>: Creates the initrd image, prior to the kernel image.
275 (This hack currently applies only to PPC Pegasos systems.)
276 </li>
277</ul>
278
279</body>
280</section>
281<section>
282<title>Compiler Flags</title>
283<body>
284
285<p>
286The following flags are supported by genkernel, and are passed to the relevant
287applications while the kernel is being assembled. These flags affect the
288<e>compiler</e> used for the kernel compilation process, albeit at a much lower
289level.
290</p>
291
292<ul>
293 <li>
294 <b>--kernel-cc=<c>someCompiler</c></b>: Specifies the compiler employed
295 during the kernel compilation process.
296 </li>
297 <li>
298 <b>--kernel-ld=<c>someLinker</c></b>: Specifies the linker employed during
299 the kernel compilation process.
300 </li>
301 <li>
302 <b>--kernel-as=<c>someAssembler</c></b>: Specifies the assembler employed
303 during the kernel compilation process.
304 </li>
305 <li>
306 <b>--kernel-make=<c>someMake</c></b>: Specifies an alternative to the
307 <e>GNU make</e> utility employed during the kernel compilation process.
308 </li>
309</ul>
310
311<ul>
312 <li>
313 <b>--utils-cc=<c>someCompiler</c></b>: Specifies the compiler employed
314 during the compilation of support utilities.
315 </li>
316 <li>
317 <b>--utils-ld=<c>someLinker</c></b>: Specifies the linker employed during
318 the compilation of support utilities.
319 </li>
320 <li>
321 <b>--utils-as=<c>someAssembler</c></b>: Specifies the assembler employed
322 during the compilation of support utilities.
323 </li>
324 <li>
325 <b>--utils-make=<c>someMake</c></b>: Specifies an alternative to the <e>GNU
326 make</e> utility employed during the compilation of support utilities.
327 </li>
328</ul>
329
330<ul>
331 <li>
332 <b>--makeopts=<c>-jX</c></b>: Specifies the number of concurrent threads
333 that the make utility can implement while the kernel (and utilities) are
334 being compiled. The variable <b>'X'</b> is a number obtained by adding one
335 (1) to the number of CPUs used by the system. So, for a system with one
336 CPU, the appropriate flag is <c>-j2</c>; a system with two CPUs will use
337 the <c>-j3</c> flag, and so on. <e>(A system with one processor that
338 supports Hyper-Threading&trade; (HT) Technology can use the
339 </e><c>-j3</c><e> flag, provided Symmetric Multi-Processing (SMP) support is
340 enabled in the kernel.)</e>
341 </li>
342</ul>
343
344</body>
345</section>
346<section>
347<title>Debugging Flags</title>
348<body>
349
350<p>
351The use of debugging flags during the kernel compilation process controls the
352amount of information reported, as well as the presentation of said data.
353</p>
354
355<ul>
356 <li>
357 <b>--loglevel=<c>verblevel</c></b>: Controls the level of verbosity for
358 information provided by genkernel. The variable <c>verblevel</c> is an
359 integer between 0 and 5. The level '0' represents minimal output, while '5'
360 provides as much information as possible about genkernel's activities
361 during the kernel compilation process.
362 </li>
363 <li>
364 <b>--logfile=<path>/path/to/outputfile</path></b>: Ignores the value set
365 by the <c>--loglevel</c> argument, and sends <b>all</b> debugging data
366 produced by genkernel to the specified output file, which is located at
367 <path>/var/log/genkernel.log</path> by default.
368 </li>
369 <li>
370 <b>--no-color</b>: Activates <e>[or deactivates]</e> colored output of
371 debugging information (reported by genkernel) using escape sequences.
372 </li>
373</ul>
374
375</body>
376</section>
377
378<section>
379<title>Initialization Flags</title>
380<body>
381
382<p>
383The flags here are used to create certain effects during system startup. Some
384of these flags are primarily for aesthetics, while others may be essential for
385enabling certain features on the system.
386</p>
387
388<ul>
389 <li>
390 <b>--<c>no-</c>splash</b>: Activates <e>[or deactivates]</e> support for
391 <uri link="http://fbsplash.berlios.de/wiki/doku.php">framebuffer
392 splash</uri> support in the genkernel-built initrd image. To override the
393 default theme used by fbsplash, use <b>--splash=<c>PreferredTheme</c></b>
394 (where <c>PreferredTheme</c> is the title of one of the directories inside
395 the <path>/etc/splash/</path> directory.
396 </li>
397 <li>
398 <b>--splash-res=<c>PreferredResolution</c></b>: This flag allows you to
399 select which splash screen resolutions will be supported in the initrd
400 during the start-up of the system. This is useful for two reasons: First,
401 you are able to select only the splash screen resolution(s) relevant to your
402 system. Second, you avoid the unnecessary increase in the disk space
403 required by initrd (since the initrd does not have to support resolutions
404 that are irrelevant for your system configuration.) However, you may want to
405 omit this flag if the kernel is being compiled for an Installation CD; this
406 allows splash support for all possible resolutions.
407 </li>
408 <li>
409 <b>--do-keymap-auto</b>: Force keymap selection during the boot sequence.
410 </li>
411 <li>
412 <b>--lvm</b>: Includes support for storage using via <uri
413 link="http://sources.redhat.com/lvm2/">Logical Volume Management</uri>
414 (LVM2) from <e>static</e> binaries, if available to the system. Relevant
415 (static) LVM2 binaries are compiled if they are unavailable. Be sure to
416 install the lvm2 package on your system with <c>emerge lvm2</c> before
417 enabling this flag, and review the <uri
418 link="https://wiki.gentoo.org/wiki/LVM">LVM article</uri>
419 on the Gentoo wiki.
420 </li>
421 <li>
422 <b>--dmraid</b>: Includes support for <uri
423 link="http://people.redhat.com/~heinzm/sw/dmraid/readme">DMRAID</uri>; the
424 utility which creates RAID mappings using the kernel device-mapper
425 subsystem. DMRAID discovers, activates, deactivates and displays properties
426 of software RAID sets (ATARAID, for example) and contained DOS partitions.
427 </li>
428 <li>
429 <b>--luks</b>: Includes support for <uri
430 link="http://luks.endorphin.org/">Linux Unified Key Setup</uri> or LUKS.
431 This will allow you to use a device encrypted by LUKS which contains the
432 root filesystem. On the bootloader, you then set that encrypted device as
433 the value of crypt_root (and real_root shall be the unencrypted device LUKS
434 creates).
435 </li>
436 <li>
437 <b>--disklabel</b>: Adds support for disk label and UUID support to your
438 initrd.
439 </li>
440 <li>
441 <b>--iscsi</b>: Adds support for iSCSI to your initrd.
442 </li>
443 <li>
444 <b>--multipath</b>: Adds support for <uri
445 link="https://wiki.gentoo.org/wiki/Multipath">Multipath</uri> to your initrd.
446 </li>
447 <li>
448 <b>--linuxrc=/path/to/your/linuxrc</b>: Specifies a user-created
449 <e>linuxrc</e> &mdash; a script that is initialized during the start-up
450 stage of the kernel, prior to the actual boot process. (A default linuxrc
451 script should be in the <path>/usr/share/genkernel/</path> directory.) This
452 script allows you to boot into a small, modularized kernel and load the
453 drivers that are needed (as modules) by the system.
454 </li>
455 <li>
456 <b>--cachedir=/path/to/alt/dir/</b>: Overrides the default cache location
457 used while compiling the kernel.
458 </li>
459 <li>
460 <b>--tempdir=/path/to/new/tempdir/</b>: Specifies the location of the
461 temporary directory used by genkernel while compiling the kernel.
462 </li>
463 <li>
464 <b>--unionfs</b>: Includes support for the <uri
465 link="http://www.fsl.cs.sunysb.edu/project-unionfs.html">Unification File
466 System</uri> in the initrd image.
467 </li>
468</ul>
469
470</body>
471</section>
472<section>
473<title>Miscellaneous Flags</title>
474<body>
475
476<p>
477The assortment of flags listed below are supported by genkernel, but do not fit
478neatly into any of the other categories:
479</p>
480
481<ul>
482 <li>
483 <b>--mountboot</b>: Detects whether or not the <path>/boot/</path>
484 directory needs to be mounted on a separate partition. It will check
485 <path>/etc/fstab</path> script for instructions on how to mount the boot
486 partition on a file system (if needed).
487 </li>
488 <li>
489 <b>--kernname=<c>NickName</c></b>: Allows you to modify the name of the
490 kernel and initrd images in the <path>/boot/</path> directory, so that the
491 images produced are kernel-<c>NickName</c>-version and
492 initramfs-<c>NickName</c>-version.
493 </li>
494</ul>
495
496</body>
497</section>
498<section>
499<title>Possible Actions</title>
500<body>
501
502<p>
503An action tells genkernel what to build. Currently, the following actions are
504supported:
505</p>
506
507<ul>
508 <li>
509 <c>all</c>: Builds all stages &mdash; the initrd, kernel image and modules.
510 </li>
511 <li><c>bzImage</c>: Only builds the kernel image</li>
512 <li><c>kernel</c>: Only builds the kernel image and modules</li>
513 <li><c>initramfs</c>: Only builds the initramfs/ramdisk image</li>
514 <li><c>ramdisk</c>: Only builds the initramfs/ramdisk image</li>
515</ul>
516
517<p>
518The first action, <c>all</c>, is recommended for most users since it builds the
519stages required for a functional kernel. Remember, an <e>action</e> simply
520tells genkernel what to <e>build</e>, not <e>install</e>.
521</p>
522
523</body>
524</section>
525<section>
526<title>Bootloader Configuration</title>
527<body>
528
529<p>
530To set up genkernel to work with your bootloader, three or four changes should
531be applied to the bootloader's configuration file:
532</p>
533
534<ol>
535 <li>
536 Add <c>real_root=/dev/sda3</c>, for example, to the kernel parameters
537 passed to the kernel image, if <path>/dev/sda3</path> contains your root
538 partition.
539 </li>
540 <li>
541 If you are using splash, add a suitable mode line such as <c>vga=0x317</c>
542 to the parameters passed to the kernel and also add <c>splash=verbose</c> or
543 <c>splash=silent</c> depending on the verboseness you require from your
544 bootloader.
545 </li>
546 <li>
547 Add the initrd information as required by the bootloader. Consult the <uri
548 link="/doc/en/handbook/handbook-x86.xml?part=1&amp;chap=10">Bootloader
549 Configuration Chapter</uri> of the Gentoo Handbook for details on how to
550 make your bootloader initrd-aware.
551 </li>
552</ol>
553
554</body>
555</section>
556</chapter>
557
558<chapter>
559<title>Configuration Options</title>
560<section>
561<title>Editing /etc/genkernel.conf</title>
562<body>
563
564<p>
565Passing flags to genkernel from the command line can be cumbersome, especially
566if you have about a dozen flags:
567</p>
568
569<pre caption="Running genkernel (overloaded with flags)">
570# <i>genkernel --loglevel=5 --no-color --no-mrproper --clean --splash \
571--kerneldir=/path/to/alternate/kernel/sources --install --menuconfig \
572--kernel-config=/path/to/preferred/configfile --save-config --mountboot all</i>
573</pre>
574
575<p>
576Fortunately, there is a configuration file where most of the basic options can
577be set (or changed) as necessary: <path>/etc/genkernel.conf</path>. What follows
578is a rundown of the more relevant options:
579</p>
580
581<ul>
582 <li>
583 <b>MENUCONFIG=<c>[yes|no]</c></b>: This option is equivalent to the
584 <c>--menuconfig</c> flag used by genkernel, which in turn uses the <c>make
585 menuconfig</c> command to invoke a command-line based kernel configuration
586 utility. To invoke the utility automatically during kernel configuration
587 via this script, set this option to 'yes' here; otherwise, choose 'no'.
588 </li>
589 <li>
590 <b>CLEAN=<c>[yes|no]</c></b>: Setting this option to 'yes' is equivalent to
591 the <c>--clean</c> flag used by genkernel, and invokes the <c>make
592 clean</c> command to remove all object files and dependencies from the
593 kernel's source tree. Setting this option to 'no' creates a cascade effect
594 &#8212; it is equivalent to genkernel's <c>--no-clean</c> flag, which
595 disables the <c>make clean</c> command and implies genkernel's
596 <c>--no-mrproper</c> flag &mdash; essentially nullifying the <c>make
597 mrproper</c> command.
598 </li>
599 <li>
600 <b>MRPROPER=<c>[yes|no]</c></b>: Setting this option to 'yes' is equivalent
601 to <c>--mrproper</c> flag used by genkernel, and invokes the <c>make
602 mrproper</c> command, which purges the kernel source tree of any
603 configuration files. Selecting 'no' here is equivalent to genkernel's
604 <c>--no-mrproper</c> flag, which disables the <c>make mrproper</c> command.
605 </li>
606 <li>
607 <b>MOUNTBOOT=<c>[yes|no]</c></b>: Setting this option to 'yes' is
608 equivalent to the <c>--mountboot</c> flag, and automatically mounts the
609 <path>/boot/</path> directory (if needed) at compile time. If the
610 <path>/boot/</path> directory is on a separate partition, consider enabling
611 this option; it will make for one less (essential) step to remember later.
612 </li>
613 <li>
614 <b>SAVE_CONFIG=<c>[yes|no]</c></b>: After configuring the kernel, the
615 selected options are stored as <path>.config</path> in the kernel source
616 tree. This script may be overwritten during the next kernel compilation, or
617 even purged from the kernel source tree. Choosing 'yes' here is equivalent
618 to the <c>--save-config</c> flag, and stores all options selected during
619 kernel configuration as a script in the <path>/etc/kernels/</path>
620 directory. Choosing 'no' preserves the <e>status quo</e>.
621 </li>
622 <li>
623 <b>USECOLOR=<c>[yes|no]</c></b>: Setting this option to 'yes' is equivalent
624 to the <c>--color</c> flag, which colors genkernel's output to ease
625 debugging (when needed.)
626 </li>
627 <li>
628 <b>LOGLEVEL=<c>[0|1|2|3|4|5]</c></b>: This option is for adjusting the
629 verbosity of the output produced by genkernel &mdash; setting this option to
630 '0' with <c>--loglevel=0</c> will suppress all output produced by
631 genkernel; setting this option to '5' with <c>--loglevel=5</c> provides
632 the user with all output produced by genkernel.
633 </li>
634</ul>
635
636<note>
637More options are described in <path>/etc/genkernel.conf</path>.
638</note>
639
640<p>
641By choosing the appropriate options in <path>/etc/genkernel.conf</path>, you
642can halve the number of flags passed to genkernel from the command line:
643</p>
644
645<pre caption="Running genkernel (with flags), after employing genkernel.conf">
646# <i>genkernel --splash --kerneldir=/path/to/alternate/kernel/sources \
647--kernel-config=/path/to/preferred/configfile --install all</i>
648</pre>
649
650<p>
651Identical results are obtained from both approaches, but the latter has most of
652the options stored in a script that can be modified at a later date.
653</p>
654
655</body>
656</section>
657</chapter>
658
659<chapter>
660<title>Network-Booting with genkernel</title>
661<section>
662<title>Network Booting from an Installation CD</title>
663<body>
664
665<p>
666The genkernel utility can build kernel and initrd images that provide support
667for network booting, or <e>netboot</e>ing. With any luck, you should be able
668to netboot any recent computer into the environment provided by the
669Installation CD.
670</p>
671
672<p>
673The magic lies in genkernel's linuxrc script: it will try to <e>netmount</e>
674the Installation CD using NFS. From there, <e>the init scripts</e> of the
675Installation CD can take over, as if the CD was present locally.
676</p>
677
678</body>
679</section>
680<section>
681<title>Building Kernel and Initrd Images with Support for Netbooting</title>
682<body>
683
684<p>
685To enable support for netbooting, include the following options while
686configuring the kernel:
687</p>
688
689<warn>
690Support for netbooting with genkernel is experimental and may contain bugs.
691</warn>
692
693<p>
694First, the kernel image must include the drivers for your Network Interface
695Cards (NIC). Normally, drivers for such devices will be compiled as modules.
696However, it is essential (for netbooting) that you have such drivers compiled
697directly into the kernel image and <b>not</b> as modules.
698</p>
699
700<pre caption="Configuring a 2.6.x series kernel to support your NIC driver">
701Device Drivers --->
702 Networking Support --->
703 Ethernet (10 or 100Mbit) --->
704 [*] Ethernet (10 or 100Mbit)
705 &lt;*&gt; the driver for your network card
706<comment>(Be sure to select &lt;*&gt; and not &lt;M&gt;)</comment>
707</pre>
708
709<p>
710Secondly, we suggest that you enable <c>IP: kernel level autoconfiguration</c>
711and the <c>IP: DHCP support</c> options. This avoids an unnecessary layer of
712complexity since the IP address and the NFS path to the Installation CD can be
713configured on a DHCP server. Of course, this means the kernel command line
714will remain constant for any machine &mdash; which is very important for
715<e>etherbooting</e>.
716</p>
717
718<pre caption="Configuring a 2.6.x series kernel to support DHCP">
719Device Drivers --->
720 Networking Support --->
721 Networking options
722 [*] TCP/IP networking--->
723 [*] IP: kernel level autoconfiguration
724 [*] IP: DHCP support
725<comment>(These options tell the kernel to send a DHCP request at bootup.)</comment>
726</pre>
727
728<p>
729Additionally, you should enable SquashFS because most modern Gentoo
730Installation CDs require it. Support for SquashFS is not included with the
731generic kernel source tree. To enable SquashFS, apply the necessary patches to
732the generic kernel source or install <c>gentoo-sources</c>.
733</p>
734
735<pre caption="Configuring the kernel to support SquashFS">
736File systems--->
737 Miscellaneous filesystems --->
738 [*] SquashFS 2.X - Squashed file system support
739</pre>
740
741<p>
742Once the compilation process is completed, create a compressed <e>tarball</e>
743(tar.gz) that contains the kernel's modules. This step is only necessary if
744your kernel version does not match the kernel image version on the Installation
745CD.
746</p>
747
748<pre caption="Creating a compressed tarball containing the kernel modules">
749<comment>(Create a tar.gz containing all the modules)</comment>
750# <i>cd /</i>
751# <i>tar -cf /tmp/modules-X.Y.Z.tar.gz /lib/modules/X.Y.Z/</i>
752</pre>
753
754<p>
755Depending on your network boot mechanism, you will need to do some of the
756following steps:
757</p>
758
759<pre caption="Creating a boot image">
760<comment>(Create an etherboot image)</comment>
761# <i>emerge mknbi</i>
762# <i>cd /boot</i>
763# <i>mkelf-linux -params="root=/dev/ram0 init=/linuxrc ip=dhcp" kernel... initrd... > etherboot.img</i>
764
765<comment>(Create a OpenBoot / SPARC64 TFTP image)</comment>
766# <i>emerge sparc-utils</i>
767# <i>cd /boot</i>
768# <i>elftoaout kernel... -o kernel.aout</i>
769# <i>piggyback64 kernel.aout System.map-... initrd-...</i>
770# <i>mv kernel.aout openboot.img</i> <comment>(This is the boot image)</comment>
771
772<comment>(PXE does not need any more steps, the kernel and initrd can be used as is)</comment>
773</pre>
774
775<p>
776Finally, copy this kernel to your TFTP server. The details are
777architecture-dependent and are beyond the scope of this guide. Please refer to
778the documentation for your platform.
779</p>
780
781</body>
782</section>
783<section>
784<title>NFS Setup</title>
785<body>
786
787<p>
788To setup a NFS share that contains the Installation CD, use the loop device to
789mount the ISO image and then copy the contents of the CD into the NFS share. As
790a nice extra, genkernel's initrd scripts will extract all tar.gz files located
791in the <path>/nfs/livecd/add/</path> directory. All you have to do here is copy
792the <c>modules-X.Y.Z.tar.gz</c> archive to the <path>/nfs/livecd/add/</path>
793directory.
794</p>
795
796<pre caption="Preparing the NFS share">
797<comment>(This assumes that /nfs/livecd is an exported NFS share)</comment>
798# <i>mount /tmp/gentoo-livecd.iso /mnt/cdrom -o loop</i>
799# <i>cp -p /mnt/cdrom /nfs/livecd</i>
800# <i>umount /mnt/cdrom</i>
801
802<comment>(Copy the modules.tar.gz into /add)</comment>
803# <i>mkdir /nfs/livecd/add</i>
804# <i>cp /tmp/modules-X.Y.Z.tar.gz /nfs/livecd/add</i>
805</pre>
806
807</body>
808</section>
809<section>
810<title>DHCP Setup</title>
811<body>
812
813<p>
814The netboot images will ask your DHCP server for an IP as well as a root-path
815parameter. Both can be specified per host using a MAC address to identify
816machines:
817</p>
818
819<pre caption="Sample client dhcpd.conf setup">
820...
821
822host netbootableMachine {
823 hardware ethernet 11:22:33:44:55:66;
824 fixed-address 192.168.1.10;
825 option root-path "192.168.1.2:/nfs/livecd";
826}
827<comment># Here, 192.168.1.2 is the NFS server
828# While 192.168.1.10 will be the IP address of the netbooted machine</comment>
829...
830</pre>
831
832</body>
833</section>
834<section>
835<title>Netbooting Instructions</title>
836<body>
837
838<p>
839Netbooting itself is again very platform-specific. The important part is to
840specify the <c>ip=dhcp</c> and <c>init=/linuxrc</c> parameters on the kernel
841command line, as this will bring up the network interface and tell the initrd
842scripts to mount the Installation CD via NFS. Here are some platform-specific
843tips:
844</p>
845
846<pre caption="Netbooting Instructions">
847<comment># Etherboot - insert the etherboot disk into the drive and reboot
848# The kernel command line was specified when the image was constructed</comment>
849
850<comment># Sparc64 - Hit Stop-A at the boot prompt</comment>
851ok boot net ip=dhcp init=/linuxrc
852
853<comment># PXE - Setup pxelinux (part of syslinux),
854then create a pxelinux.cfg/default along the lines of:</comment>
855
856DEFAULT gentoo
857TIMEOUT 40
858PROMPT 1
859
860LABEL gentoo
861 KERNEL kernel-X.Y.Z
862 APPEND initrd=initrd-X.Y.Z root=/dev/ram0 init=/linuxrc ip=dhcp
863</pre>
864
865</body>
866</section>
867</chapter>
868
869<chapter>
870<title>Booting a genkernel initramfs</title>
871<section>
22<title>Introduction</title> 872<title>Introduction</title>
23<body> 873<body>
24 874
25<p> 875<p>
26Genkernel is designed to allow users who are not previously used to 876If you installed an initramfs with genkernel, you should definitely take a look
27compiling a kernel to use a similar setup to that one that is used on 877at the various boot options that you can (or need to) define in your bootloader
28the Gentoo LiveCDs which auto-detects your hardware. 878configuration. The most common ones are added to this guide for your reference.
29</p>
30
31<p> 879</p>
32Some users may also be interested in using genkernel for hardware
33which requires initialization and a working kernel before it can be
34booted. Because genkernel also automatically compiles your kernel modules,
35thus allowing hardware which needs to be loaded with module parameters
36to be used.
37</p>
38 880
39</body> 881</body>
40</section>
41<section> 882</section>
42<title>Is genkernel for me?</title>
43<body>
44
45<p>
46Genkernel is often a good choice to those who are unused to compiling
47their own kernel or those who are not certain about their hardware
48configurations.
49</p>
50
51<p>
52Because genkernel is designed to use a generic configuration, it
53should be able to support all of your hardware - however, because all
54the drivers and modules have to be compiled as well, compiling a
55kernel by yourself is often much faster provided you know what you need.
56</p>
57
58<p>
59Genkernel does not however, currently support booting the sytem from
60LVM2/EVMS2 partitions. Users are recommended to use a manually compiled
61kernel for the time being.
62</p>
63
64</body>
65</section> 883<section>
884<title>Loading LVM or software-RAID</title>
885<body>
886
887<p>
888If your system uses LVM or software-RAID, you undoubtedly have built the
889initramfs using the <c>--lvm</c> and <c>--mdadm</c> options (didn't you).
890However, you should not forget to enable support during boot as well. This can
891be done using the <c>dolvm</c> and <c>domdadm</c> options.
892</p>
893
894<pre caption="Enabling LVM and/or MDADM support">
895<comment># Example for GRUB 1.x</comment>
896title Gentoo Linux
897root (hd0,0)
898kernel /vmlinuz root=/dev/md3 <i>dolvm domdadm</i>
899initrd /initramfs-genkernel-x86_64-3.4.3
900</pre>
901
902</body>
66<section> 903</section>
67<title>Getting genkernel</title>
68<body>
69
70<p>
71You can obtain genkernel by simply running <c>emerge genkernel</c>. Don't
72forget to use the <c>-k</c> flag for emerge if you are using binary packages,
73i.e. GRP. Due to the GRP packages having an older version of genkernel, the
74flags are different. As a result, you should consult the <uri
75link="http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&amp;chap=9">
76Gentoo Handbook</uri> and <path>genkernel --help</path>.
77</p>
78
79</body>
80</section> 904<section>
81<section> 905<title>Booting in single-user mode</title>
82<title>Supported platforms</title>
83<body> 906<body>
84 907
85<p>
86As of genkernel 3.0.1_beta12; the following platforms should be
87supported: alpha, amd64, parisc, parisc64, ppc, sparc, sparc64, and x86. If
88you believe that there is a bug with the support code, and not with
89genkernel, please file a bug at the <uri
90link="http://bugs.gentoo.org">Gentoo Bugzilla.</uri>
91</p> 908<p>
909If for some reason boot-up fails, you might be able to rescue your system by
910booting in the single-user mode. This will only load the really necessary
911services and then drop you to a rescue (root) shell.
912</p>
913
914<pre caption="Booting in single-user mode">
915<comment># Example for GRUB 1.x</comment>
916title Gentoo Linux
917root (hd0,0)
918kernel /vmlinuz root=/dev/md3 <i>init_opts=S</i>
919initrd /initramfs-genkernel-x86_64-3.4.3
920</pre>
92 921
93</body> 922</body>
94</section> 923</section>
95</chapter> 924</chapter>
96 925
97<chapter> 926<chapter>
98<title>Genkernel usage</title>
99<section>
100<title>Introduction</title> 927<title>Conclusion</title>
101<body>
102
103<p>
104Genkernel is designed to work in three modes:
105</p>
106
107<ul>
108 <li>"all" mode: this builds the kernel and the initrd</li>
109 <li>"kernel" mode: this only builds the kernel image</li>
110 <li>"initrd" mode: this only builds the initrd</li>
111</ul>
112
113<p>
114Most users will only want the "all" mode, which runs the "kernel" mode
115and the "initrd" mode for you. <b>Note</b> that the "kernel" and "initrd"
116modes are currently just aliases for the "all" mode, so they will
117currently give you no special effect.
118</p>
119
120<p>
121Although genkernel is mainly a command to make your life easier when
122you need to compile a kernel, genkernel is also packed full of
123different flags which allow you to customize how your kernel is
124compiled or configured.
125</p>
126
127</body>
128</section> 928<section>
129<section> 929<title>To Automate or not to Automate?</title>
130<title>Genkernel compiler flags</title>
131<body>
132
133<p>
134Genkernel supports the following flags which are passed to the
135relevant applications when your kernel is assembled:
136</p>
137
138<ul>
139 <li>
140 <b>--kernel-as=<c>someAssembler</c></b>: This specifies an assembler which
141 would be used for compiling your kernel.
142 </li>
143 <li>
144 <b>--kernel-cc=<c>someCompiler</c></b>: This specifies a compiler which
145 would be used for compiling your kernel.
146 </li>
147 <li>
148 <b>--kernel-ld=<c>someLinker</c></b>: This specifies a linker which would
149 be used for compiling your kernel.
150 </li>
151 <li>
152 <b>--kernel-make=<c>someMake</c></b>: This specifies an alternate GNU Make
153 which would be used for compiling your kernel.
154 </li>
155</ul>
156
157<ul>
158 <li>
159 <b>--utils-as=<c>someAssembler</c></b>: This specifies an assembler which
160 would be used for compiling the support utilities.
161 </li>
162 <li>
163 <b>--utils-cc=<c>someCompiler</c></b>: This specifies a compiler which
164 would be used for compiling the support utilities.
165 </li>
166 <li>
167 <b>--utils-ld=<c>someLinker</c></b>: This specifies a linker which would be
168 used for compiling the support utilities.
169 </li>
170 <li>
171 <b>--utils-make=<c>someMake</c></b>: This specifies an alternate GNU Make
172 which would be used for compiling the support utilities.
173 </li>
174</ul>
175
176<ul>
177 <li>
178 <b>--makeopts=<c>-jJobs</c></b>: This specifies the flags which would be
179 passed to GNU Make when the kernel and utilities are being compiled.
180 </li>
181</ul>
182
183</body> 930<body>
184</section>
185<section>
186<title>Genkernel kernel flags</title>
187<body>
188 931
189<p>
190Genkernel supports the following flags, some of which have
191<c>--<b>no-</b>option</c> equivalents that influence
192kernel compilation:
193</p> 932<p>
194 933The purpose of genkernel is to provide an (easier) alternative to the
195<ul> 934time-tested approach to kernel compilation. As always, you are free to decide
196 <li> 935on whether or not you want to automate the kernel compilation process.
197 <b>--clean</b>: This runs a <c>make clean</c> before compiling your
198 kernel. This causes all object files and dependencies to be removed.
199 </li>
200 <li>
201 <b>--mrproper</b>: This runs a <c>make mrproper</c> before compiling your
202 kernel. This causes all object files, dependencies <e>and your
203 configuration</e> to be removed.
204 </li>
205</ul>
206
207<ul>
208 <li>
209 <b>--kerneldir=<path>/path/to/sources</path></b>: This specifies an
210 alternative kernel source location, instead of the default location of
211 <path>/usr/src/linux</path>.
212 </li>
213 <li>
214 <b>--kernel-config=<path>/path/to/config-file</path></b>: This specifies an
215 alternative kernel configuration which would be used; rather than the
216 inpersistant <path>/path/to/sources/.config</path> which is used by
217 default.
218 </li>
219</ul>
220
221<ul>
222 <li>
223 <b>--<c>no-</c>bootsplash</b>: This adds <e>or does not add</e> bootsplash
224 support in the initrd which genkernel builds. Not all architectures
225 currently support bootsplash, and a kernel that supports bootsplash is
226 also required.
227 </li>
228 <li>
229 <b>--<c>no-</c>menuconfig</b>: This runs <e>or does not run</e> the kernel
230 menu-based configurator before building your kernel, after <c>make
231 oldconfig</c> has ran.
232 </li>
233</ul>
234
235<ul>
236 <li>
237 <b>--no-initrdmodules</b>: This doesn't copy any modules to the initrd
238 which genkernel creates.
239 </li>
240 <li>
241 <b>--<c>no-</c>install</b>: This installs <e>or does not install</e> your
242 kernel, modules, and initrd one the compilation has finished.
243 </li>
244</ul>
245
246</body>
247</section>
248<section>
249<title>Genkernel miscellaenous flags</title>
250<body>
251
252<p> 936</p>
253Genkernel also supports some miscellaneous flags which do not fit into
254the other two categories:
255</p>
256
257<ul>
258 <li>
259 <b>--arch-override=<c>someArch</c></b>: This flag can be used to override
260 what architecture genkernel thinks you're on, if the auto-detection
261 mechanism fails (please file a bug if it does!) or if you wish to
262 cross-compile a kernel.
263 </li>
264</ul>
265
266<ul>
267 <li>
268 <b>--busybox-config=<path>/path/to/busybox-config</path></b>: This
269 overrides the default busybox configuration with the specifid file
270 </li>
271 <li>
272 <b>--busybox-bin=<path>/path/to/busybox-binary.tar.bz2</path></b>: Using
273 this option means that a busybox binary would not be compiled, and the
274 specified tarball would be used. Note that busybox <e>must</e> be compiled
275 statically!
276 </li>
277</ul>
278
279<ul>
280 <li>
281 <b>--minkernpackage=<path>/output/to/yourkernel.tar.bz2</path></b>: This
282 flag outputs a tarball of the kernel, named as <path>kernel</path> and the
283 initrd named as <path>initrd</path> to the specified file. No path
284 information or modules will be includes in the tarball.
285 </li>
286</ul>
287
288</body>
289</section>
290<section>
291<title>Running genkernel</title>
292<body>
293
294<p>
295All that is needed to run genkernel is just genkernel with the
296necessary flags as root. For example:
297</p>
298
299<pre caption="Running genkernel">
300# genkernel --menuconfig --no-clean --no-install --bootsplash
301<comment>(Would produce a kernel, asking you what how to configure it
302to your desire, leaving alone any compiled object files, enabling
303bootsplash support but not installing anything.)</comment>
304</pre>
305
306<p>
307If you want genkernel to install your kernel as well, you must ensure
308that your <path>/boot</path> partition is mounted:
309</p>
310
311<pre caption="Mounting your /boot">
312<comment>(If /boot is a valid entry in /etc/fstab:)</comment>
313# mount /boot
314<comment>(... otherwise for IDE disks:)</comment>
315# mount /dev/hda1 /boot
316<comment>(... and for SCSI disks:)</comment>
317# mount /dev/sda1 /boot
318</pre>
319
320</body>
321</section>
322<section>
323<title>Setting up genkernel to work with your bootloader</title>
324<body>
325
326<p>
327To set up genkernel to work with your bootloader, three or four changes are
328required to your bootloader configuration.
329</p>
330
331<ol>
332 <li>
333 Add <c>root=/dev/ram0</c> and <c>init=/linuxrc</c> to the
334 kernel parameters passed to the kernel image.
335 </li>
336 <li>
337 Add <c>real_root=/dev/hda3</c>, for example, to the kernel parameters
338 passed to the kernel image if <path>/dev/hda3</path> contains your root
339 partition.
340 </li>
341 <li>
342 If you are using bootsplash, add a suitable modeline such as
343 <c>vga=0x317</c> to the parameters passed to the kernel and also add
344 <c>splash=verbose</c> or <c>splash=silent</c> depending on the verboseness
345 you require from your bootsplash.
346 </li>
347 <li>
348 Add the initrd according to how your bootloader requires it: see the <uri
349 link="http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&amp;chap=9">Gentoo
350 Handbook</uri> for details on how you would do it for your bootloader.
351 </li>
352</ol>
353 937
354</body> 938</body>
355</section> 939</section>
356</chapter> 940</chapter>
357 941
358<chapter>
359<title>Porting genkernel</title>
360<section>
361<title>Introduction</title>
362<body>
363
364<p>
365Provided your architecture has all the required libraries and utilties
366which genkernel requires, which includes but it not limited to a
367working kernel for your architecture, working compiler suite, GNU
368Make, and a working busybox distribution, you're all set to go!
369</p>
370
371<p>
372For each architecture, genkernel uses
373<path>/usr/share/genkernel/archName</path> for configuration files for
374that architecture.
375</p>
376
377</body>
378</section>
379<section>
380<title>How the system bootstrapping works</title>
381<body>
382
383<ol>
384 <li>
385 The bootloader loads the genkernel image, built to the specification of the
386 configuration files in the genkernel directories as well as the initrd
387 which is prepared by genkernel.
388 </li>
389 <li>
390 The kernel boots up, allocates a small amount of RAM in which busybox is
391 initialized, which probes the system with the modules in the modules_load
392 list for the architecture.
393 </li>
394 <li>
395 Once done, and providing that the <c>real_root</c> parameter which is the
396 root boot device as busybox sees things is found, the system is booted from
397 the device.
398 </li>
399</ol>
400
401</body>
402</section>
403<section>
404<title>The configuration files</title>
405<body>
406
407<ul>
408 <li>
409 <path>busy-config</path>: This is the configuration which is used to build
410 busybox for your architecture.
411 </li>
412 <li>
413 <path>config.sh</path>: This is a shell script which sets various internal
414 genkernel variables. See one of the <path>config.sh</path> files for an
415 example.
416 </li>
417 <li>
418 <path>modules_load</path>: This is a file containing a space-delimited list
419 of modules which are loaded for SCSI, FireWire, ATARAID and PCMCIA support.
420 If none are available for your platform, leave the fields blank. See one of
421 the <path>modules_load</path> files for an example.
422 </li>
423</ul>
424
425<ul>
426 <li>
427 <path>kernel-config</path>: A default kernel configuration used for any
428 kernel version.
429 </li>
430 <li>
431 <path>kernel-config-2.4</path>: A default kernel configuration used for 2.4
432 series kernels.
433 </li>
434 <li>
435 <path>kernel-config-2.6</path>: A default kernel configuration used for 2.6
436 series kernels.
437 </li>
438</ul>
439
440</body>
441</section>
442</chapter>
443</guide> 942</guide>

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.40

  ViewVC Help
Powered by ViewVC 1.1.20