After installing and configuring a stage3, the eventual result is that you have a Gentoo base system at your disposal. This chapter describes how to progress to that state. 7.4 2006-11-01
Chrooting Optional: Selecting Mirrors

In order to download source code quickly it is recommended to select a fast mirror. Portage will look in your make.conf file for the GENTOO_MIRRORS variable and use the mirrors listed therein. You can surf to our mirror list and search for a mirror (or mirrors) close to you (as those are most frequently the fastest ones), but we provide a nice tool called mirrorselect which provides you with a nice interface to select the mirrors you want.

# mirrorselect -i -o >> /mnt/gentoo/etc/make.conf
Do not select any IPv6 mirrors. Our stages currently do not support IPv6.

A second important setting is the SYNC setting in make.conf. This variable contains the rsync server you want to use when updating your Portage tree (the collection of ebuilds, scripts containing all the information Portage needs to download and install software). Although you can manually enter a SYNC server for yourself, mirrorselect can ease that operation for you:

# mirrorselect -i -r -o >> /mnt/gentoo/etc/make.conf

After running mirrorselect it is adviseable to double-check the settings in /mnt/gentoo/etc/make.conf !

Copy DNS Info

One thing still remains to be done before we enter the new environment and that is copying over the DNS information in /etc/resolv.conf. You need to do this to ensure that networking still works even after entering the new environment. /etc/resolv.conf contains the nameservers for your network.

