<?xml version='1.0' encoding="UTF-8"?>
<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">

<guide link="/doc/en/xml-guide.xml">
<title>Gentoo Linux Genkernel Guide</title>

<author title="Author">
  <mail link="plasmaroo@gentoo.org">Tim Yamin</mail>
</author>

<abstract>
This guide intends to provide a reference of all the functions
provided by Genkernel. 
</abstract>

<license/>

<version>1.0.0.1</version>
<date>April 22, 2003</date>

<chapter>
<title>Introduction</title>
<section>
<title>Introduction</title>
<body>

<p>
Genkernel is designed to allow users who are not previously used to
compiling a kernel to use a similar setup to that one that is used on
the Gentoo LiveCDs which auto-detects your hardware.
</p>

<p>
Some users may also be interested in using genkernel for hardware
which requires initialization and a working kernel before it can be
booted. Because genkernel also automatically compiles your kernel modules,
thus allowing hardware which needs to be loaded with module parameters
to be used.
</p>

</body>
</section>
<section>
<title>Is genkernel for me?</title>
<body>

<p>
Genkernel is often a good choice to those who are unused to compiling
their own kernel or those who are not certain about their hardware
configurations.
</p>

<p>
Because genkernel is designed to use a generic configuration, it
should be able to support all of your hardware - however, because all
the drivers and modules have to be compiled as well, compiling a
kernel by yourself is often much faster provided you know what you need.
</p>

<p>
Genkernel does not however, currently support booting the sytem from
LVM2/EVMS2 partitions. Users are recommended to use a manually compiled
kernel for the time being.
</p>

</body>
</section>
<section>
<title>Getting genkernel</title>
<body>

<p>
You can obtain genkernel by simply running <c>emerge genkernel</c>. Don't 
forget to use the <c>-k</c> flag for emerge if you are using binary packages, 
i.e. GRP. Due to the GRP packages having an older version of genkernel, the 
flags are different. As a result, you should consult the <uri 
link="http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&amp;chap=9">
Gentoo Handbook</uri> and <path>genkernel --help</path>.
</p>

</body>
</section>
<section>
<title>Supported platforms</title>
<body>

<p>
As of genkernel 3.0.2; the following platforms should be
supported: alpha, amd64, parisc, parisc64, ppc, ppc64, sparc, sparc64, and x86. If
you believe that there is a bug with the support code, and not with
genkernel, please file a bug at the <uri 
link="http://bugs.gentoo.org">Gentoo Bugzilla.</uri>
</p>

</body>
</section>
</chapter>

<chapter>
<title>Genkernel usage</title>
<section>
<title>Introduction</title>
<body>

<p>
Genkernel is designed to work in three modes:
</p>

<ul>
  <li>"all" mode: this builds the kernel and the initrd</li>
  <li>"kernel" mode: this only builds the kernel image</li>
  <li>"initrd" mode: this only builds the initrd</li>
</ul>

<p>
Most users will only want the "all" mode, which runs the "kernel" mode
and the "initrd" mode for you. <b>Note</b> that the "kernel" and "initrd"
modes are currently just aliases for the "all" mode, so they will
currently give you no special effect.
</p>

<p>
Although genkernel is mainly a command to make your life easier when
you need to compile a kernel, genkernel is also packed full of
different flags which allow you to customize how your kernel is
compiled or configured.
</p>

</body>
</section>
<section>
<title>Genkernel compiler flags</title>
<body>

<p>
Genkernel supports the following flags which are passed to the
relevant applications when your kernel is assembled:
</p>

<ul>
  <li>
    <b>--kernel-as=<c>someAssembler</c></b>: This specifies an assembler which 
    would be used for compiling your kernel.
  </li>
  <li>
    <b>--kernel-cc=<c>someCompiler</c></b>: This specifies a compiler which 
    would be used for compiling your kernel.
  </li>
  <li>
    <b>--kernel-ld=<c>someLinker</c></b>: This specifies a linker which would 
    be used for compiling your kernel.
  </li>
  <li>
    <b>--kernel-make=<c>someMake</c></b>: This specifies an alternate GNU Make 
    which would be used for compiling your kernel.
  </li>
</ul>

