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


5. Installing the Gentoo Installation Files

Content:

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

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 3: 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 lynx available, then you can immediately surf to the Gentoo mirrorlist and choose a mirror close to you. Then 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. Select one and press D to download. When you're finished, press Q to quit the browser.

Code listing 4: Surfing to the mirror listing with lynx

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

If you do not have lynx, you should have links2 at your disposal. links2 is more powerful than lynx, but has some drawbacks. One of them is that it doesn't listen to the proxy variables we have declared previously. If you need to setup a proxy, use links2 -http-proxy proxy.server.com:8080. From there on, you should follow the same steps as with lynx as they are equivalent.

Code listing 5: Surfing to the mirror listing with links2

(Without proxy)   # links2 http://www.gentoo.org/main/en/mirrors.xml
(With proxy)      # links2 -http-proxy proxy.server.com:8080 http://www.gentoo.org/main/en/mirrors.xml

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 6: 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 7: Unpacking the stage

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

Note: You can ignore any "No such file or directory" warnings regarding ./proc. Also, the message "Error exit delayed from previous errors" can be ignored as well.

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 8: 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 9: 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 10: 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>-20040412.tar.bz2. Be sure to substitute the tarball filename with your stage.

Code listing 11: Extracting the stage tarball

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

Note: You can ignore any "No such file or directory" warnings regarding ./proc. Also, the message "Error exit delayed from previous errors" can be ignored as well.

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. 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 later on.

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 12: 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 13: 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 14: 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

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/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 15: Opening /etc/make.conf

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

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

CHOST

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

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= 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 16: The GCC march setting

# AMD64 users should not use athlon-xp
-march=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 17: The GCC O setting

-O2

Other popular optimization flags are -pipe (use pipes rather than temporary files for communication between the various stages of compilation) and -fomit-frame-pointer (which doesn't keep the frame pointer in a register for functions that don't need one).

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

Code listing 18: 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

MAKEOPTS

With MAKEOPTS you define how many parallel compilations should occur when you install a package. The suggested number is the number of CPUs in your system plus one.

Code listing 19: MAKEOPTS for a regular, 1-CPU system

MAKEOPTS="-j2"

Ready, Set, Go!

Update your /mnt/gentoo/etc/make.conf to your own will and save. You are now ready to continue with Installing the Gentoo Base System.


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