Gentoo Logo

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

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

5. Installing the Gentoo Installation Files


5.a. Installing a Stage Tarball

Setting the Date/Time Right

Before you continue you need to check your date/time and update it. A misconfigured clock may lead to strange results in the future!

To verify the current date/time, run date:

Code Listing 1.1: Verifying the date/time

# date
Sun Apr 25 16:21:18 CEST 2004

If the date/time displayed is wrong, update it using the date MMDDhhmmYYYY syntax (Month, Day, hour, minute and Year). For instance, to set the date to April 25th, 16:21 in the year 2004:

Code Listing 1.2: Setting the date/time

# date 042516212004

Making your Choice

The next step you need to perform is to install the stage tarball of your choice onto your system. You have the option of downloading the required tarball from the Internet or, if you are booted from one of the Gentoo Universal LiveCDs, copy it over from the CD itself. If you have a Universal CD and the stage you want to use is on the CD, downloading it from the Internet is just a waste of bandwidth as the stage files are the same.

5.b. Default: Using a Stage from the Internet

Downloading the Stage Tarball

Go to the Gentoo mountpoint at which you mounted your filesystems (most likely /mnt/gentoo):

Code Listing 2.1: Going to the Gentoo mountpoint

# cd /mnt/gentoo

Depending on your installation medium, you have a couple of tools available to download a stage. If you have links2 available, then you can immediately surf to the Gentoo mirrorlist and choose a mirror close to you. If you don't have links2 available you should have lynx at your disposal. In this case, substitute all occurrences of links2 in the rest of the instructions with lynx.

Pick the releases/ directory, followed by your architecture (for instance x86/) and the Gentoo version (2004.2/) to finish up with the stages/ directory. There you should see all available stage files for your architecture (they might be stored within subdirectories named to the individual sub architectures). Select one and press D to download. When you're finished, press Q to quit the browser.

Code Listing 2.2: Surfing to the mirror listing with links2

(Without proxy)   # links2
(With proxy)      # links2 -http-proxy

If you want to check the integrity of the downloaded stage tarball, use md5sum and compare the output with the MD5 checksum provided on the mirror. For instance, to check the validity of the x86 stage tarball:

Code Listing 2.3: Example checking integrity of a stage tarball

# md5sum -c stage1-x86-2004.2.tar.bz2.md5
stage1-x86-2004.2.tar.bz2: OK

Unpacking the Stage Tarball

Now unpack your downloaded stage onto your system. We use GNU's tar to proceed as it is the easiest method:

Code Listing 2.4: Unpacking the stage

# tar -xvjpf stage?-*.tar.bz2

Make sure that you use the same options (-xvjpf). The x stands for Extract, the v for Verbose (okay, yes, this is optional), the j for Decompress with bzip2, the p for Preserve permissions and the f to denote that we want to extract a file, not standard input.

Now that the stage is installed, continue with Installing Portage.

5.c. Alternative: Using a Stage from the LiveCD

Extracting the Stage Tarball

The stages on the CD reside in the /mnt/cdrom/stages directory. To see a listing of available stages, use ls:

Code Listing 3.1: List all available stages

# ls /mnt/cdrom/stages

If the system replies with an error, you may need to mount the CD-ROM first:

Code Listing 3.2: Mounting the CD-ROM

# ls /mnt/cdrom/stages
ls: /mnt/cdrom/stages: No such file or directory
# mount /dev/cdroms/cdrom0 /mnt/cdrom
# ls /mnt/cdrom/stages

Now go into your Gentoo mountpoint (usually /mnt/gentoo):

Code Listing 3.3: Changing directory to /mnt/gentoo

# cd /mnt/gentoo

We will now extract the stage tarball of your choice. We will do this with the GNU tar tool. Make sure you use the same options (-xvjpf)! In the next example, we extract the stage tarball stage3-<subarch>-2004.2.tar.bz2. Be sure to substitute the tarball filename with your stage.

Code Listing 3.4: Extracting the stage tarball

# tar -xvjpf /mnt/cdrom/stages/stage3-<subarch>-2004.2.tar.bz2

Now that the stage is installed, continue with Installing Portage.

5.d. Installing Portage

Network or No Network?

If you don't have a working network connection, you have to install a Portage snapshot provided by one of our LiveCDs. This automatically assumes that you are installing from a stage3 tarball (as it is the only tarball supported for networkless installations). If you want to use prebuilt packages later on to speed up the installation, you must use a Portage snapshot from the LiveCD. Other users will download a fully updated Portage tree using emerge in the next chapter.

Continue with the appropriate part:

Installing a Portage Snapshot and Source Code from LiveCD

There is a Portage snapshot available on the Universal LiveCDs. Since you are reading this, we can safely assume you are using such a LiveCD. To install this snapshot, take a look inside /mnt/cdrom/snapshots/ to see what snapshot we have available:

Code Listing 4.1: Checking the /mnt/cdrom/snapshots content

# ls /mnt/cdrom/snapshots

Now extract the snapshot using the following construct. Again, make sure you use the correct options to tar. Also, the -C is with a capital C, not c. In the next example we use portage-20040710.tar.bz2 as the snapshot filename. Be sure to substitute with your snapshot.

Code Listing 4.2: Extracting a Portage snapshot

# tar -xvjf /mnt/cdrom/snapshots/portage-20040710.tar.bz2 -C /mnt/gentoo/usr