<ul>
  <li>
    <b>--utils-as=<c>someAssembler</c></b>: This specifies an assembler which 
    would be used for compiling the support utilities.
  </li>
  <li>
    <b>--utils-cc=<c>someCompiler</c></b>: This specifies a compiler which 
    would be used for compiling the support utilities.
  </li>
  <li>
    <b>--utils-ld=<c>someLinker</c></b>: This specifies a linker which would be 
    used for compiling the support utilities.
  </li>
  <li>
    <b>--utils-make=<c>someMake</c></b>: This specifies an alternate GNU Make 
    which would be used for compiling the support utilities.
  </li>
</ul>

<ul>
  <li>
    <b>--makeopts=<c>-jJobs</c></b>: This specifies the flags which would be 
    passed to GNU Make when the kernel and utilities are being compiled.
  </li>
</ul>

</body>
</section>
<section>
<title>Genkernel kernel flags</title>
<body>

<p>
Genkernel supports the following flags, some of which have
<c>--<b>no-</b>option</c> equivalents that influence
kernel compilation:
</p>

<ul>
  <li>
    <b>--callback="echo Hello"</b>: This routine calls the specified
    arguments after the kernel and the relevant modules have been built; but
    before the initrd has been built. This is useful where you might want
    external modules installed to the initrd by emerging the relevant item
    using the callback and then redefinining a Genkernel module group.
  </li>
  <li>
    <b>--<c>no-</c>clean</b>: This runs <e>or does not
    run</e> <c>make clean</c> before compiling your kernel. This
    causes all object files and dependencies to be removed.
  </li>
  <li>
    <b>--<c>no-</c>mrproper</b>: This runs <e>or does not
    run</e> <c>make mrproper</c> before compiling your kernel. This
    causes all object files, dependencies <b> and your
    configuration</b> to be removed.
  </li>
</ul>

<ul>
  <li>
    <b>--kerneldir=<path>/path/to/sources</path></b>: This specifies an 
    alternative kernel source location, instead of the default location of 
    <path>/usr/src/linux</path>.
  </li>
  <li>
    <b>--kernel-config=<path>/path/to/config-file</path></b>: This specifies an 
    alternative kernel configuration which would be used; rather than the 
    inpersistant <path>/path/to/sources/.config</path> which is used by 
    default.
  </li>
</ul>

<ul>
  <li>
    <b>--<c>no-</c>bootsplash</b>: This adds <e>or does not add</e> bootsplash 
    support in the initrd which genkernel builds. Not all architectures 
    currently support bootsplash, and a kernel that supports bootsplash is 
    also required.
  </li>
  <li>
    <b>--<c>no-</c>menuconfig</b>: This runs <e>or does not run</e> the kernel 
    menu-based configurator before building your kernel, after <c>make 
    oldconfig</c> has ran.
  </li>
</ul>

<ul>
  <li>
    <b>--no-initrdmodules</b>: This doesn't copy any modules to the initrd 
    which genkernel creates.
  </li>
  <li>
    <b>--<c>no-</c>install</b>: This installs <e>or does not install</e> your 
    kernel, modules, and initrd once the compilation has finished.
  </li>
</ul>

</body>
</section>
<section>
<title>Genkernel miscellaenous flags</title>
<body>

<p>
Genkernel also supports some miscellaneous flags which do not fit into
the other two categories:
</p>

<ul>
  <li>
    <b>--arch-override=<c>someArch</c></b>: This flag can be used to override 
    what architecture genkernel thinks you're on, if the auto-detection 
    mechanism fails (please file a bug if it does!) or if you wish to 
    cross-compile a kernel.
  </li>
</ul>

<ul>
  <li>
    <b>--busybox-config=<path>/path/to/busybox-config</path></b>: This 
    overrides the default busybox configuration with the specifid file
  </li>
  <li>
    <b>--busybox-bin=<path>/path/to/busybox-binary.tar.bz2</path></b>: Using 
    this option means that a busybox binary would not be compiled, and the 
    specified tarball would be used. Note that busybox <e>must</e> be compiled 
    statically!
  </li>
</ul>

<ul>
  <li>
    <b>--minkernpackage=<path>/output/to/yourkernel.tar.bz2</path></b>: This 
    flag outputs a tarball of the kernel, named as <path>kernel</path> and the 
    initrd named as <path>initrd</path> to the specified file. No path 
    information or modules will be includes in the tarball.
  </li>
</ul>

