<?xml version='1.0' encoding="UTF-8"?>
<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/gentoo-x86-quickinstall.xml,v 1.66 2006/11/28 20:01:21 nightmorph Exp $ -->

<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">

<guide link="/doc/en/gentoo-x86-quickinstall.xml" lang="en">
<title>Gentoo Linux x86 Quick Install Guide</title>

<author title="Author">
  <mail link="neysx@gentoo.org">Xavier Neys</mail>
</author>
<author title="Author">
  <mail link="sven.vermeulen@siphos.be">Sven Vermeulen</mail>
</author>
<author title="Author">Steven Wagner</author>

<abstract>
The Quick install guide covers the Gentoo install process in a non-verbose
manner. Its purpose is to allow users to perform a stage3 install in no time.
Users should already have prior experience with installing Gentoo Linux if they
want to follow this guide.
</abstract>

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

<version>11</version>
<date>2006-11-28</date>

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

<p>
This guide contains all commands you should use to complete a stage3
installation of Gentoo. You need a connection to the Internet to download the
stage3 and Portage snapshots.
</p>

<p>
Timing output follows all commands that take more than a couple of seconds to
finish. Commands were timed on an AMD 2000 1.66 Ghz PC with 512 MB of RAM and
two SATA disks connected to a hardware controller.
</p>

<pre caption="Test box specs">
<comment>(The following specs and the timing information should help you determine
a rough estimate of the time you need to complete your install)</comment>

# <i>grep bogo /proc/cpuinfo</i>
bogomips       : 3337.81

# <i>hdparm -tT /dev/sda</i>
/dev/sda:
 Timing cached reads:   1100 MB in  2.00 seconds = 549.97 MB/sec
 Timing buffered disk reads:  224 MB in  3.01 seconds =  74.36 MB/sec

# <i>grep MemTotal /proc/meminfo</i>
MemTotal:       509248 kB
</pre>

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

<chapter>
<title>Quick Install Guide</title>
<section>
<title>Installation Media</title>
<body>

<p>
Download a CD from one of our <uri link="/main/en/mirrors.xml">mirrors</uri>.
You can find the minimal CD ISO in
<path>releases/x86/&lt;release&gt;/installcd</path> or the LiveCD ISO in
<path>releases/x86/&lt;release&gt;/livecd</path>. The <e>minimal</e>
installation CD is only useful for Internet-based installations.  You can use
the <e>LiveCD</e> to perform a networkless installation as documented in the
<uri link="/doc/en/handbook/2006.1/handbook-x86.xml">2006.1 x86 installation
handbook</uri>. The minimal CD is recommended.
</p>

<p>
<uri link="/doc/en/faq.xml#isoburning">Burn</uri> the CD and boot it.
</p>

</body>
</section>
<section>
<title>Booting the CD</title>
<body>

<p>
Press
<c>F2</c> at the boot screen to find out what boot options exist. You can
either start <c>gentoo</c> or <c>gentoo-nofb</c>, the latter disables the
framebuffer. If you booted the LiveCD, don't forget to add the <c>nox</c>
option to prevent the X graphical environment from starting. Several options
allow to enable or disable some features. If all goes well, your hardware will
be detected and all modules will be loaded. If the kernel fails to boot
properly or if your computer hangs during the boot procedure, you may have to
experiment with different configurations. The safest way is probably to use the
<c>nodetect</c> option and then load required modules explicitly.
</p>

<pre caption="Boot the minimal CD">
Gentoo Linux Installation LiveCD                     http://www.gentoo.org
Enter to Boot; F1 for kernels  F2 for options.
boot: <i>gentoo-nofb</i>
  <comment>(or in case of problems)</comment>
boot: <i>gentoo-nofb nodetect</i>
</pre>

</body>
</section>
<section>
<title>Optional: loading modules</title>
<body>

<p>
If you used the <c>nodetect</c> option, once booted, load the required modules.
You need to enable networking and have access to your disks. The <c>lspci</c>
command can help you identify your hardware.
</p>

