<section>
<subsection>
<title>Chrooting</title>
<subsubsection>
<title>Optional: Selecting Mirrors</title>
<body>

<p>
If you are booted from a Gentoo LiveCD, you are able to use <c>mirrorselect</c>
to update <path>/etc/make.conf</path> so fast mirrors are used for both Portage
as source code:
</p>

<pre caption="Selecting fast mirrors">
# <i>mirrorselect -a -s4 -o &gt;&gt; /mnt/gentoo/etc/make.conf</i>
</pre>

<p>
If for some reason <c>mirrorselect</c> fails, don't panic. This step is
completely optional. If <c>mirrorselect</c> fails, the default values suffice.
</p>

</body>
</subsubsection>
<subsubsection>
<title>Entering the new Environment</title>
<body>

<p>
Now that all partitions are initialised and the base environment
installed, it is time to enter our new installation environment by
<e>chrooting</e> in it. This means that we change from the current
installation environment (LiveCD or other installation medium) to your
installation system (namely the initialised partitions).
</p>

<p>
This chrooting is done in three steps. First we will change the root
from <path>/</path> (on the installation medium) to <path>/mnt/gentoo</path> 
(on your partitions) using <c>chroot</c>. Then we will create a new environment
using <c>env-update</c>, which essentially creates environment variables.
Finally, we load those variables into memory using <c>source</c>.
</p>

<pre caption = "Chrooting into the new environment">
# <i>chroot /mnt/gentoo /bin/bash</i>
# <i>env-update</i>
Regenerating /etc/ld.so.cache...
# <i>source /etc/profile</i>
</pre>

<p>
Congratulations! You are now inside your own Gentoo Linux environment.
Ofcourse it is far from finished, which is why the installation still
has some sections left :-)
</p>

</body>
</subsubsection>
<subsubsection>
<title>Optional: Updating Portage</title>
<body>

<p>
If you are <e>not</e> using GRP, you must download a recent Portage snapshot
from the Internet. <c>emerge sync</c> does this for you:
</p>

<pre caption="Updating Portage">
# <i>emerge sync</i>
</pre>

</body>
</subsubsection>
</subsection>
<subsection>
<title>Differences between Stage1, Stage2 and Stage3</title>
<body>

<p>
Now take a seat and think of your previous steps. We asked you to
select a <e>stage1</e>, <e>stage2</e> or <e>stage3</e> and warned you
that your choice is important for further installation steps. Well, this
is the first place where your choice defines the further steps.
</p>

<ul>
<li>
If you chose <e>stage1</e>, then you have to follow <e>both</e> steps in
this section ("Progressing from Stage1 to Stage2" and "Progressing from
Stage2 to Stage3").
</li>
<li>
If you chose <e>stage2</e> you only can skip the first step
("Progressing from Stage1 to Stage2") and immediately start with the
second one ("Progressing from Stage2 to Stage3").
</li>
<li>
If you chose <e>stage3</e> (either with or without GRP) then you can skip both 
steps and continue with the next section.
</li>
</ul>

</body>
</subsection>
<subsection>
<title>Progressing from Stage1 to Stage2</title>
<subsubsection>
<title>Introduction to Bootstrapping</title>
<body>

<p>
So, you want to compile everything from scratch? Okay then :-)
</p>

<p>
In this step, we will <e>bootstrap</e> your Gentoo system. This takes a
long time, but the result is a system that has been optimized from the
ground up for your specific machine and needs.
</p>

<p>
<e>Bootstrapping</e> means building the GNU C Library, GNU Compiler
Collection and several other key system programs. The GNU Compiler
Collection even has to be built twice: first with the "generic" compiler
we provide, and a second time with the compiler you then just built.
</p>

<p>
Before starting the bootstrap, we list a couple of options you might or
might not want.
</p>

</body>
</subsubsection>
<subsubsection>
<title>Optional: Decreasing Compilation Time</title>
<body>

<p>
If you want to speed up the bootstrapping, you can temporarily deselect
java-support. This means that the GNU Compiler Collection and the GNU C
Library will be compiled without java-support (which decreases
compilation time considerably). Although this means that you wont have
the GNU Java Compiler (<c>gjc</c>) this does <e>not</e> mean that your
system won't be able to use java applets and other java-related stuff.
</p>

<p>
To deselect java-support temporarily, define <e>USE="-java"</e> before
firing up the bootstrap script.
</p>

<pre caption = "Deselecting java support">
# <i>export USE="-java"</i>
</pre>

</body>
</subsubsection>
<subsubsection>
<title>Optional: Downloading the Sources First</title>
<body>

<p>
If you haven't copied over all sourcecode before, then the bootstrap
script will download all necessary files. It goes without saying that
this only works if you have a working network connnection :-) If you want to 
download the sourcecode first and later bootstrap the system (for instance 
because you don't want to have your internet connection open during the 
compilation) use the <e>-f</e> option of the bootstrap script, which will 
fetch (hence the letter <e>f</e>) all sourcecode for you.
</p>

<pre caption = "Downloading the necessary sources">
# <i>cd /usr/portage</i>
# <i>scripts/bootstrap.sh -f</i>
</pre>

</body>
</subsubsection>
<subsubsection>
<title>Bootstrapping the System</title>
<body>

<p>
Okay then, take your keyboard and punch in the next commands to start
the bootstrap. Then go amuse yourself with something else, because this
step takes quite some time to finish.
</p>

<pre caption = "Bootstrapping the system">
# <i>cd /usr/portage</i>
# <i>scripts/bootstrap.sh</i>
</pre>

</body>
</subsubsection>
</subsection>
<subsection>
<title>Progressing from Stage2 to Stage3</title>
<subsubsection>
<title>Introduction</title>
<body>

<p>
If you are reading this section, then you have a bootstrapped system
(either because you bootstrapped it previously, or you are using a
<e>stage2</e>). Then it is now time to build all system packages.
</p>

<p>
<e>All</e> system packages? No, not really. In this step, you will build
the system packages of which there are no alternatives to use. However,
some system packages have several alternatives (such as system loggers)
and as Gentoo is all about choices, we don't want to force one upon you.
</p>

</body>
</subsubsection>
<subsubsection>
<title>Optional: Viewing what will be done</title>
<body>

<p>
If you want to know what packages will be installed, execute <c>emerge
-p system</c>. This will list all packages that will be built. As this
list is pretty big, you should also use a pager like <c>less</c> or
<c>more</c> to go up and down the list.
</p>

<pre caption = "View what 'emerge system' will do">
# <i>emerge -p system | less</i>
</pre>

</body>
</subsubsection>
<subsubsection>
<title>Optional: Downloading the sources first</title>
<body>

<p>
If you want <c>emerge</c> to download the sources before you continue
(for instance because you don't want the internet connection to be left
open while you are building all packages) you can use the <e>-f</e>
option of <c>emerge</c> which will fetch all sources for you. 
</p>

<pre caption = "Fetching the sources">
# <i>emerge -f system</i>
</pre>

<note>
This will <e>not</e> built the packages! Only fetch the sources.
</note>

</body>
</subsubsection>
<subsubsection>
<title>Building the System</title>
<body>

<p>
To start building the system, execute <c>emerge system</c>. Then go do
something else, because this step takes a long time to complete.
</p>

<pre caption = "Building the System">
# <i>emerge system</i>
</pre>

<p>
When the building has completed, go on with the next section.
</p>

</body>
</subsubsection>
</subsection>
</section>
