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

<!-- The content of this document is licensed under the CC-BY-SA license -->
<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->

<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-install-ia64-kernel.xml,v 1.31 2013/04/06 08:24:16 swift Exp $ -->

<sections>

<version>21</version>
<date>2013-04-06</date>

<section>
<title>Installing the Sources</title>
<subsection>
<title>Choosing a Kernel</title>
<body>

<p>
The core around which all distributions are built is the Linux kernel. It is the
layer between the user programs and your system hardware. Gentoo provides its
users several possible kernel sources. A full listing with description is
available at the <uri link="/doc/en/gentoo-kernel.xml">Gentoo Kernel
Guide</uri>. 
</p>

<p>
For <keyval id="arch"/> systems, we will use <c>gentoo-sources</c> (contains
additional patches for extra features).
</p>

<p>
Now install it using <c>emerge</c>.
</p>

<pre caption="Installing a kernel source">
# <i>emerge gentoo-sources</i>
</pre>

<p>
When you take a look in <path>/usr/src</path> you should see a symlink called
<path>linux</path> pointing to your kernel source. In this case, the installed
kernel source points to <c>gentoo-sources-<keyval id="kernel-version"/></c>.
Your version may be different, so keep this in mind.
</p>

<pre caption="Viewing the kernel source symlink">
# <i>ls -l /usr/src/linux</i>
lrwxrwxrwx    1 root   root    12 Oct 13 11:04 /usr/src/linux -&gt; linux-<keyval id="kernel-version"/>
</pre>

<p>
Now it is time to configure and compile your kernel source. You can use
<c>genkernel</c> for this, which will build a generic kernel as used by the
Installation CD. We explain the "manual" configuration first though, as it is
the best way to optimize your environment.
</p>

<p>
If you want to manually configure your kernel, continue now with <uri
link="#manual">Default: Manual Configuration</uri>. If you want to use 
<c>genkernel</c> you should read <uri link="#genkernel">Alternative: Using 
genkernel</uri> instead.
</p>

</body>
</subsection>
</section>
<section id="manual">
<title>Default: Manual Configuration</title>
<subsection>
<title>Introduction</title>
<body>

<p>
Manually configuring a kernel is often seen as the most difficult procedure a
Linux user ever has to perform. Nothing is less true -- after configuring a
couple of kernels you don't even remember that it was difficult ;)
</p>

<p>
However, one thing <e>is</e> true: you must know your system when you start
configuring a kernel manually. Most information can be gathered by emerging 
pciutils (<c>emerge pciutils</c>) which contains <c>lspci</c>. You will now 
be able to  use <c>lspci</c> within the chrooted environment. You may safely 
ignore any <e>pcilib</e> warnings (like pcilib: cannot open 
/sys/bus/pci/devices) that <c>lspci</c> throws out. Alternatively, you can run 
<c>lspci</c> from a <e>non-chrooted</e> environment. The results are the same. 
You can also run <c>lsmod</c> to see what kernel modules the Installation CD 
uses (it might provide you with a nice hint on what to enable).
</p>

<p>
Now go to your kernel source directory and execute <c>make menuconfig</c>. This
will fire up an ncurses-based configuration menu.
</p>

<pre caption="Invoking menuconfig">
# <i>cd /usr/src/linux</i>
# <i>make menuconfig</i>
</pre>

<p>
You will be greeted with several configuration sections. We'll first list some
options you must activate (otherwise Gentoo will not function, or not function
properly without additional tweaks).
</p>

</body>
</subsection>
<subsection>
<title>Activating Required Options</title>
<body>

<p>
Make sure that every driver that is vital to the booting of your system (such as
SCSI controller, ...) is compiled <e>in</e> the kernel and not as a module,
otherwise your system will not be able to boot completely.
</p>

<p>
Now select the correct system type and processor type. If you don't know what
kind of IA64 system type you have, <c>DIG-compliant</c> is a good default
choice. If you are installing on an SGI system make sure you select the
SGI system type, your kernel may just lock up and refuse to boot otherwise.
</p>

