Gentoo Logo

Disclaimer : This handbook has been replaced by a newer version and is not maintained anymore.


[ << ] [ < ] [ Home ] [ > ] [ >> ]


6. Installing the Gentoo Base System

Content:

6.a. Chrooting

Optional: Selecting Mirrors

If you have booted from a Gentoo LiveCD, you are able to use mirrorselect to update /etc/make.conf so fast mirrors are used for both Portage and source code (of course in case you have a working network connection):

Warning: An error within mirrorselect might make it output garbage after the GENTOO_MIRRORS statement. Please open /mnt/gentoo/etc/make.conf and remove the garbage at the end of the GENTOO_MIRRORS statement if applicable.

Code Listing 1.1: Selecting fast mirrors

# mirrorselect -a -s4 -o | grep 'GENTOO_MIRRORS=' >> /mnt/gentoo/etc/make.conf

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

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.

Code Listing 1.2: Copy over DNS information

(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 Filesystem

Mount the /proc filesystem on /mnt/gentoo/proc to allow the installation to use the kernel-provided information even within the chrooted environment.

Code Listing 1.3: Mounting /proc

# mount -t proc none /mnt/gentoo/proc

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 (LiveCD 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.

Code Listing 1.4: Chrooting into the new environment

# chroot /mnt/gentoo /bin/bash
# env-update
 * Caching service dependencies...
# source /etc/profile

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 :-)

Optional: Updating the Portage tree

If you haven't installed a Portage snapshot in the previous chapter, you must download a recent Portage tree from the Internet. emerge --sync does this for you. Other users should skip this and continue with Configuring the USE variable.

Code Listing 1.5: Updating the Portage tree

# emerge --sync

Portage uses the RSYNC protocol for updating the Portage tree. If the above command fails due to your firewall, use emerge-webrsync which downloads and installs a Portage snapshot for you using the regular HTTP protocol.

Code Listing 1.6: Updating the Portage tree with emerge-webrsync

# emerge-webrsync

If you are warned that a new Portage version is available and that you should update Portage, you should ignore it. Portage will be updated for you later on during the installation.

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 -qt 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 /etc/make.profile/make.defaults. 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.

Code Listing 1.7: Viewing available USE flags

# 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:

Code Listing 1.8: Opening /etc/make.conf

# nano -w /etc/make.conf

Code Listing 1.9: USE setting

USE="-gtk -gnome qt kde dvd alsa cdr"

You will probably only use one or maybe two locales on your system. Up until now after compiling glibc a full set of all available locales will be created. As of now you can activate the userlocales USE flag and specify only the locales you will need in /etc/locales.build.

Code Listing 1.10: Activate the userlocales USE flag especially for glibc

# mkdir /etc/portage
# echo "sys-libs/glibc userlocales" >> /etc/portage/package.use

Now specify the locales you want to be able to use:

Code Listing 1.11: nano -w /etc/locales.build

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

Optional: Using Distributed Compiling

If you are interested in using a collection of systems to help in compiling your system you might want to take a look at our DistCC Guide. By using distcc you can use the processing power of several systems to aid you with the installation.

6.b. Differences between Stage1, Stage2 and Stage3

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

6.c. Progressing from Stage1 to Stage2

Introduction to Bootstrapping

So, you want to compile everything from scratch? Okay then :-)

In this step, we will bootstrap 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.

Bootstrapping means building the GNU C Library, GNU Compiler Collection and several other key system programs.

Before starting the bootstrap, we list a couple of options you might or might not want. If you do not want to read those, continue with Bootstrapping the System.

Optional: Downloading the Sources First

If you haven't copied over all source code 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 source code first and later bootstrap the system (for instance because you don't want to have your internet connection open during the compilation) use the -f option of the bootstrap script, which will fetch (hence the letter f) all source code for you.

Code Listing 3.1: Downloading the necessary sources

# cd /usr/portage
# scripts/bootstrap.sh -f

Bootstrapping the System

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.

Code Listing 3.2: Bootstrapping the system

# cd /usr/portage
# scripts/bootstrap.sh

Now continue with the next step, Progressing from Stage2 to Stage3.

6.d. Progressing from Stage2 to Stage3

Introduction

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

All system packages? No, not really. In this step, you will build the system packages of which there are no alternatives to use. 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.

Optional: Viewing what will be done

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

Code Listing 4.1: View what 'emerge system' will do

# emerge --pretend system | less

Optional: Downloading the Sources

If you want emerge 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 --fetchonly option of emerge which will fetch all sources for you.

Code Listing 4.2: Fetching the sources

# emerge --fetchonly system

Building the System

To start building the system, execute emerge system. Then go do something to keep your mind busy, because this step takes a long time to complete.

Code Listing 4.3: Building the System

# emerge system

You can for now safely ignore any warnings about updated configuration files (and running etc-update). When your Gentoo system is fully installed and booted, do read our documentation on Configuration File Protection.

When the build process has completed, continue with Configuring the Kernel.


[ << ] [ < ] [ Home ] [ > ] [ >> ]


Print

View all

Page updated November 6, 2004

Summary: Independent of what stage you chose, the eventual result is that you have a Gentoo base system at your disposal. This chapter describes how to progress to that stadium.

Sven Vermeulen
Author

Daniel Robbins
Author

Chris Houser
Author

Jerry Alexandratos
Author

Seemant Kulleen
Gentoo x86 Developer

Tavis Ormandy
Gentoo Alpha Developer

Jason Huebel
Gentoo AMD64 Developer

Guy Martin
Gentoo HPPA developer

Pieter Van den Abeele
Gentoo PPC developer

Joe Kallar
Gentoo SPARC developer

John P. Davis
Editor

Pierre-Henri Jondot
Editor

Eric Stockbridge
Editor

Rajiv Manglani
Editor

Jungmin Seo
Editor

Stoyan Zhekov
Editor

Jared Hudson
Editor

Colin Morey
Editor

Jorge Paulo
Editor

Carl Anderson
Editor

Jon Portnoy
Editor

Zack Gilburd
Editor

Jack Morgan
Editor

Benny Chuang
Editor

Erwin
Editor

Joshua Kinard
Editor

Tobias Scherbaum
Editor

Grant Goodyear
Reviewer

Gerald J. Normandin Jr.
Reviewer

Donnie Berkholz
Reviewer

Ken Nowack
Reviewer

Lars Weiler
Contributor

Donate to support our development efforts.

Copyright 2001-2014 Gentoo Foundation, Inc. Questions, Comments? Contact us.