<pre caption="Load required modules">
livecd root # <i>lspci</i>
<comment>(Use lspci's output to identify required modules)</comment>

<comment>(The following is an example, adapt it to your hardware)</comment>
livecd root # <i>modprobe 3w-9xxx</i>
livecd root # <i>modprobe r8169</i>
</pre>

</body>
</section>
<section>
<title>Network Configuration</title>
<body>

<p>
If your network does not work already, you can use <c>net-setup</c> to configure
your network. You might need to load support for your network card using
<c>modprobe</c> prior to the configuration. If you have ADSL, use
<c>pppoe-setup</c> and <c>pppoe-start</c>. For PPTP support, first edit
<path>/etc/ppp/chap-secrets</path> and <path>/etc/ppp/options.pptp</path> and
then use <c>pptp &lt;server&nbsp;ip&gt;</c>.
</p>

<p>
For wireless access, use <c>iwconfig</c> to set the wireless parameters and then
use either <c>net-setup</c> again or run <c>ifconfig</c>, <c>dhcpcd</c> and/or
<c>route</c> manually.
</p>

<p>
If you are behind a proxy, do not forget to initialize your system using 
<c>export http_proxy</c>, <c>ftp_proxy</c> and <c>RSYNC_PROXY</c>.
</p>

<pre caption="Configure networking the guided way">
livecd root # <i>net-setup eth0</i>
</pre>

<p>
Alternatively, you can start networking manually. The following example assigns
the IP address 192.168.1.10 to your PC and defines 192.168.1.1 as your router
and name server.
</p>

<pre caption="Configure networking the manual way">
livecd root # <i>ifconfig eth0 192.168.1.10/24</i>
livecd root # <i>route add default gw 192.168.1.1</i>
livecd root # <i>echo nameserver 192.168.1.1 &gt; /etc/resolv.conf</i>
</pre>

<p>
The installation CD allows you to start an <c>sshd</c> server, add additional
users, run <c>irssi</c> (a command-line chat client) and surf the web using
<c>lynx</c> or <c>links</c>.
</p>

</body>
</section>
<section>
<title>Optional: connect to your new box over ssh</title>
<body>

<p>
The most interesting feature is of course <c>sshd</c>. You can start it and
then connect from another machine and cut and paste commands from this guide.
</p>

<pre caption="Start sshd">
livecd root # <i>time /etc/init.d/sshd start</i>
 * Generating hostkey ...
<comment>(sshd generates the key and displays more output)</comment>
 * starting sshd ...                            [ok]

real   0m13.688s
user   0m9.420s
sys    0m0.090s
</pre>

<p>
Now, set the root password on the liveCD so that you can connect to it from
another PC. Please note that allowing root to connect over ssh is not
recommended under normal circumstances. If you can't trust your local network,
use a long and complex password, you should use it only once as it will
disappear after your first reboot.
</p>

<pre caption="Set the root password">
livecd root # <i>passwd</i>
New UNIX password: <comment>type_a_password</comment>
Retype new UNIX password: <comment>type_a_password</comment>
passwd: password updated successfully
</pre>

<p>
Now, you can start a terminal on another PC and connect to your new box, follow
the rest of this guide in another window, and cut and paste commands.
</p>

<pre caption="Connect to your new box from another PC">
<comment>(Use the IP address of your new box)</comment>
$ <i>ssh root@192.168.1.10</i>
The authenticity of host '192.168.1.10 (192.168.1.10)' can't be established.
RSA key fingerprint is 96:e7:2d:12:ac:9c:b0:94:90:9f:40:89:b0:45:26:8f.
Are you sure you want to continue connecting (yes/no)? <i>yes</i>
Warning: Permanently added '192.168.1.10' (RSA) to the list of known hosts.
Password: <comment>type_the_password</comment>
</pre>

</body>
</section>
<section>
<title>Preparing the Disks</title>
<body>

<p>
Use <c>fdisk</c> or <c>cfdisk</c> to create your partition layout. You need at
least a swap partition (type 82) and one Linux partition (type 83). The
following scenario creates a <path>/boot</path>, a swap and a main partition
as used in our handbook. The device name is likely to be either
<path>/dev/sda</path> for a SATA or SCSI disk, or <path>/dev/hda</path> for an
IDE disk.
</p>

<pre caption="Create the partitions">
livecd ~ # <i>fdisk /dev/sda</i>

<comment>(The rest of this guide uses the following partitioning scheme)</comment>
livecd ~ # <i>fdisk -l /dev/sda</i>

Disk /dev/sda: 599.9 GB, 599978409984 bytes
255 heads, 63 sectors/track, 72943 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          12       96358+  83  Linux
/dev/sda2              13         110      787185   82  Linux swap / Solaris
/dev/sda3             111       72943   585031072+  83  Linux
</pre>

<p>
Use <c>mke2fs</c>, <c>mke2fs -j</c>, <c>mkreiserfs</c>, <c>mkfs.xfs</c> and
<c>mkfs.jfs</c> to create file systems on your Linux partitions. Initialize your
swap partition using <c>mkswap</c> and <c>swapon</c>.
</p>

<pre caption="Create the file systems and activate swap">
<comment>(ext2 is all you need on the /boot partition)</comment>
livecd ~ # <i>mke2fs /dev/sda1</i>

<comment>(Let's use ext3 on the main partition)</comment>
livecd ~ # <i>mke2fs -j /dev/sda3</i>

<comment>(Create and activate swap)</comment>
livecd ~ # <i>mkswap /dev/sda2 &amp;&amp; swapon /dev/sda2</i>
</pre>

<p>
Mount the freshly created file systems on <path>/mnt/gentoo</path>. Create
directories for the other mount points (like <path>/mnt/gentoo/boot</path>) if
you need them and mount them too.
</p>

<pre caption="Mount the file systems">
livecd ~ # <i>mount /dev/sda3 /mnt/gentoo</i>
livecd ~ # <i>mkdir /mnt/gentoo/boot</i>
livecd ~ # <i>mount /dev/sda1 /mnt/gentoo/boot</i>
</pre>

</body>
</section>
<section>
<title>Setting Up The Stage</title>
<body>

<p>
First make sure your date and time is set correctly using <c>date
MMDDhhmmYYYY</c>. Use UTC time.
</p>

<pre caption="Set the date and UTC time">
<comment>(Check the clock)</comment>
livecd ~ # <i>date</i>
Mon Mar  6 00:14:13 UTC 2006

<comment>(Set the current date and time if required)</comment>
livecd ~ # <i>date 030600162006</i> <comment>(Format is MMDDhhmmYYYY)</comment>
Mon Mar  6 00:16:00 UTC 2006
</pre>

<p>
Next, download a stage from one of our <uri
link="/main/en/mirrors.xml">mirrors</uri>. Go to <path>/mnt/gentoo</path> and
unpack the stage using <c>tar xjpf &lt;stage3 tarball&gt;</c>.
</p>

<pre caption="Download a stage3 archive">
livecd ~ # <i>cd /mnt/gentoo</i>
livecd gentoo # <i>links http://www.gentoo.org/main/en/mirrors.xml</i>
<comment>(Pick a mirror, move to the releases/x86/current/stages directory
highlight the stage3 of your choice, probably stage3-i686-2006.1.tar.bz2
and press D to download it)</comment>

<comment>(<b>Or</b> download it directly with wget without choosing a nearby mirror)</comment>
livecd ~ # <i>cd /mnt/gentoo</i>
livecd gentoo # <i>wget http://gentoo.osuosl.org/releases/x86/current/stages/stage3-i686-2006.1.tar.bz2</i>
</pre>

<pre caption="Unpack the stage3 archive">
livecd gentoo # <i>time tar xjpf stage3*</i>

real  1m13.157s
user  1m2.920s
sys   0m7.230s
</pre>

<p>
Install the latest Portage snapshot. Proceed as for the stage3 archive: choose
a nearby mirror from our <uri link="/main/en/mirrors.xml">list</uri>, download
the latest snapshot and unpack it.
</p>

<pre caption="Download the latest Portage snapshot">
livecd gentoo # <i>cd /mnt/gentoo/usr</i>
livecd usr # <i>links http://www.gentoo.org/main/en/mirrors.xml</i>
<comment>(Pick a mirror, move to the snapshots/ directory,
highlight <b>portage-latest.tar.bz2</b> and press D to download it)</comment>

<comment>(<b>Or</b> download it directly with wget without choosing a nearby mirror)</comment>
livecd gentoo # <i>cd /mnt/gentoo/usr</i>
livecd usr # <i>wget http://gentoo.osuosl.org/snapshots/portage-latest.tar.bz2</i>
</pre>

<pre caption="Unpack the Portage snapshot">
livecd usr # <i>time tar xjf portage*</i>

real  0m51.523s
user  0m28.680s
sys   0m12.840s
</pre>

</body>
</section>
<section>
<title>Chrooting</title>
<body>

<p>
Mount the <path>/proc</path> file system, copy over the
<path>/etc/resolv.conf</path> file, then chroot into your Gentoo environment.
</p>

<pre caption="Chroot">
livecd usr # <i>cd /</i>
livecd / # <i>mount -t proc proc /mnt/gentoo/proc</i>
livecd / # <i>cp -L /etc/resolv.conf /mnt/gentoo/etc/</i>
livecd / # <i>chroot /mnt/gentoo /bin/bash</i>
livecd / # <i>env-update &amp;&amp; source /etc/profile</i>
>>> Regenerating /etc/ld.so.cache...
</pre>

</body>
</section>
<section>
<title>Set your timezone</title>
<body>

<p>
Set your time zone information by copying the correct file from
<path>/usr/share/zoneinfo</path> over the <path>/etc/localtime</path> file.
</p>

<pre caption="Copy your timezone file">
<comment>(Using Brussels as an example)</comment>
livecd / # <i>cp /usr/share/zoneinfo/Europe/Brussels /etc/localtime</i>
livecd / # <i>date</i>
Wed Mar  8 00:46:05 CET 2006
</pre>

</body>
</section>
<section>
<title>Set your host and domain name</title>
<body>

<p>
Set your host name in <path>/etc/conf.d/hostname</path> and
<path>/etc/hosts</path>.  In the following example, we use <c>mybox</c> as host
name and <c>at.myplace</c> as domain name.  You can either edit the config
files with <c>nano</c> or use the following commands:
</p>

<pre caption="Set host and domain name">
livecd / # <i>cd /etc</i>
livecd etc # <i>echo "127.0.0.1 mybox.at.myplace mybox localhost" > hosts</i>
livecd etc # <i>sed -i -e 's/HOSTNAME.*/HOSTNAME="mybox"/' conf.d/hostname</i>
<comment>(Use defined host name and check)</comment>
livecd etc # <i>hostname mybox</i>
livecd etc # <i>hostname -f</i>
mybox.at.myplace
</pre>

</body>
</section>
<section>
<title>Kernel Configuration</title>
<body>

<p>
Install a kernel source (usually <c>gentoo-sources</c> or
<c>vanilla-sources</c>), configure it, compile it and copy the
<path>arch/i386/boot/bzImage</path> file to <path>/boot</path>.
</p>

<pre caption="Install a kernel source, compile it and install the kernel">
livecd etc # <i>time emerge gentoo-sources</i>

real  2m51.435s
user  0m58.220s
sys   0m29.890s
livecd etc # <i>cd /usr/src/linux</i>
livecd linux # <i>make menuconfig</i>
<comment>(Configure your kernel)</comment>
livecd linux # <i>time make -j2</i>

<comment>(Elapsed time depends highly on the options you selected)</comment>
real  3m51.962s
user  3m27.060s
sys   0m24.310s

livecd linux # <i>make modules_install</i>
livecd linux # <i>cp arch/i386/boot/bzImage /boot/kernel</i>
</pre>

</body>
</section>
<section>
<title>Configure the system</title>
<body>

<p>
Edit your <path>/etc/fstab</path> and replace <c>BOOT</c>, <c>ROOT</c> and
<c>SWAP</c> with the actual partition names. Don't forget to check that the
file systems match your installation.
</p>

<pre caption="Example fstab">
livecd linux # <i>cd /etc</i>
livecd etc # <i>nano -w fstab</i>
/dev/<i>sda1</i>   /boot     ext2    noauto,noatime     1 2
/dev/<i>sda3</i>   /         ext3    noatime            0 1
/dev/<i>sda2</i>   none      swap    sw                 0 0
</pre>

<p>
Configure your network in <path>/etc/conf.d/net</path>. Add the <c>net.eth0</c>
init script to the default run level. If you have multiple NICs, symlink them
to the <c>net.eth0</c> init script and add them to the default run level as
well. Either edit <path>/etc/conf.d/net</path> with <c>nano</c> or use the
following commands:
</p>

<pre caption="Configure networking">
livecd etc # <i>cd conf.d</i>
livecd conf.d # <i>echo 'config_eth0=( "192.168.1.10/24" )' >> net</i>
livecd conf.d # <i>echo 'routes_eth0=( "default via 192.168.1.1" )' >> net</i>
livecd conf.d # <i>rc-update add net.eth0 default</i>
<comment>(If you compiled your network card driver as a module,
add it to /etc/modules.autoload.d/kernel-2.6)</comment>
livecd conf.d # <i>echo r8169 >> /etc/modules.autoload.d/kernel-2.6</i>
<comment>(If you want to reconnect via ssh after you have rebooted your new box:)</comment>
livecd conf.d # <i>rc-update add sshd default</i>
</pre>

<note>
Emerge <c>pcmcia-cs</c> and add it to the default run level if you need it.
</note>

<p>
Set the root password using <c>passwd</c>.
</p>

<pre caption="Set the root password">
livecd conf.d # <i>passwd</i>
New UNIX password: <comment>type_the_password</comment>
Retype new UNIX password: <comment>type_the_password_again</comment>
passwd: password updated successfully
</pre>

<p>
Check the system configuration in <path>/etc/rc.conf</path>, 
<path>/etc/conf.d/rc</path>, <path>/etc/conf.d/keymaps</path>,
<path>/etc/conf.d/clock</path> and edit any of those files if required.
</p>

<pre caption="Optional: edit some config files">
livecd conf.d # <i>nano -w /etc/rc.conf</i>
livecd conf.d # <i>nano -w /etc/conf.d/rc</i>
livecd conf.d # <i>nano -w /etc/conf.d/keymaps</i>
livecd conf.d # <i>nano -w /etc/conf.d/clock</i>
</pre>

</body>
</section>
<section>
<title>Installing System Tools</title>
<body>

<p>
Install a system logger like <c>syslog-ng</c> and a cron daemon like
<c>vixie-cron</c>, and add them to the default run level.
</p>

<note>
Cron daemons depend on an MTA. <c>mail-mta/ssmtp</c> will be pulled in as a
dependency. If you want to use a more advanced MTA, you might want to install
it now. If you are in a hurry, let ssmtp be installed and remove it later when
you install the MTA of your choice.
</note>

<pre caption="Install a syslogger and a cron daemon">
livecd conf.d # <i>time emerge syslog-ng vixie-cron</i>

real  1m52.699s
user  1m1.630s
sys   0m35.220s
livecd conf.d # <i>rc-update add syslog-ng default</i>
livecd conf.d # <i>rc-update add vixie-cron default</i>
</pre>

<p>
Install the necessary file system tools (<c>xfsprogs</c>, <c>reiserfsprogs</c>
or <c>jfsutils</c>) and networking tools (<c>dhcpcd</c> or <c>rp-pppoe</c>) if
you need any.
</p>

<pre caption="Install extra tools if required">
livecd conf.d # <i>emerge xfsprogs</i>           <comment>(If you use the XFS file system)</comment>
livecd conf.d # <i>emerge jfsutils</i>           <comment>(If you use the JFS file system)</comment>
livecd conf.d # <i>emerge reiserfsprogs</i>      <comment>(If you use the Reiser file system)</comment>
livecd conf.d # <i>emerge dhcpcd</i>             <comment>(If you need a DHCP client)</comment>
livecd conf.d # <i>USE="-X" emerge rp-pppoe</i>  <comment>(If you need PPPoE ADSL connectivity)</comment>
</pre>

</body>
</section>
<section>
<title>Configuring the Bootloader</title>
<body>

<p>
Emerge <c>grub</c> or <c>lilo</c>. Configure either
<path>/boot/grub/grub.conf</path> or <path>/etc/lilo.conf</path> and install
the bootloader you have emerged.
</p>

<p>
<b>1. Using grub</b>
</p>

<pre caption="Emerge grub and edit its configuration file">
livecd conf.d # <i>time emerge grub</i>

real  1m8.634s
user  0m39.460s
sys   0m15.280s
livecd conf.d # <i>nano -w /boot/grub/grub.conf</i>
</pre>

<pre caption="Example grub.conf">
default 0
timeout 10

title=Gentoo
root (hd0,0)
kernel /boot/kernel root=/dev/sda3
</pre>

<pre caption="Install grub">
livecd conf.d # <i>grub</i>
Probing devices to guess BIOS drives. This may take a long time.

grub> <i>root (hd0,0)</i>
 Filesystem type is ext2fs, partition type 0x83

grub> <i>setup (hd0)</i>
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  16 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2 /boot/
grub/menu.lst"... succeeded
Done.

grub> <i>quit</i>
</pre>

<p>
Now, proceed with the <uri link="#reboot">rebooting section</uri>.
</p>

<p>
<b>2. Using lilo</b>
</p>

<pre caption="Emerge lilo and edit its configuration file">
livecd conf.d # <i>time emerge lilo</i>

real  0m47.016s
user  0m22.770s
sys   0m5.980s
livecd conf.d # <i>nano -w /etc/lilo.conf</i>
</pre>

<pre caption="Example lilo.conf">
boot=/dev/sda
prompt
timeout=50
default=gentoo

image=/boot/kernel
  label=Gentoo
  read-only
  root=/dev/sda3
</pre>

<pre caption="Install lilo">
livecd conf.d # <i>lilo</i>
Added Gentoo *
</pre>

</body>
</section>
<section id="reboot">
<title>Reboot</title>
<body>

<p>
Exit the chrooted environment, unmount all file systems and reboot:
</p>

<pre caption="Reboot">
livecd conf.d # <i>exit</i>
livecd / # <i>umount /mnt/gentoo/proc /mnt/gentoo/boot /mnt/gentoo</i>
livecd / # <i>reboot</i>
<comment>(Don't forget to remove the CD)</comment>
</pre>

</body>
</section>
<section id="after-reboot">
<title>Finalizing the Installation</title>
<body>

<note>
The <b>total</b> elapsed time between the display of the boot prompt on the
minimal CD and the display of the login prompt after the reboot was
<b>00:42:31</b> on our test box. Yes, less than one hour! Note that this time
also includes the stage3, Portage snapshot and several packages download time
and the time spent configuring the kernel.
</note>

<p>
Log in as <c>root</c>, then add one or more users for daily use with
<c>useradd</c>.
</p>

<pre caption="Connect to your new box from another PC">
<comment>(Clean up your known_hosts file because your new box
has generated a new definitive hostkey)</comment>
$ <i>nano -w ~/.ssh/known_hosts</i>
<comment>(Look for the IP of your new PC and delete the line,
then save the file and exit nano)</comment>

<comment>(Use the IP address of your new box)</comment>
$ <i>ssh root@192.168.1.10</i>
The authenticity of host '192.168.1.10 (192.168.1.10)' can't be established.
RSA key fingerprint is 96:e7:2d:12:ac:9c:b0:94:90:9f:40:89:b0:45:26:8f.
Are you sure you want to continue connecting (yes/no)? <i>yes</i>
Warning: Permanently added '192.168.1.10' (RSA) to the list of known hosts.
Password: <comment>type_the_password</comment>
</pre>

<pre caption="Add a new user">
mybox ~ # <i>adduser -g users -G lp,wheel,audio,cdrom,portage,cron -m john</i>
mybox ~ # <i>passwd john</i>
New UNIX password: <comment>Set John's password</comment>
Retype new UNIX password: <comment>Type John's password again</comment>
passwd: password updated successfully
</pre>

</body>
</section>
<section>
<title>Last configuration touches</title>
<body>

<p>
Start by selecting nearby mirrors either by defining the <c>RSYNC</c> and
<c>GENTOO_MIRRORS</c> variables in <path>/etc/make.conf</path> or by using
<c>mirrorselect</c>. You can also define the number of concurrent compilation
processes at this point.
</p>

<pre caption="Use mirrorselect and set MAKEOPTS">
mybox ~ # <i>emerge mirrorselect</i>
mybox ~ # <i>mirrorselect -i -o >> /etc/make.conf</i>
mybox ~ # <i>mirrorselect -i -r -o >> /etc/make.conf</i>
<comment>(Usually, (the number of processors + 1) is a good value)</comment>
mybox ~ # <i>echo 'MAKEOPTS="-j2"' >> /etc/make.conf</i>
</pre>

<p>
Now is a good time to enable or disable some USE flags. Run <c>emerge -vpe
world</c> to list all currently installed packages and their enabled and
disabled USE flags. Either edit <path>/etc/make.conf</path> or use the
following command to define the USE variable:
</p>

<pre caption="View USE flags in use and enable or disable some">
mybox ~ # <i>emerge -vpe world</i>
<comment>(Portage displays the packages and their USE flags, as an example, let's
disable ipv6 and fortran, and enable userlocales and unicode)</comment>
mybox ~ # <i>echo 'USE="nptl nptlonly -ipv6 -fortran userlocales unicode"' >> /etc/make.conf</i>
</pre>

<p>
If you enabled the <c>userlocales</c> USE flag for versions of glibc that still
support it, you should edit <path>/etc/locales.build</path> and define the
locales you want to build.
</p>

<p>
Later versions of glibc ignore the userlocales USE flag and use
<path>/etc/locale.gen</path> instead. If you are upgrading glibc to such a
version, you should create <path>/etc/locale.gen</path> <e>and remove</e>
<path>/etc/locales.build</path>. Check the output of <c>emerge -vpe world</c>
to know whether glibc supports the userlocales USE flag.
</p>

<pre caption="Define locales">
mybox ~ # <i>cd /etc</i>
<comment>(For versions of glibc with the userlocales USE flag)</comment>
mybox etc # <i>nano -w locales.build</i>

<comment>(For recent versions of glibc, convert locales.build)</comment>
mybox etc # <i>grep '^[^#].*' locales.build | sed 's:/: :' >locale.gen</i>
mybox etc # <i>rm locales.build</i>
mybox etc # <i>nano -w locale.gen</i>
</pre>

<p>
Last but not least, you may want to alter the <c>CFLAGS</c> variable in your
<path>/etc/make.conf</path> to optimise the code to your specific needs. Please
note that using a long list of flags is rarely needed and can even lead to a
broken system. It is recommended to specify the processor type in the
<c>march</c> option and stick to <c>-O2 -pipe</c>.
</p>

<p>
You may also want to switch to <b>~x86</b>. You should only do this if you can
deal with the odd broken ebuild or package. If you'd rather keep your system
stable, don't add the <c>ACCEPT_KEYWORDS</c> variable. Adding
<c>FEATURES="parallel-fetch ccache"</c> is also a good idea.
</p>

<pre caption="Last edit of make.conf">
mybox etc # <i>nano -w make.conf</i>
<comment>(Set -march to your CPU type in CFLAGS)</comment>
CFLAGS="-O2 -march=<i>athlon-xp</i> -pipe"
<comment>(Add the following line)</comment>
FEATURES="parallel-fetch ccache"
<comment>(Only add the following if you know what you're doing)</comment>
ACCEPT_KEYWORDS="~x86"
</pre>

<p>
You might want to recompile your whole system twice to make full use of your
latest configuration changes. It would take quite a long time to complete and
yield minimal speed benefits. You can let your system optimise itself gradually
over time when new versions of packages are released. However, recompiling is
a still good idea from the standpoint of maintaining system consistency. Please
see the <uri link="/doc/en/gcc-upgrading.xml">Gentoo GCC Upgrading Guide</uri>
for a discussion on the benefits of ensuring a consistently built system and
world.
</p>

<p>
Recompiling only the packages that have already been updated since the release
or that are affected by your new USE flags will take enough time.  You might
also have to remove packages that block your upgrade. Look for "[blocks
<brite>B</brite>     ]" in the output of <c>emerge -vpuD --newuse world</c> and
use <c>emerge -C</c> to remove them.
</p>

<pre caption="Update your packages">
<comment>(Install ccache)</comment>
mybox etc # <i>emerge ccache</i>

<comment>(Please note that the switch to ~x86 causes many packages to be upgraded)</comment>
mybox etc # <i>emerge -vpuD --newuse world</i>
<comment>(Take a good look at the package list and their USE flags,
remove blocking packages if any, and start the lengthy process)</comment>
mybox etc # <i>time emerge -vuD --newuse world</i>
<comment>(79 packages have been (re)compiled)</comment>

real  180m13.276s
user  121m22.905s
sys   36m31.472s

<comment>(Remerge libtool to avoid further potential problems)</comment>
mybox etc # <i>emerge libtool</i>

<comment>(Update config files, make sure you <b>do not</b> let etc-update
update config files you have edited)</comment>
mybox etc # <i>etc-update</i>

<comment>(If perl has been updated, you should run the perl-cleaner script)</comment>
mybox etc # <i>time perl-cleaner all</i>
real  1m6.495s
user  0m42.699s
sys   0m10.641s

<comment>(In case of a major upgrade of python, you should run the python-updater script)</comment>
mybox etc # <i>python-updater</i>
</pre>

</body>
</section>
<section>
<title>What to do next</title>
<body>

<p>
Depending on what your new Gentoo machine is supposed to do, you will probably
want to install server applications or a desktop system. Just as an example,
<c>emerge gnome</c> and <c>emerge kde</c> have been timed on the ~x86 system
installed as describe above. Both have been installed from the same starting
point.
</p>

<p>
You should check our <uri link="/doc/en/">documentation index</uri> to find out
how to install and configure the applications of your choice.
</p>

<impo>
The following is only an example. It is in no way meant as a recommended setup.
</impo>

<pre caption="Emerge GNOME">
mybox etc # <i>emerge -vp gnome</i>
<comment>(Look at the list of packages and their USE flags,
then edit make.conf if required.</comment>
mybox etc # <i>nano -w /etc/make.conf</i>
<comment>(The following USE flags have been defined)</comment>
USE="nptl nptlonly -ipv6 -fortran unicode svg hal dbus \
     -kde -qt3 -qt4 -arts -eds -esd gnome gstreamer gtk firefox"

mybox etc # <i>time emerge gnome</i>
<comment>(326 packages have been emerged)</comment>

real  520m44.532s
user  339m21.144s
sys   146m22.337s
</pre>

<pre caption="Emerge KDE">
mybox etc # <i>emerge -vp kde-meta</i>
<comment>(Look at the list of packages and their USE flags,
then edit make.conf if required.</comment>
mybox etc # <i>nano -w /etc/make.conf</i>
<comment>The following USE flags have been defined)</comment>
USE="nptl nptlonly -ipv6 -fortran unicode svg hal dbus \
     kde qt3 qt4 -arts -eds -esd -gnome -gstreamer -gtk -firefox"

mybox etc # <i>time emerge kde-meta</i>
<comment>(391 packages have been emerged)</comment>

real  1171m25.318s
user  851m26.393s
sys   281m45.629s
</pre>

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