You also need to copy over all source code from the CD:

Code Listing 4.3: Copy over source code

# mkdir /mnt/gentoo/usr/portage/distfiles
# cp /mnt/cdrom/distfiles/* /mnt/gentoo/usr/portage/distfiles/

Now that your Portage snapshot is installed, continue with Configuring the Compile Options.

5.e. Configuring the Compile Options


To optimize Gentoo, you can set a couple of variables which impact Portage behaviour. All those variables can be set as environment variables (using export) but that isn't permanent. To keep your settings, Portage provides you with /etc/make.conf, a configuration file for Portage. It is this file we will edit now.

Note: A commented listing of all possible variables can be found in /mnt/gentoo/etc/make.conf.example. For a successful Gentoo installation you'll only need to set the variables which are mentioned beneath.

Fire up your favorite editor (in this guide we use nano) so we can alter the optimization variables we will discuss hereafter.

Code Listing 5.1: Opening /etc/make.conf

# nano -w /mnt/gentoo/etc/make.conf

As you probably noticed, the make.conf.example file is structured in a generic way: commented lines start with "#", other lines define variables using the VARIABLE="content" syntax. The make.conf file uses the same syntax. Several of those variables are discussed next.


Warning: Although it might be tempting for non-stage1 users, they should not change the CHOST setting in make.conf. Doing so might render their system unusable. Again: only change this variable if you use a stage1 installation.

The CHOST variable defines what architecture gcc has to compile programs for. The possibilities are:

Architecture Subarchitecture CHOST Setting
x86 i386 i386-pc-linux-gnu
x86 i486 i486-pc-linux-gnu
x86 i586 i586-pc-linux-gnu
x86 i686 and above (incl. athlon) i686-pc-linux-gnu
alpha alpha-unknown-linux-gnu
ppc powerpc-unknown-linux-gnu
ppc64 powerpc64-unknown-linux-gnu
sparc sparc-unknown-linux-gnu
hppa (generic) hppa-unknown-linux-gnu
hppa pa7000 hppa1.1-unknown-linux-gnu
hppa pa8000 and above hppa2.0-unknown-linux-gnu
mips mips-unknown-linux-gnu
amd64 x86_64-pc-linux-gnu


The CFLAGS and CXXFLAGS variables define the optimization flags for the gcc C and C++ compiler respectively. Although we define those generally here, you will only have maximum performance if you optimize these flags for each program separately. The reason for this is because every program is different.

In make.conf you should define the optimization flags you think will make your system the most responsive generally. Don't place experimental settings in this variable; too much optimization can make programs behave bad (crash, or even worse, malfunction).

We will not explain all possible optimization options. If you want to know them all, read the GNU Online Manual(s) or the gcc info page (info gcc -- only works on a working Linux system). The make.conf.example file itself also contains lots of examples and information; don't forget to read it too.

A first setting is the -march= flag, which specifies the name of the target architecture. Possible options are described in the make.conf.example file (as comments). For instance, for the x86 Athlon XP architecture:

Code Listing 5.2: The GCC march setting

# AMD64 users who want to use a native 64 bit system should not use athlon-xp

A second one is the -O flag (that is a capital O, not a zero), which specifies the gcc optimization class flag. Possible classes are s (for size-optimized), 0 (zero - for no optimizations), 1, 2 or 3 for more speed-optimization flags (every class has the same flags as the one before, plus some extras). For instance, for a class-2 optimization:

Code Listing 5.3: The GCC O setting


Another popular optimization flag is -pipe (use pipes rather than temporary files for communication between the various stages of compilation).

Mind you that using -fomit-frame-pointer (which doesn't keep the frame pointer in a register for functions that don't need one) might have serious repercussions on the debugging of applications!

When you define the CFLAGS and CXXFLAGS, you should combine several optimization flags, like in the following example:

Code Listing 5.4: Defining the CFLAGS and CXXFLAGS variable

CFLAGS="-march=athlon-xp -pipe -O2"   # AMD64 users should not use athlon-xp
CXXFLAGS="${CFLAGS}"                  # Use the same settings for both variables


With MAKEOPTS you define how many parallel compilations should occur when you install a package. A good choice is the number of CPUs in your system plus one, but this guideline isn't always perfect.

Code Listing 5.5: MAKEOPTS for a regular, 1-CPU system


Ready, Set, Go!

Update your /mnt/gentoo/etc/make.conf to your own preference and save (nano users would hit Ctrl-X). You are now ready to continue with Installing the Gentoo Base System.

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


View all

Page updated November 9, 2004

Summary: Gentoo installs work through so-called stage-files. In this chapter we describe how you extract a stage-file and configure Portage.

Sven Vermeulen

Daniel Robbins

Chris Houser

Jerry Alexandratos

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

Pierre-Henri Jondot

Eric Stockbridge

Rajiv Manglani

Jungmin Seo

Stoyan Zhekov

Jared Hudson

Colin Morey

Jorge Paulo

Carl Anderson

Jon Portnoy

Zack Gilburd

Jack Morgan

Benny Chuang


Joshua Kinard

Tobias Scherbaum

Lars Weiler

Jochen Maes

Grant Goodyear

Gerald J. Normandin Jr.

Donnie Berkholz

Ken Nowack

Donate to support our development efforts.

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