<pre caption="Selecting correct system type">
System type ---&gt;
  <comment>(Change according to your system)</comment>
  <i>DIG-compliant</i>
Processor type ---&gt;
  <comment>(Change according to your system)</comment>
  <i>Itanium 2</i>
</pre>

<p>
Next select <e>Maintain a devtmpfs file system to mount at /dev</e> so that
critical device files are already available early in the boot process.
</p>

<pre caption="Enabling devtmpfs support">
Device Drivers ---&gt;
  Generic Driver Options ---&gt;
    [*] Maintain a devtmpfs filesystem to mount at /dev
    [ ]   Automount devtmpfs at /dev, after the kernel mounted the rootfs
</pre>

<p>
Now go to <c>File Systems</c> and select support for the filesystems you use.
<e>Don't</e> compile the file system you use for the root filesystem as module,
otherwise your Gentoo system will not be able to mount your partition. Also
select <c>Virtual memory</c> and <c>/proc file system</c>.
</p>

<pre caption="Selecting necessary file systems">
File systems ---&gt;
  Pseudo Filesystems ---&gt;
    [*] /proc file system support
    [*] Virtual memory file system support (former shm fs)

<comment>(Select one or more of the following options as needed by your system)</comment>
  &lt;*&gt; Reiserfs support
  &lt;*&gt; Ext3 journalling file system support
  &lt;*&gt; JFS filesystem support
  &lt;*&gt; Second extended fs support
  &lt;*&gt; XFS filesystem support

<comment>(Be sure to enable VFAT support for the EFI partition)</comment>
  DOS/FAT/NT Filesystems  ---&gt;
    &lt;*&gt; VFAT (Windows-95) fs support