</body>
</section>
<section>
<title>Running genkernel</title>
<body>

<p>
All that is needed to run genkernel is just genkernel with the
necessary flags as root. For example:
</p>

<pre caption="Running genkernel">
# genkernel --menuconfig --no-clean --no-install --bootsplash all
<comment>(Would produce a kernel, asking you what how to configure it
to your desire, leaving alone any compiled object files, enabling
bootsplash support but not installing anything.)</comment>
</pre>

<p>
If you want genkernel to install your kernel as well, you must ensure
that your <path>/boot</path> partition is mounted - recent Genkernels
would automatically attempt to do this for you if MOUNTBOOT is set to
"yes" in <path>/etc/genkernel.conf</path>.
</p>

<pre caption="Mounting your /boot manually">
<comment>(If /boot is a valid entry in /etc/fstab:)</comment>
# mount /boot
<comment>(... otherwise for IDE disks:)</comment>
# mount /dev/hda1 /boot
<comment>(... and for SCSI disks:)</comment>
# mount /dev/sda1 /boot
</pre>

</body>
</section>
<section>
<title>Setting up genkernel to work with your bootloader</title>
<body>

<p>
To set up genkernel to work with your bootloader, three or four changes are
required to your bootloader configuration.
</p>

<ol>
  <li>
    Add <c>root=/dev/ram0</c> and <c>init=/linuxrc</c> to the 
    kernel parameters passed to the kernel image.
  </li>
  <li>
    Add <c>real_root=/dev/hda3</c>, for example, to the kernel parameters 
    passed to the kernel image if <path>/dev/hda3</path> contains your root 
    partition.
  </li>
  <li>
    If you are using bootsplash, add a suitable modeline such as 
    <c>vga=0x317</c> to the parameters passed to the kernel and also add 
    <c>splash=verbose</c> or <c>splash=silent</c> depending on the verboseness 
    you require from your bootsplash.
  </li>
  <li>
    Add the initrd according to how your bootloader requires it: see the <uri 
    link="http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&amp;chap=9">Gentoo 
    Handbook</uri> for details on how you would do it for your bootloader.
  </li>
</ol>

</body>
</section>
</chapter>

<chapter>
<title>Porting genkernel</title>
<section>
<title>Introduction</title>
<body>

<p>
Provided your architecture has all the required libraries and utilties
which genkernel requires, which includes but it not limited to a
working kernel for your architecture, working compiler suite, GNU
Make, and a working busybox distribution, you're all set to go!
</p>

<p>
For each architecture, genkernel uses
<path>/usr/share/genkernel/archName</path> for configuration files for
that architecture.
</p>

</body>
</section>
<section>
<title>How the system bootstrapping works</title>
<body>

<ol>
  <li>
    The bootloader loads the genkernel image, built to the specification of the 
    configuration files in the genkernel directories as well as the initrd 
    which is prepared by genkernel.
  </li>
  <li>
    The kernel boots up, allocates a small amount of RAM in which busybox is 
    initialized, which probes the system with the modules in the modules_load 
    list for the architecture.
  </li>
  <li>
    Once done, and providing that the <c>real_root</c> parameter which is the 
    root boot device as busybox sees things is found, the system is booted from 
    the device.
  </li>
</ol>

</body>
</section>
<section>
<title>The configuration files</title>
<body>

<ul>
  <li>
    <path>busy-config</path>: This is the configuration which is used to build 
    busybox for your architecture.
  </li>
  <li>
    <path>config.sh</path>: This is a shell script which sets various internal 
    genkernel variables. See one of the <path>config.sh</path> files for an 
    example.
  </li>
  <li>
    <path>modules_load</path>: This is a file containing a space-delimited list 
    of modules which are loaded for SCSI, FireWire, ATARAID and PCMCIA support. 
    If none are available for your platform, leave the fields blank. See one of 
    the <path>modules_load</path> files for an example.
  </li>
</ul>

<ul>
  <li>
    <path>kernel-config</path>: A default kernel configuration used for any 
    kernel version.
  </li>
  <li>
    <path>kernel-config-2.4</path>: A default kernel configuration used for 2.4 
    series kernels.
  </li>
  <li>
    <path>kernel-config-2.6</path>: A default kernel configuration used for 2.6 
    series kernels.
  </li>
</ul>

</body>
</section>
</chapter>
</guide>
