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 UTC 2005

If the date/time displayed is wrong, update it using the date MMDDhhmmYYYY syntax (Month, Day, hour, minute and Year). At this stage, you should use UTC time. You will be able to define your timezone later on. For instance, to set the date to March 29th, 16:21 in the year 2005:

Code Listing 1.1: Setting the UTC date/time

# date 032916212005

Making your Choice

The next step you need to perform is to install the stage3 tarball onto your system. You have the option of downloading the required tarball from the Internet or, if you booted one of the Gentoo Universal CDs, copy it over from the disc itself. In most cases, the command uname -m can be used to help you decide which stage file to download.

Minimal CDs and LiveDVDs do not contain any stage3 archive.

1.  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 1.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 links available, then you can immediately surf to the Gentoo mirrorlist and choose a mirror close to you: type links http://www.gentoo.org/main/en/mirrors.xml and press enter.

If you don't have links available you should have lynx at your disposal. If you need to go through a proxy, export the http_proxy and ftp_proxy variables:

Code Listing 1.1: Setting proxy information for lynx

# export http_proxy="http://proxy.server.com:port"
# export ftp_proxy="http://proxy.server.com:port"

We will now assume that you have links at your disposal.

Select a mirror closeby. Usually HTTP mirrors suffice, but other protocols are available as well. Move to the ${release-dir} directory. There you should see all available stage files for your architecture (they might be stored within subdirectories named after the individual subarchitectures). Select one and press D to download. When you're finished, press Q to quit the browser.

Code Listing 1.1: Surfing to the mirror listing with links

# links http://www.gentoo.org/main/en/mirrors.xml

(If you need proxy support with links:)
# links -http-proxy proxy.server.com:8080 http://www.gentoo.org/main/en/mirrors.xml

Make sure you download a stage3 tarball - installations using a stage1 or stage2 tarball are not supported anymore.

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.

Code Listing 1.1: Checking integrity of a stage tarball

# md5sum -c ${stage3}.DIGESTS
${stage3}: OK

Unpacking the Stage Tarball

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

Code Listing 1.1: Unpacking the stage

# tar xvjpf stage3-*.tar.bz2

Make sure that you use the same options (xvjpf). The x stands for Extract, the v for Verbose to see what happens during the extraction process (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.

1.  Installing Portage

Unpacking a Portage Snapshot

You now have to install a Portage snapshot, a collection of files that inform Portage what software titles you can install, which profiles are available, etc.

Download and Install a Portage Snapshot

Go to the mountpoint where you mounted your filesystem (most likely /mnt/gentoo):

Code Listing 1.1: Going to the Gentoo mountpoint

# cd /mnt/gentoo

Fire up links (or lynx) and go to our Gentoo mirror list. Pick a mirror close to you and open the snapshots/ directory. There, download the latest Portage snapshot (portage-latest.tar.bz2) by selecting it and pressing D.

Code Listing 1.1: Browsing the Gentoo mirrorlist

# links http://www.gentoo.org/main/en/mirrors.xml

Now exit your browser by pressing Q. You will now have a Portage snapshot stored in /mnt/gentoo.

If you want to check the integrity of the downloaded snapshot, use md5sum and compare the output with the MD5 checksum provided on the mirror.

Code Listing 1.1: Checking integrity of a Portage snapshot

# md5sum -c portage-latest.tar.bz2.md5sum
portage-latest.tar.bz2: OK

In the next step, we extract the Portage snapshot onto your filesystem. Make sure that you use the exact command; the last option is a capital C, not c.

Code Listing 1.1: Extracting the Portage snapshot

# tar xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr

1.  Configuring the Compile Options

Introduction

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/usr/share/portage/config/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 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.

CFLAGS and CXXFLAGS

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= or -mtune= flag, which specifies the name of the target architecture. Possible options are described in the make.conf.example file (as comments).

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.

Another popular optimization flag is -pipe (use pipes rather than temporary files for communication between the various stages of compilation). It has no impact on the generated code, but uses more memory. On systems with low memory, gcc might get killed. In that case, do not use this flag.

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. The default values contained in the stage3 archive you unpacked should be good enough. The following example is just an example:

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

MAKEOPTS

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

MAKEOPTS="-j2"

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 August 3, 2011

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-2012 Gentoo Foundation, Inc. Questions, Comments? Contact us.