Gentoo Logo

1.  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
Fri Mar 29 16:21:18 CEST 2013

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 March 29th, 16:21 in the year 2013:

Code Listing 1.1: Setting the date/time

# date 032916212013

Making your Choice

The next step you need to perform is to install the stage tarball of your choice onto your system.

1.  Downloading the Stage Tarball

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

Code Listing 1.1: Going to the Gentoo mountpoint

# cd /mnt/gentoo

The table below specifies exactly which stages you need for your system. Stages may be downloaded off the official Gentoo mirrors under the experimental/mips/stages directory.

Endianness CPU Notation
Big Endian
(SGI Users)
Big Endian
(SGI Users)
Little Endian
(Cobalt Users)
Little Endian
All Standard CPU Types mipsel1

Warning: Although we provide stages for little-endian MIPS1, support for little endian MIPS systems is still restricted to the Cobalt server range. They are provided for those who may wish to experiment with Gentoo on presently unsupported platforms, thus it is assumed that you know what you're doing.

If you need to go through a proxy, export the http_proxy and ftp_proxy variables:

Code Listing 1.1: Setting proxy information for wget

# export http_proxy=""
# export ftp_proxy=""

The Gentoo/MIPS netboot images provide wget as a means of downloading files. Due to space constraints, it is not possible to provide more capable browsers on SGI netboot images. LiveCD users may use elinks.

Code Listing 1.1: Fetching the tarball via wget

# wget -c

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

Code Listing 1.1: Example checking integrity of a stage tarball

# md5sum -c stage3-mips4-2008.0.tar.bz2.DIGESTS
stage3-mips4-2008.0.tar.bz2: OK
# sha1sum -c stage3-mips4-2008.0.tar.bz2.DIGESTS
stage3-mips4-2008.0.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 1.1: Unpacking the stage

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

Make sure that you use the same options (-xjpf). The x stands for Extract, 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 Configuring the Compile Options.

1.  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 a text editor so we can alter the optimization variables we will discuss hereafter. Two editors are provided, vi (part of Busybox) and nano. We will assume you're using nano.

Code Listing 1.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.


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). Examples include ISA levels (mips1 ... mips4) and CPU models (r4400, r4600 ... etc). For pure ISA level architectures, one can simply specify -mips3 rather than -march=mips3.

Code Listing 1.1: The GCC -march and -mips# settings

(For an R4600 system...)

(Any MIPS4-class CPU...)

(Or just specify the ISA level directly...)

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 even 3 for more speed-optimization flags (every class has the same flags as the one before, plus some extras). -O2 is the recommended default. -O3 is known to cause problems when used system-wide, so we recommend that you stick to -O2.

Code Listing 1.1: The GCC O setting


A very important setting in the MIPS world is the -mabi= flag. MIPS has 3 different ABIs: 32 (pure 32-bit, aka o32), 64 (full 64-bit, aka n64) and n32 (a mix of 32-bit data structures with 64-bit instructions). This flag selects which of these you wish to use. Note you need libraries for the ABI you select. In layman's terms, this means, for example, you can't use -mabi=64 on a 32-bit userland (or even an n32 userland).

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

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 1.1: Defining the CFLAGS and CXXFLAGS variable

CFLAGS="-mabi=32 -mips4 -pipe -O2"
CXXFLAGS="${CFLAGS}"                  # Use the same settings for both variables

Note: You may also want to view the Compilation Optimization Guide for more information on how the various compilation options can affect your system.


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

Code Listing 1.1: 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).

Page updated December 17, 2013

Summary: Gentoo installs work through a stage3 archive. In this chapter we describe how you extract the stage3 archive and configure Portage.

Donate to support our development efforts.

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