<comment>(Enable GPT partition label support if you used that previously</comment>
-*- Enable the block layer --->
    ...
    Partition Types --->
    [*] Advanced partition selection
      ...
      [*] EFI GUID Partition support
</pre>

<p>
If you are using PPPoE to connect to the Internet or you are using a dial-up
modem, you will need the following options in the kernel:
</p>

<pre caption="Selecting PPPoE necessary drivers">
Device Drivers ---&gt;
  Network device support ---&gt;
    &lt;*&gt; PPP (point-to-point protocol) support
    &lt;*&gt;   PPP support for async serial ports
    &lt;*&gt;   PPP support for sync tty ports
</pre>

<p>
The two compression options won't harm but are not definitely needed, neither
does the <c>PPP over Ethernet</c> option, that might only be used by <c>ppp</c>
when configured to do kernel mode PPPoE.
</p>

<p>
If you require it, don't forget to include support in the kernel for your
ethernet card.
</p>

<p>
If you have an Intel CPU that supports HyperThreading (tm), or you have a
multi-CPU system, you should activate "Symmetric multi-processing support":
</p>

<pre caption="Activating SMP support">
Processor type and features  ---&gt;
  [*] Symmetric multi-processing support
</pre>

<p>
If you use USB Input Devices (like Keyboard or Mouse) don't forget to enable
those as well:
</p>

<pre caption="Activating USB Support for Input Devices">
Device Drivers ---&gt;
  [*] HID Devices  ---&gt;
    &lt;*&gt;   USB Human Interface Device (full HID) support
</pre>

<p>
When you've finished configuring the kernel, continue with <uri 
link="#compiling">Compiling and Installing</uri>.
</p>

</body>
</subsection>
<subsection id="compiling">
<title>Compiling and Installing</title>
<body>

<p>
Now that your kernel is configured, it is time to compile and install it. Exit 
the configuration and start the compilation process:
</p>

<pre caption="Compiling the kernel">
# <i>make &amp;&amp; make modules_install</i>
</pre>

<p>
When the kernel has finished compiling, copy the kernel image to <path>/</path>.
Use whatever name you feel is appropriate for your kernel choice and remember it
as you will need it later on when you configure your bootloader. Remember to
replace <c>vmlinuz</c> with the name and version of your kernel.
</p>

<pre caption="Installing the kernel">
# <i>cp vmlinux.gz /boot/vmlinuz</i>
</pre>

</body>
</subsection>
<subsection id="initramfs">
<title>(Optional) Building an Initramfs</title>
<body>

<p>
If you use a specific partition layout where important file system locations
(like <path>/usr</path> or <path>/var</path>) are on separate partitions, then
you will need to setup an initramfs so that this partition can be mounted before
it is needed.
</p>

<p>
Without an initramfs, you risk that the system will not boot up properly as the
tools that are responsible for mounting the file systems need information that
resides on those file systems. An initramfs will pull in the necessary files
into an archive which is used right after the kernel boots, but before the
control is handed over to the <c>init</c> tool. Scripts on the initramfs will
then make sure that the partitions are properly mounted before the system
continues booting.
</p>

<p>
To install an initramfs, install <c>genkernel</c> first, then have it 
generate an initramfs for you.
</p>

<pre caption="Building an initramfs">
# <i>emerge genkernel</i>
# <i>genkernel --bootdir=/. --no-mountboot --install initramfs</i>
</pre>

<p>
If you need specific support in the initramfs, such as lvm or raid, add in the
appropriate options to genkernel. See <c>genkernel --help</c> for more
information, or the next example which enables support for LVM and software raid
(mdadm):
</p>

<pre caption="Building an initramfs with support for LVM and software raid">
# <i>genkernel --bootdir=/. --no-mountboot --lvm --mdadm --install initramfs</i>
</pre>
 
<p>
The initramfs will be stored in <path>/</path>. You can find the file by simply
listing the files starting with <path>initramfs</path>:
</p>

<pre caption="Checking the initramfs file name">
# <i>ls /initramfs*</i>
</pre>

<p>
Now continue with <uri link="#kernel_modules">Kernel Modules</uri>.
</p>

</body>
</subsection>
</section>
<section id="genkernel">
<title>Alternative: Using genkernel</title>
<body>

<p>
If you are reading this section, you have chosen to use our <c>genkernel</c>
script to configure your kernel for you.
</p>

<p>
Now that your kernel source tree is installed, it's now time to compile your 
kernel by using our <c>genkernel</c> script to automatically build a kernel for 
you. <c>genkernel</c> works by configuring a kernel nearly identically to the 
way our Installation CD kernel is configured. This means that when you use 
<c>genkernel</c> to build your kernel, your system will generally detect all 
your hardware at boot-time, just like our Installation CD does. Because 
genkernel doesn't require any manual kernel configuration, it is an ideal 
solution for those users who may not be comfortable compiling their own kernels.
</p>

<p>
Now, let's see how to use genkernel. First, emerge the genkernel ebuild:
</p>

<pre caption="Emerging genkernel">
# <i>emerge genkernel</i>
</pre>

<p>
Now, compile your kernel sources by running <c>genkernel</c>.  Be aware
though, as <c>genkernel</c> compiles a kernel that supports almost all hardware,
this compilation will take quite a while to finish!
</p>

<note>
Users of LVM2 will probably want to add <c>--lvm2</c> to the genkernel
command-line.
</note>

<pre caption="Running genkernel">
# <i>genkernel --bootdir=/. --no-mountboot all</i>
</pre>

<p>
Once <c>genkernel</c> completes, a kernel, full set of modules and 
<e>initial ram disk</e> (initramfs) will be created. We will use the kernel 
and initrd when configuring a boot loader later in this document. Write
down the names of the kernel and initrd as you will need it when writing
the bootloader configuration file. The initrd will be started immediately after 
booting to perform hardware autodetection (just like on the Installation CD)
before your "real" system starts up.
</p>

<pre caption="Checking the created kernel image name and initrd">
# <i>ls /kernel* /initramfs*</i>
</pre>

</body>
</section>
<section id="kernel_modules">
<title>Kernel Modules</title>

<subsection>
<include href="hb-install-kernelmodules.xml"/>
</subsection>

</section>
</sections>