(The "-L" option is needed to make sure we don't copy a symbolic link)
# cp -L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
Mounting the /proc and /dev Filesystems

Mount the /proc filesystem on /mnt/gentoo/proc to allow the installation to use the kernel-provided information within the chrooted environment, and then mount-bind the /dev filesystem.

# mount -t proc none /mnt/gentoo/proc
# mount -o bind /dev /mnt/gentoo/dev
Entering the new Environment

Now that all partitions are initialized and the base environment installed, it is time to enter our new installation environment by chrooting into it. This means that we change from the current installation environment (Installation CD or other installation medium) to your installation system (namely the initialized partitions).

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

# chroot /mnt/gentoo /bin/bash
# env-update
>> Regenerating /etc/ld.so.cache...
# source /etc/profile
# export PS1="(chroot) $PS1"

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

Configuring Portage Updating the Portage tree

You should now update your Portage tree to the latest version. emerge --sync does this for you.

# emerge --sync
(If you're using a slow terminal like some framebuffers or a serial
console, you can add the --quiet option to speed up this process:)
# emerge --sync --quiet

If you are behind a firewall that blocks rsync traffic, you can use emerge-webrsync which will download and install a portage snapshot for you.

If you are warned that a new Portage version is available and that you should update Portage, you should do it now using emerge portage command.

Choosing the Right Profile

First, a small definition is in place.

A profile is a building block for any Gentoo system. Not only does it specify default values for CHOST, CFLAGS and other important variables, it also locks the system to a certain range of package versions. This is all maintained by the Gentoo developers.

Previously, such a profile was barely touched by the user. However, users can choose between two profiles, one for a 2.4 kernel and one for a 2.6 kernel. This requirement has been imposed to improve the integration of the 2.6 kernels.

Previously, such a profile was untouched by the users. However, there may be certain situations in which you may decide a profile change is necessary.

You can see what profile you are currently using with the following command:

# ls -FGg /etc/make.profile
lrwxrwxrwx  1 48 Apr  8 18:51 /etc/make.profile -> ../usr/portage/profiles/default-linux/x86/2006.1/

The default profile will provide you with a Linux 2.6-based system. This is the recommended default, but you have the option of choosing another profile too.

There are also desktop and server subprofiles available for some architectures. Look inside the 2006.1/ profile to see if there is one available for your architecture. You may wish to view the desktop profile's make.defaults to determine if it fits your needs.

Some users may wish to install a system based on the older Linux 2.4 profile. If you have good reason to do this, then you should first check that an additional profile exists. On x86, we can do this with the following command:

# ls -d /usr/portage/profiles/default-linux/x86/no-nptl/2.4
/usr/portage/profiles/default-linux/x86/no-nptl/2.4

The above example shows that the additional 2.4 profile exists (i.e. it didn't complain about missing file or directory). It is recommended that you stay with the default, but if you wish to switch, you can do so as follows:

(Make sure you use the right architecture, the example below is for x86)
# ln -snf /usr/portage/profiles/default-linux/x86/no-nptl/2.4 /etc/make.profile
(List the files in the 2.4 profile)
# ls -FGg /etc/make.profile/
total 12
-rw-r--r--  1 939 Dec 10 14:06 packages
-rw-r--r--  1 347 Dec  3  2004 parent
-rw-r--r--  1 573 Dec  3  2004 virtuals

For ppc, there are a number of new profiles provided with 2006.1:

(Generic PPC profile, for all PPC machines, minimal)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc32/2006.1 /etc/make.profile
(G3 profile)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc32/2006.1/G3 /etc/make.profile
(G3 Pegasos profile)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc32/2006.1/G3/Pegasos/ /etc/make.profile
(G4 (Altivec) profile)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc32/2006.1/G4 /etc/make.profile
(G4 (Altivec) Pegasos profile)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc32/2006.1/G4/Pegasos/ /etc/make.profile

For ppc64, there are a number of new profiles provided with 2006.1:

(Generic 64bit userland PPC64 profile, for all PPC64 machines)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc64/2006.1/64bit-userland /etc/make.profile
(Generic 32bit userland PPC64 profile, for all PPC64 machines)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc64/2006.1/32bit-userland /etc/make.profile
(Each type of userland has sub profiles as follows, with (userland) replaced with the chosen userland from above)
(970 profile for JS20)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc64/2006.1/(userland)/970 /etc/make.profile
(G5 profile)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc64/2006.1/(userland)/970/pmac /etc/make.profile
(POWER3 profile)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc64/2006.1/(userland)/power3 /etc/make.profile
(POWER4 profile)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc64/2006.1/(userland)/power4 /etc/make.profile
(POWER5 profile)
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc64/2006.1/(userland)/power5 /etc/make.profile
(The multilib profile is not stable as of this release.)
Configuring the USE variable

USE is one of the most powerful variables Gentoo provides to its users. Several programs can be compiled with or without optional support for certain items. For instance, some programs can be compiled with gtk-support, or with qt-support. Others can be compiled with or without SSL support. Some programs can even be compiled with framebuffer support (svgalib) instead of X11 support (X-server).

Most distributions compile their packages with support for as much as possible, increasing the size of the programs and startup time, not to mention an enormous amount of dependencies. With Gentoo you can define what options a package should be compiled with. This is where USE comes into play.

In the USE variable you define keywords which are mapped onto compile-options. For instance, ssl will compile ssl-support in the programs that support it. -X will remove X-server support (note the minus sign in front). gnome gtk -kde -qt3 -qt4 will compile your programs with gnome (and gtk) support, and not with kde (and qt) support, making your system fully tweaked for GNOME.

The default USE settings are placed in the make.defaults files of your profile. You will find make.defaults files in the directory which /etc/make.profile points to and all parent directories as well. The default USE setting is the sum of all USE settings in all make.defaults files. What you place in /etc/make.conf is calculated against these defaults settings. If you add something to the USE setting, it is added to the default list. If you remove something from the USE setting (by placing a minus sign in front of it) it is removed from the default list (if it was in the default list at all). Never alter anything inside the /etc/make.profile directory; it gets overwritten when you update Portage!

A full description on USE can be found in the second part of the Gentoo Handbook, USE flags. A full description on the available USE flags can be found on your system in /usr/portage/profiles/use.desc.

# less /usr/portage/profiles/use.desc
(You can scroll using your arrow keys, exit by pressing 'q')

As an example we show a USE setting for a KDE-based system with DVD, ALSA and CD Recording support:

# nano -w /etc/make.conf
USE="-gtk -gnome qt3 qt4 kde dvd alsa cdr"
Optional: GLIBC Locales

You will probably only use one or maybe two locales on your system. You can specify locales you will need in /etc/locale.gen.

# nano -w /etc/locale.gen

The following locales are an example to get both English (United States) and German (Germany) with the accompanying character formats (like UTF-8).

en_US ISO-8859-1
en_US.UTF-8 UTF-8
de_DE ISO-8859-1
de_DE@euro ISO-8859-15

The next step is to run locale-gen. It will generate all the locales you have specified in the /etc/locale.gen file.

locale-gen is available in glibc-2.3.6-r4 and newer. If you have an older version of glibc, you should update it now.

Now continue with Configuring the Kernel.